Mercurial > repos > cathywise > truststore_browse_testing
annotate TrustStoreGalaxyBrowse.py @ 27:901b359bb74a
We are getting closer.
| author | Catherine Wise <catherine.wise@csiro.au> | 
|---|---|
| date | Thu, 14 May 2015 15:36:42 +1000 | 
| parents | 463b024b53ff | 
| children | 157062f5c547 | 
| rev | line source | 
|---|---|
| 9 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 1 """TrustStore downloaded for Galaxy.""" | 
| 0 | 2 from __future__ import division, absolute_import, print_function, unicode_literals | 
| 3 import sys | |
| 4 import shutil | |
| 5 import gzip | |
| 6 import tempfile | |
| 7 import os | |
| 9 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 8 import json | 
| 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 9 import operator | 
| 15 | 10 import urlparse | 
| 0 | 11 from py_ts import TrustStoreClient, utils | 
| 9 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 12 from galaxy.datatypes.checkers import util | 
| 0 | 13 | 
| 16 | 14 # Tell urllib3 to use pyOpenSSL because we are on old Python stdlib. | 
| 24 
f4585bf75a8a
Give up, try to update Python instead.
 Catherine Wise <catherine.wise@csiro.au> parents: 
16diff
changeset | 15 # import urllib3.contrib.pyopenssl | 
| 
f4585bf75a8a
Give up, try to update Python instead.
 Catherine Wise <catherine.wise@csiro.au> parents: 
16diff
changeset | 16 # urllib3.contrib.pyopenssl.inject_into_urllib3() | 
| 25 
18fe446f2d02
Tell requests about the new cert bundle. FFS.
 Catherine Wise <catherine.wise@csiro.au> parents: 
24diff
changeset | 17 # | 
| 26 
463b024b53ff
The path was wrong. UUUUGH.
 Catherine Wise <catherine.wise@csiro.au> parents: 
