Previous changeset 7:f067504aa92a (2020-11-05) Next changeset 9:80af973c5277 (2021-02-26) |
Commit message:
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/idr_download commit e337464c8219abdb7e8664ba94cff46025070664" |
modified:
idr_download_by_ids.py idr_download_by_ids.xml |
b |
diff -r f067504aa92a -r 97f70f7ed077 idr_download_by_ids.py --- a/idr_download_by_ids.py Thu Nov 05 23:29:40 2020 +0000 +++ b/idr_download_by_ids.py Sun Nov 22 13:55:01 2020 +0000 |
[ |
@@ -1,4 +1,5 @@ import argparse +import json import os import sys import tarfile @@ -112,8 +113,22 @@ image_ids, channel=None, z_stack=0, frame=0, coord=(0, 0), width=0, height=0, region_spec='rectangle', - skip_failed=False, download_tar=False, omero_host='idr.openmicroscopy.org', omero_secured=True, omero_username='public', omero_password='public' + skip_failed=False, download_tar=False, omero_host='idr.openmicroscopy.org', omero_secured=False, config_file=None ): + + if config_file is None: # IDR connection + omero_username = 'public' + omero_password = 'public' + else: # other omero instance + with open(config_file) as f: + cfg = json.load(f) + omero_username = cfg['username'] + omero_password = cfg['password'] + + if omero_username == "" or omero_password == "": + omero_username = 'public' + omero_password = 'public' + # basic argument sanity checks and adjustments prefix = 'image-' # normalize image ids by stripping off prefix if it exists @@ -358,13 +373,10 @@ '-oh', '--omero-host', type=str, default="idr.openmicroscopy.org" ) p.add_argument( - '--omero-secured', action='store_false' + '--omero-secured', action='store_true', default=True ) p.add_argument( - '-u', '--omero-username', type=str, default="public" - ) - p.add_argument( - '-p', '--omero-password', type=str, default="public" + '-cf', '--config-file', dest='config_file', default=None ) args = p.parse_args() if not args.image_ids: |
b |
diff -r f067504aa92a -r 97f70f7ed077 idr_download_by_ids.xml --- a/idr_download_by_ids.xml Thu Nov 05 23:29:40 2020 +0000 +++ b/idr_download_by_ids.xml Sun Nov 22 13:55:01 2020 +0000 |
[ |
@@ -1,6 +1,6 @@ <?xml version="1.0"?> -<tool id="idr_download_by_ids" name="IDR Download" version="0.43" profile="18.09"> - <description>- download images from the Image Data Resource using image IDs</description> +<tool id="idr_download_by_ids" name="IDR/OMERO Download" version="0.43" profile="18.09"> + <description>- download images from any OMERO instance using image IDs</description> <macros> <xml name="region_spec" token_pos="upper-left corner"> <param name="x_coord" type="integer" value="0" min="0" @@ -22,12 +22,14 @@ <command detect_errors="exit_code"><![CDATA[ #if $omero_instance_type.omero_instance == "priv": + ## the user wants to use a non-public OMERO instance + ## check if credentials are set in the user-preferences, if not warn the user and exit #set $username = $__user__.extra_preferences.get('omero_account|username', "") #set $password = $__user__.extra_preferences.get('omero_account|password', "") - #if $username == "" or $password =="": - echo "OMERO connection credentials are empty. Set your credentials via: User -> Preferences -> Manage Information" && - exit 1 + #if $omero_instance_type.galaxy_test_param != 'true' and ($username == "" or $password ==""): + echo "OMERO connection credentials are empty. Set your credentials via: User -> Preferences -> Manage Information" 1>&2 && + exit 1 && #end if #end if @@ -51,13 +53,28 @@ $skip_failed $download_tar #if $omero_instance_type.omero_instance =='priv': - -h '$omero_host' - $omero_secured - -u '$username' - -p '$password' + -oh '$omero_instance_type.omero_host' + $omero_instance_type.omero_secured + -cf '$credentials' #end if 2> >(tee -a $out_log >&2) ]]></command> + <configfiles> + <configfile name="credentials"><![CDATA[ +#if $omero_instance_type.omero_instance =='priv' and $omero_instance_type.galaxy_test_param == 'true': + ## as a test for a private instance we actually use a public instance, but with credentials + #set $username = 'public' + #set $password = 'public' +#else: + #set $username = $__user__.extra_preferences.get('omero_account|username', "") + #set $password = $__user__.extra_preferences.get('omero_account|password', "") +#end if +{ + "username": "$username", + "password": "$password" +} + ]]></configfile> + </configfiles> <inputs> <conditional name="omero_instance_type"> <param name="omero_instance" type="select" label="Which OMERO instance to connect?" @@ -68,13 +85,13 @@ </param> <when value="priv"> <param name="omero_host" type="text" label="OMERO host URL"> - <validator type="regex" message="Enter a valid host location, for example, your.omero.server"> - [.A-Za-z0-9_-] - </validator> + <validator type="regex" message="Enter a valid host location, for example, your.omero.server">^[a-zA-Z0-9._-]*$</validator> + <validator type="expression" message="No two dots (..) allowed">'..' not in value</validator> </param> - <param name="omero_secured" type="boolean" label="Seured connection?" checked="true" truevalue="--omero-secured" falsevalue="" + <param name="omero_secured" type="boolean" label="Secured connection?" checked="true" truevalue="--omero-secured" falsevalue="" help="Select Yes if your OMERO instance is running with SSL, otherwise select No"> </param> + <param name="galaxy_test_param" type="hidden" value="false" /> </when> <when value="idr" /> </conditional> @@ -300,6 +317,51 @@ </assert_contents> </output> </test> + <test> + <conditional name="omero_instance_type"> + <param name="omero_instance" value="priv" /> + <param name="omero_host" value="idr.openmicroscopy.org" /> + <param name="omero_secured" value="true" /> + <param name="galaxy_test_param" value="true" /> + </conditional> + <param name="source" value="dataset" /> + <param name="id_spec" value="ids.txt" /> + <param name="channel" value="PCNT" /> + <conditional name="clip_image"> + <param name="select" value="--rectangle" /> + <param name="x_coord" value="3" /> + <param name="y_coord" value="3" /> + <param name="width" value="5" /> + <param name="height" value="5" /> + </conditional> + <param name="frame" value="0" /> + <param name="download_tar" value="false" /> + <output_collection name="output_file" type="list"> + <element name="Centrin_PCNT_Cep215_20110506_Fri-1545_0_SIR_PRJ__1884807__3__3__5__5" file="test0.tiff"/> + </output_collection> + </test> + <test expect_failure="true"> + <conditional name="omero_instance_type"> + <param name="omero_instance" value="priv" /> + <param name="omero_host" value="idr.openmicroscopy.org" /> + <param name="omero_secured" value="true" /> + </conditional> + <param name="source" value="dataset" /> + <param name="id_spec" value="ids.txt" /> + <param name="channel" value="PCNT" /> + <conditional name="clip_image"> + <param name="select" value="--rectangle" /> + <param name="x_coord" value="3" /> + <param name="y_coord" value="3" /> + <param name="width" value="5" /> + <param name="height" value="5" /> + </conditional> + <param name="frame" value="0" /> + <param name="download_tar" value="false" /> + <assert_stderr> + <has_text text="OMERO connection credentials are empty. Set your credentials via: User -> Preferences -> Manage Information" /> + </assert_stderr > + </test> </tests> <help><![CDATA[ Download image data from the IDR_ (Image Data Resource) - a public repository |