changeset 14:589f9250e30f

Fix son reading.
author Catherine Wise <catherine.wise@csiro.au>
date Wed, 13 May 2015 10:54:07 +1000
parents 11344d545e88
children 7b3039ccf50f
files TrustStoreGalaxyBrowse.py TrustStoreGalaxyBrowse.xml
diffstat 2 files changed, 11 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/TrustStoreGalaxyBrowse.py	Wed May 13 10:30:45 2015 +1000
+++ b/TrustStoreGalaxyBrowse.py	Wed May 13 10:54:07 2015 +1000
@@ -97,9 +97,9 @@
 
 def main():
     properties_file = sys.argv[1]
-    ouput_root = sys.argv[2]
     json_params = None
     metadata_path = None
+    all_params = None
     with open(properties_file, 'r') as file_:
         settings = file_.read()
         print(settings)
@@ -108,7 +108,7 @@
         metadata_path = all_params["job_config"]["TOOL_PROVIDED_JOB_METADATA_FILE"]
 
     output_filename = json_params.get('output', None)
-    output_data = json_params.get('output_data')
+    output_data = all_params.get('output_data')
     extra_files_path, file_name, ext, out_data_name, hda_id, dataset_id = \
       operator.itemgetter('extra_files_path', 'file_name', 'ext', 'out_data_name', 'hda_id', 'dataset_id')(output_data[0])
 
@@ -147,6 +147,8 @@
         sys.exit(2)
     root = truststore.listDirectory(store)
 
+    first = True
+
     with open(metadata_path, 'wb') as metadata_file:
         for path in paths:
             locations = utils.Navigation.files_at_path(root, path)
@@ -157,7 +159,12 @@
                 filename = "".join(c in SAFE_CHARS and c or '-' for c in location.name)
                 extension = os.path.splitext(filename)[1]
                 name = construct_multi_filename(hda_id, filename, extension)
-                target_output_filename = os.path.normpath("/".join([ouput_root, name]))
+                target_output_filename = None
+                if first:
+                    target_output_filename = file_name
+                    first = False
+                else:
+                    target_output_filename = os.path.normpath("/".join([extra_files_path, name]))
                 metadata_file.write(
                     metadata_to_json(dataset_id, filename, name, extension, target_output_filename))
                 download = truststore.getFile(store, location)
--- a/TrustStoreGalaxyBrowse.xml	Wed May 13 10:30:45 2015 +1000
+++ b/TrustStoreGalaxyBrowse.xml	Wed May 13 10:54:07 2015 +1000
@@ -7,7 +7,7 @@
         <exit_code range="4" err_level="fatal" description="Could not find matching file in store." />
         <exit_code range="5" err_level="fatal" description="Bad credentials supplied. See stdout for more information." />
     </stdio>
-    <command interpreter="python">TrustStoreGalaxyBrowse.py $output "."</command>
+    <command interpreter="python">TrustStoreGalaxyBrowse.py $output</command>
     <inputs action="https://tstest-kms.it.csiro.au/kmscolab_3_0/login" check_values="false" method="get" target="_blank">
         <display>go to TrustStore server $GALAXY_URL</display>
         <!--<param name="appCallbackUrl" type="baseurl" value="/tool_runner?tool_id=ts_import_2" />-->