25diff
changeset | 18 os.environ["REQUESTS_CA_BUNDLE"] = "/etc/ssl/certs/ca-certificates.crt" | 
| 16 | 19 | 
| 9 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 20 CLIENT_KEY = "desktop" | 
| 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 21 CLIENT_SECRET = "cpU92F1PT7VOCANjSknuCDp4DrubmujoBaF6b0miz8OpKNokEbGMHCaSFK5/lISbBmaaGVCgeADI2A39F3Hkeg==" | 
| 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 22 CHUNK_SIZE = 2**20 # 1Mb | 
| 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 23 SAFE_CHARS = '.-()[]0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ' | 
| 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 24 | 
| 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 25 def print_nice(elem, f, depth): | 
| 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 26 """Print the file name.""" | 
| 0 | 27 try: | 
| 28 f.write('\t'*depth + elem.name + " (" + str(len(elem.fragments)) + " parts)\n") | |
| 29 except AttributeError: | |
| 30 f.write('\t'*depth + elem.name + "\n") | |
| 31 for child in elem.children: | |
| 9 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 32 print_nice(child, f, depth+1) | 
| 0 | 33 | 
| 34 def check_gzip(file_path): | |
| 9 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 35 """Check if file is gziped.""" | 
| 0 | 36 try: | 
| 9 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 37 temp = open(file_path, "U") | 
| 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 38 magic_check = temp.read(2) | 
| 0 | 39 temp.close() | 
| 40 if magic_check != util.gzip_magic: | |
| 9 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 41 return (False, False) | 
| 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 42 except Exception: | 
| 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 43 return (False, False) | 
| 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 44 return (True, True) | 
| 0 | 45 | 
| 46 def ungzip(download, outputFile): | |
| 9 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 47 """Uncompress file.""" | 
| 0 | 48 is_gzipped, is_valid = check_gzip(download) | 
| 49 | |
| 50 if is_gzipped and not is_valid: | |
| 9 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 51 print("File is compressed (gzip) but not valid.") | 
| 0 | 52 sys.exit(4) | 
| 53 elif is_gzipped and is_valid: | |
| 9 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 54 # We need to uncompress the temp_name file, but BAM files must | 
| 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 55 # remain compressed in the BGZF format | 
| 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 56 file_handle, uncompressed = tempfile.mkstemp(prefix='data_id_upload_gunzip_', dir=os.path.dirname(outputFile), text=False ) | 
| 0 | 57 gzipped_file = gzip.GzipFile(download, 'rb') | 
| 58 while 1: | |
| 59 try: | |
| 60 chunk = gzipped_file.read(CHUNK_SIZE) | |
| 61 except IOError: | |
| 9 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 62 os.close(file_handle) | 
| 0 | 63 os.remove(uncompressed) | 
| 9 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 64 print('Problem decompressing gzipped data %s %s' % (download, outputFile)) | 
| 0 | 65 sys.exit(4) | 
| 66 if not chunk: | |
| 67 break | |
| 9 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 68 os.write(file_handle, chunk) | 
| 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 69 os.close(file_handle) | 
| 0 | 70 gzipped_file.close() | 
| 71 | |
| 72 shutil.copy(uncompressed, outputFile) | |
| 73 try: | |
| 74 os.remove(uncompressed) | |
| 75 os.remove(download) | |
| 76 except OSError: | |
| 9 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 77 pass | 
| 0 | 78 else: | 
| 79 shutil.copy(download, outputFile) | |
| 80 | |
| 9 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 81 def construct_multi_filename(id, name, file_type): | 
| 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 82 """ Implementation of *Number of Output datasets cannot be determined until | 
| 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 83 tool run* from documentation_. | 
| 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 84 .. _documentation: http://wiki.galaxyproject.org/Admin/Tools/Multiple%20Output%20Files | 
| 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 85 From https://github.com/mdshw5/galaxy-json-data-source/blob/master/json_data_source.py | 
| 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 86 """ | 
| 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 87 filename = "%s_%s_%s_%s_%s" % ('primary', id, name, 'visible', file_type) | 
| 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 88 return filename | 
| 0 | 89 | 
| 9 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 90 def metadata_to_json(dataset_id, filename, name, extesion, ds_type='dataset', primary=False): | 
| 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 91 """ Return line separated JSON | 
| 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 92 From https://github.com/mdshw5/galaxy-json-data-source/blob/master/json_data_source.py | 
| 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 93 """ | 
| 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 94 meta_dict = dict(type=ds_type, | 
| 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 95 ext=extesion, | 
| 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 96 filename=filename, | 
| 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 97 name=name, | 
| 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 98 metadata={}) | 
| 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 99 if primary: | 
| 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 100 meta_dict['base_dataset_id'] = dataset_id | 
| 0 | 101 else: | 
| 9 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 102 meta_dict['dataset_id'] = dataset_id | 
| 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 103 return "%s\n" % json.dumps(meta_dict) | 
| 0 | 104 | 
| 9 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 105 def main(): | 
| 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 106 properties_file = sys.argv[1] | 
| 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 107 json_params = None | 
| 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 108 metadata_path = None | 
| 14 | 109 all_params = None | 
| 9 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 110 with open(properties_file, 'r') as file_: | 
| 13 | 111 settings = file_.read() | 
| 112 print(settings) | |
| 113 all_params = json.loads(settings) | |
| 9 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 114 json_params = all_params.get("param_dict") | 
| 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 115 metadata_path = all_params["job_config"]["TOOL_PROVIDED_JOB_METADATA_FILE"] | 
| 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 116 | 
| 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 117 output_filename = json_params.get('output', None) | 
| 14 | 118 output_data = all_params.get('output_data') | 
| 9 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 119 extra_files_path, file_name, ext, out_data_name, hda_id, dataset_id = \ | 
| 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 120 operator.itemgetter('extra_files_path', 'file_name', 'ext', 'out_data_name', 'hda_id', 'dataset_id')(output_data[0]) | 
| 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 121 | 
| 15 | 122 url_params = urlparse.unquote(json_params['URL']).split(";") | 
| 9 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 123 if len(url_params) < 3: | 
| 15 | 124 print("The url we got back is malformed: "+ json_params['URL']) | 
| 0 | 125 sys.exit(5) | 
| 9 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 126 short_url = url_params[0] | 
| 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 127 username = url_params[1] | 
| 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 128 password = url_params[2] | 
| 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 129 if "/short" not in short_url: | 
| 15 | 130 print("The url we got back is malformed: " + json_params['URL']) | 
| 9 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 131 sys.exit(5) | 
| 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 132 kms_url = short_url.split("/short")[0] | 
| 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 133 | 
| 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 134 config = TrustStoreClient.Config( | 
| 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 135 None, kms_url, CLIENT_KEY, CLIENT_SECRET, tmpDir='/mnt/galaxy/tmp') | 
| 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 136 truststore = TrustStoreClient.TrustStoreClient(headless=False, config=config) | 
| 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 137 try: | 
| 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 138 truststore.authenticate(username, password) | 
| 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 139 except TrustStoreClient.TrustStoreClientAuthenticationException as err: | 
| 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 140 print(err) | 
| 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 141 sys.exit(5) | 
| 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 142 truststore.getPrivateKey('privkey.pem') | 
| 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 143 | 
| 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 144 path_texts = truststore.lengthenPath(short_url) | 
| 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 145 if len(path_texts) < 2: | 
| 27 
901b359bb74a
We are getting closer.
 Catherine Wise <catherine.wise@csiro.au> parents: 
