changeset 9:3e8bd0d01725

Attempt to guess data type.
author Wise, Catherine (Digital, Acton) <Catherine.Wise@csiro.au>
date Thu, 25 Jun 2015 08:26:34 +1000
parents 278e80313c7f
children 7301c2e96fce
files TrustStoreGalaxyBrowse.py
diffstat 1 files changed, 10 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/TrustStoreGalaxyBrowse.py	Wed Jun 24 14:16:51 2015 +1000
+++ b/TrustStoreGalaxyBrowse.py	Thu Jun 25 08:26:34 2015 +1000
@@ -10,6 +10,8 @@
 import urlparse
 from py_ts import TrustStoreClient, utils
 from galaxy.datatypes.checkers import util
+from galaxy.datatypes import sniff
+from galaxy.datatypes.registry import Registry
 
 # Tell urllib3 to use pyOpenSSL because we are on old Python stdlib.
 # import urllib3.contrib.pyopenssl
@@ -119,6 +121,12 @@
       operator.itemgetter('extra_files_path', 'file_name', 'ext', 'out_data_name', 'hda_id', 'dataset_id')(output_data[0])
     extra_files_path = json_params['__new_file_path__']
 
+    datatypes_registry = Registry()
+    datatypes_registry.load_datatypes(
+        root_dir=all_params['job_config']['GALAXY_ROOT_DIR'],
+        config=all_params['job_config']['GALAXY_DATATYPES_CONF_FILE']
+    )
+
     url_params = urlparse.unquote(json_params['URL']).split(";")
     if len(url_params) < 3:
         print("The url we got back is malformed: "+ json_params['URL'])
@@ -184,8 +192,9 @@
                         first = False
                     else:
                         target_output_filename = os.path.normpath(os.path.join(extra_files_path, name))
+                    ext = sniff.handle_uploaded_dataset_file(filename, datatypes_registry, ext=ext)
                     metadata_file.write(
-                        metadata_to_json(dataset_id, target_output_filename, name, extension, data_type))
+                        metadata_to_json(dataset_id, target_output_filename, name, ext, data_type))
                     download = truststore.getFile(store, location)
                     if download is None:
                         print("File %s not found." % location.name)