Mercurial > repos > cathywise > truststore_browse_testing
comparison TrustStoreGalaxyBrowse.py @ 29:157062f5c547
Fix temporary dir.
| author | Catherine Wise <catherine.wise@csiro.au> |
|---|---|
| date | Mon, 18 May 2015 11:17:03 +1000 |
| parents | 901b359bb74a |
| children | e4c13ce69e25 |
comparison
equal
deleted
inserted
replaced
| 28:a325622e2277 | 29:157062f5c547 |
|---|---|
| 129 if "/short" not in short_url: | 129 if "/short" not in short_url: |
| 130 print("The url we got back is malformed: " + json_params['URL']) | 130 print("The url we got back is malformed: " + json_params['URL']) |
| 131 sys.exit(5) | 131 sys.exit(5) |
| 132 kms_url = short_url.split("/short")[0] | 132 kms_url = short_url.split("/short")[0] |
| 133 | 133 |
| 134 tmp_dir = '/mnt/galaxy/tmp' | |
| 135 tmp = None | |
| 136 if os.path.exists(tmp_dir): | |
| 137 tmp = tmp_dir | |
| 138 | |
| 134 config = TrustStoreClient.Config( | 139 config = TrustStoreClient.Config( |
| 135 None, kms_url, CLIENT_KEY, CLIENT_SECRET, tmpDir='/mnt/galaxy/tmp') | 140 None, kms_url, CLIENT_KEY, CLIENT_SECRET, tmpDir=tmp) |
| 136 truststore = TrustStoreClient.TrustStoreClient(headless=False, config=config) | 141 truststore = TrustStoreClient.TrustStoreClient(headless=False, config=config) |
| 137 try: | 142 try: |
| 138 truststore.authenticate(username, password) | 143 truststore.authenticate(username, password) |
| 139 except TrustStoreClient.TrustStoreClientAuthenticationException as err: | 144 except TrustStoreClient.TrustStoreClientAuthenticationException as err: |
| 140 print(err) | 145 print(err) |
| 154 sys.exit(2) | 159 sys.exit(2) |
| 155 root = truststore.listDirectory(store) | 160 root = truststore.listDirectory(store) |
| 156 | 161 |
| 157 first = True | 162 first = True |
| 158 | 163 |
| 159 with open(metadata_path, 'wb') as metadata_file: | 164 if root is not None: |
| 160 for path in paths: | 165 with open(metadata_path, 'wb') as metadata_file: |
| 161 locations = utils.Navigation.files_at_path(root, path) | 166 for path in paths: |
| 162 for location in locations: | 167 locations = utils.Navigation.files_at_path(root, path) |
| 163 if not locations: | 168 for location in locations: |
| 164 print("Path not found: " + path) | 169 if not locations: |
| 165 continue | 170 print("Path not found: " + path) |
| 166 filename = "".join(c in SAFE_CHARS and c or '-' for c in location.name) | 171 continue |
| 167 extension = os.path.splitext(filename)[1] | 172 filename = "".join(c in SAFE_CHARS and c or '-' for c in location.name) |
| 168 name = construct_multi_filename(hda_id, filename, extension) | 173 extension = os.path.splitext(filename)[1] |
| 169 target_output_filename = None | 174 name = construct_multi_filename(hda_id, filename, extension) |
| 170 if first: | 175 target_output_filename = None |
| 171 target_output_filename = file_name | 176 if first: |
| 172 first = False | 177 target_output_filename = file_name |
| 173 else: | 178 first = False |
| 174 target_output_filename = os.path.normpath("/".join([extra_files_path, name])) | 179 else: |
| 175 metadata_file.write( | 180 target_output_filename = os.path.normpath("/".join([extra_files_path, name])) |
| 176 metadata_to_json(dataset_id, filename, name, extension, target_output_filename)) | 181 metadata_file.write( |
| 177 download = truststore.getFile(store, location) | 182 metadata_to_json(dataset_id, filename, name, extension, target_output_filename)) |
| 178 if download is None: | 183 download = truststore.getFile(store, location) |
| 179 print("File %s not found." % location.name) | 184 if download is None: |
| 180 sys.exit(4) | 185 print("File %s not found." % location.name) |
| 181 ungzip(download, target_output_filename) | 186 sys.exit(4) |
| 187 ungzip(download, target_output_filename) | |
| 188 else: | |
| 189 print("Store is damaged or we don't have sufficient access.") | |
| 190 sys.exit(4) | |
| 182 | 191 |
| 183 | 192 |
| 184 if __name__ == '__main__': | 193 if __name__ == '__main__': |
| 185 main() | 194 main() |