26diff
changeset | 146 print("The path we got was malformed: " + str(path_texts)) | 
| 9 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 147 sys.exit(3) | 
| 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 148 paths = path_texts[1:] | 
| 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 149 store_id = path_texts[0] | 
| 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 150 | 
| 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 151 store = truststore.getStoreByID(store_id) | 
| 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 152 if store is None: | 
| 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 153 print("Coudn't find store with that ID, or don't have access.") | 
| 0 | 154 sys.exit(2) | 
| 9 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 155 root = truststore.listDirectory(store) | 
| 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 156 | 
| 14 | 157 first = True | 
| 158 | |
| 9 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 159 with open(metadata_path, 'wb') as metadata_file: | 
| 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 160 for path in paths: | 
| 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 161 locations = utils.Navigation.files_at_path(root, path) | 
| 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 162 for location in locations: | 
| 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 163 if not locations: | 
| 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 164 print("Path not found: " + path) | 
| 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 165 continue | 
| 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 166 filename = "".join(c in SAFE_CHARS and c or '-' for c in location.name) | 
| 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 167 extension = os.path.splitext(filename)[1] | 
| 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 168 name = construct_multi_filename(hda_id, filename, extension) | 
| 14 | 169 target_output_filename = None | 
| 170 if first: | |
| 171 target_output_filename = file_name | |
| 172 first = False | |
| 173 else: | |
| 174 target_output_filename = os.path.normpath("/".join([extra_files_path, name])) | |
| 9 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 175 metadata_file.write( | 
| 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 176 metadata_to_json(dataset_id, filename, name, extension, target_output_filename)) | 
| 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 177 download = truststore.getFile(store, location) | 
| 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 178 if download is None: | 
| 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 179 print("File %s not found." % location.name) | 
| 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 180 sys.exit(4) | 
| 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 181 ungzip(download, target_output_filename) | 
| 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 182 | 
| 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 183 | 
| 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 184 if __name__ == '__main__': | 
| 
0f2a5664c9eb
Actually update downloader (probably not working).
 Catherine Wise <catherine.wise@csiro.au> parents: 
0diff
changeset | 185 main() | 
