Mercurial > repos > cathywise > truststore_browse_testing
comparison TrustStoreGalaxyBrowse.py @ 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 |
comparison
equal
deleted
inserted
replaced
| 13:11344d545e88 | 14:589f9250e30f |
|---|---|
| 95 meta_dict['dataset_id'] = dataset_id | 95 meta_dict['dataset_id'] = dataset_id |
| 96 return "%s\n" % json.dumps(meta_dict) | 96 return "%s\n" % json.dumps(meta_dict) |
| 97 | 97 |
| 98 def main(): | 98 def main(): |
| 99 properties_file = sys.argv[1] | 99 properties_file = sys.argv[1] |
| 100 ouput_root = sys.argv[2] | |
| 101 json_params = None | 100 json_params = None |
| 102 metadata_path = None | 101 metadata_path = None |
| 102 all_params = None | |
| 103 with open(properties_file, 'r') as file_: | 103 with open(properties_file, 'r') as file_: |
| 104 settings = file_.read() | 104 settings = file_.read() |
| 105 print(settings) | 105 print(settings) |
| 106 all_params = json.loads(settings) | 106 all_params = json.loads(settings) |
| 107 json_params = all_params.get("param_dict") | 107 json_params = all_params.get("param_dict") |
| 108 metadata_path = all_params["job_config"]["TOOL_PROVIDED_JOB_METADATA_FILE"] | 108 metadata_path = all_params["job_config"]["TOOL_PROVIDED_JOB_METADATA_FILE"] |
| 109 | 109 |
| 110 output_filename = json_params.get('output', None) | 110 output_filename = json_params.get('output', None) |
| 111 output_data = json_params.get('output_data') | 111 output_data = all_params.get('output_data') |
| 112 extra_files_path, file_name, ext, out_data_name, hda_id, dataset_id = \ | 112 extra_files_path, file_name, ext, out_data_name, hda_id, dataset_id = \ |
| 113 operator.itemgetter('extra_files_path', 'file_name', 'ext', 'out_data_name', 'hda_id', 'dataset_id')(output_data[0]) | 113 operator.itemgetter('extra_files_path', 'file_name', 'ext', 'out_data_name', 'hda_id', 'dataset_id')(output_data[0]) |
| 114 | 114 |
| 115 url_params = json_params['URL'].split(";") | 115 url_params = json_params['URL'].split(";") |
| 116 if len(url_params) < 3: | 116 if len(url_params) < 3: |
| 145 if store is None: | 145 if store is None: |
| 146 print("Coudn't find store with that ID, or don't have access.") | 146 print("Coudn't find store with that ID, or don't have access.") |
| 147 sys.exit(2) | 147 sys.exit(2) |
| 148 root = truststore.listDirectory(store) | 148 root = truststore.listDirectory(store) |
| 149 | 149 |
| 150 first = True | |
| 151 | |
| 150 with open(metadata_path, 'wb') as metadata_file: | 152 with open(metadata_path, 'wb') as metadata_file: |
| 151 for path in paths: | 153 for path in paths: |
| 152 locations = utils.Navigation.files_at_path(root, path) | 154 locations = utils.Navigation.files_at_path(root, path) |
| 153 for location in locations: | 155 for location in locations: |
| 154 if not locations: | 156 if not locations: |
| 155 print("Path not found: " + path) | 157 print("Path not found: " + path) |
| 156 continue | 158 continue |
| 157 filename = "".join(c in SAFE_CHARS and c or '-' for c in location.name) | 159 filename = "".join(c in SAFE_CHARS and c or '-' for c in location.name) |
| 158 extension = os.path.splitext(filename)[1] | 160 extension = os.path.splitext(filename)[1] |
| 159 name = construct_multi_filename(hda_id, filename, extension) | 161 name = construct_multi_filename(hda_id, filename, extension) |
| 160 target_output_filename = os.path.normpath("/".join([ouput_root, name])) | 162 target_output_filename = None |
| 163 if first: | |
| 164 target_output_filename = file_name | |
| 165 first = False | |
| 166 else: | |
| 167 target_output_filename = os.path.normpath("/".join([extra_files_path, name])) | |
| 161 metadata_file.write( | 168 metadata_file.write( |
| 162 metadata_to_json(dataset_id, filename, name, extension, target_output_filename)) | 169 metadata_to_json(dataset_id, filename, name, extension, target_output_filename)) |
| 163 download = truststore.getFile(store, location) | 170 download = truststore.getFile(store, location) |
| 164 if download is None: | 171 if download is None: |
| 165 print("File %s not found." % location.name) | 172 print("File %s not found." % location.name) |
