Mercurial > repos > cathywise > truststore_browse_testing
comparison TrustStoreGalaxyBrowse.py @ 43:174df9815ecd
Fix data types.
author | Wise, Catherine (Digital, Acton) <Catherine.Wise@csiro.au> |
---|---|
date | Thu, 25 Jun 2015 11:09:43 +1000 |
parents | 5ea7590f7395 |
children | 31838e0ecf45 |
comparison
equal
deleted
inserted
replaced
42:1ca5aa0a4d6b | 43:174df9815ecd |
---|---|
7 import os | 7 import os |
8 import json | 8 import json |
9 import operator | 9 import operator |
10 import urlparse | 10 import urlparse |
11 from py_ts import TrustStoreClient, utils | 11 from py_ts import TrustStoreClient, utils |
12 # import galaxy.model # need to import model before sniff to resolve a circular import dependency | |
12 from galaxy.datatypes.checkers import util | 13 from galaxy.datatypes.checkers import util |
14 # from galaxy.datatypes import sniff | |
15 # from galaxy.datatypes.registry import Registry | |
13 | 16 |
14 # Tell urllib3 to use pyOpenSSL because we are on old Python stdlib. | 17 # Tell urllib3 to use pyOpenSSL because we are on old Python stdlib. |
15 # import urllib3.contrib.pyopenssl | 18 # import urllib3.contrib.pyopenssl |
16 # urllib3.contrib.pyopenssl.inject_into_urllib3() | 19 # urllib3.contrib.pyopenssl.inject_into_urllib3() |
17 # | 20 # |
117 output_data = all_params.get('output_data') | 120 output_data = all_params.get('output_data') |
118 extra_files_path, file_name, ext, out_data_name, hda_id, dataset_id = \ | 121 extra_files_path, file_name, ext, out_data_name, hda_id, dataset_id = \ |
119 operator.itemgetter('extra_files_path', 'file_name', 'ext', 'out_data_name', 'hda_id', 'dataset_id')(output_data[0]) | 122 operator.itemgetter('extra_files_path', 'file_name', 'ext', 'out_data_name', 'hda_id', 'dataset_id')(output_data[0]) |
120 extra_files_path = json_params['__new_file_path__'] | 123 extra_files_path = json_params['__new_file_path__'] |
121 | 124 |
125 # datatypes_registry = Registry() | |
126 # datatypes_registry.load_datatypes( | |
127 # root_dir=all_params['job_config']['GALAXY_ROOT_DIR'], | |
128 # config=all_params['job_config']['GALAXY_DATATYPES_CONF_FILE'] | |
129 # ) | |
130 | |
122 url_params = urlparse.unquote(json_params['URL']).split(";") | 131 url_params = urlparse.unquote(json_params['URL']).split(";") |
123 if len(url_params) < 3: | 132 if len(url_params) < 3: |
124 print("The url we got back is malformed: "+ json_params['URL']) | 133 print("The url we got back is malformed: "+ json_params['URL']) |
125 sys.exit(5) | 134 sys.exit(5) |
126 short_url = url_params[0] | 135 short_url = url_params[0] |
160 root = truststore.listDirectory(store) | 169 root = truststore.listDirectory(store) |
161 | 170 |
162 first = True | 171 first = True |
163 | 172 |
164 print("Preparing the following for downloading: " + str(paths)) | 173 print("Preparing the following for downloading: " + str(paths)) |
174 | |
175 # Empty parameter file. | |
176 open(file_name, 'w' ).close() | |
165 | 177 |
166 if root is not None: | 178 if root is not None: |
167 with open(metadata_path, 'wb') as metadata_file: | 179 with open(metadata_path, 'wb') as metadata_file: |
168 for path in paths: | 180 for path in paths: |
169 locations = utils.Navigation.files_at_path(root, path) | 181 locations = utils.Navigation.files_at_path(root, path) |
176 filename = "".join(c in SAFE_CHARS and c or '-' for c in location.name) | 188 filename = "".join(c in SAFE_CHARS and c or '-' for c in location.name) |
177 extension = os.path.splitext(filename)[1].strip(".") | 189 extension = os.path.splitext(filename)[1].strip(".") |
178 name = construct_multi_filename(hda_id, filename, extension) | 190 name = construct_multi_filename(hda_id, filename, extension) |
179 target_output_filename = None | 191 target_output_filename = None |
180 data_type = "new_primary_dataset" | 192 data_type = "new_primary_dataset" |
181 if first: | 193 # if first: |
182 target_output_filename = file_name | 194 # target_output_filename = file_name |
183 dataset = "new_primary_dataset" | 195 # dataset = "new_primary_dataset" |
184 first = False | 196 # first = False |
185 else: | 197 # else: |
186 target_output_filename = os.path.normpath(os.path.join(extra_files_path, name)) | 198 target_output_filename = os.path.normpath(os.path.join(extra_files_path, name)) |
187 metadata_file.write( | |
188 metadata_to_json(dataset_id, target_output_filename, name, extension, data_type)) | |
189 download = truststore.getFile(store, location) | 199 download = truststore.getFile(store, location) |
190 if download is None: | 200 if download is None: |
191 print("File %s not found." % location.name) | 201 print("File %s not found." % location.name) |
192 sys.exit(4) | 202 sys.exit(4) |
193 ungzip(download, target_output_filename) | 203 ungzip(download, target_output_filename) |
204 # ext = sniff.handle_uploaded_dataset_file(target_output_filename, datatypes_registry, ext=ext) | |
205 # print("Guessed file type: " + ext) | |
206 print("in file: " + properties_file) | |
207 metadata_file.write( | |
208 metadata_to_json(dataset_id, target_output_filename, name, extension, data_type)) | |
194 else: | 209 else: |
195 print("Store is damaged or we don't have sufficient access.") | 210 print("Store is damaged or we don't have sufficient access.") |
196 sys.exit(4) | 211 sys.exit(4) |
197 | 212 |
198 | 213 |