# HG changeset patch # User Catherine Wise # Date 1431911823 -36000 # Node ID 157062f5c54764fdb147aea691ee49dfdca5dc70 # Parent a325622e22777dad0c5e81a8327b5f82cc17b2bb Fix temporary dir. diff -r a325622e2277 -r 157062f5c547 TrustStoreGalaxyBrowse.py --- a/TrustStoreGalaxyBrowse.py Thu May 14 15:43:08 2015 +1000 +++ b/TrustStoreGalaxyBrowse.py Mon May 18 11:17:03 2015 +1000 @@ -131,8 +131,13 @@ sys.exit(5) kms_url = short_url.split("/short")[0] + tmp_dir = '/mnt/galaxy/tmp' + tmp = None + if os.path.exists(tmp_dir): + tmp = tmp_dir + config = TrustStoreClient.Config( - None, kms_url, CLIENT_KEY, CLIENT_SECRET, tmpDir='/mnt/galaxy/tmp') + None, kms_url, CLIENT_KEY, CLIENT_SECRET, tmpDir=tmp) truststore = TrustStoreClient.TrustStoreClient(headless=False, config=config) try: truststore.authenticate(username, password) @@ -156,29 +161,33 @@ first = True - with open(metadata_path, 'wb') as metadata_file: - for path in paths: - locations = utils.Navigation.files_at_path(root, path) - for location in locations: - if not locations: - print("Path not found: " + path) - continue - 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 = 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) - if download is None: - print("File %s not found." % location.name) - sys.exit(4) - ungzip(download, target_output_filename) + if root is not None: + with open(metadata_path, 'wb') as metadata_file: + for path in paths: + locations = utils.Navigation.files_at_path(root, path) + for location in locations: + if not locations: + print("Path not found: " + path) + continue + 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 = 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) + if download is None: + print("File %s not found." % location.name) + sys.exit(4) + ungzip(download, target_output_filename) + else: + print("Store is damaged or we don't have sufficient access.") + sys.exit(4) if __name__ == '__main__':