Mercurial > repos > cathywise > truststore_import
comparison TrustStoreGalaxyImport.py @ 37:2ced2ca1c758
Multiple downloads.
author | Catherine Wise <catherine.wise@csiro.au> |
---|---|
date | Fri, 31 Jan 2014 11:32:24 +1100 |
parents | 6e2dba73eebd |
children |
comparison
equal
deleted
inserted
replaced
36:8e8a88fe0f4f | 37:2ced2ca1c758 |
---|---|
48 else: | 48 else: |
49 shutil.copy(download, outputFile) | 49 shutil.copy(download, outputFile) |
50 | 50 |
51 if __name__ == '__main__': | 51 if __name__ == '__main__': |
52 | 52 |
53 kms_url = sys.argv[1] | 53 kms_url = "https://tstest-kms.it.csiro.au/kmscolab_3_0" |
54 ims_url = sys.argv[2] | 54 ims_url = "https://tstest-ims.it.csiro.au/ims_3_0/services/IMS" |
55 username = sys.argv[3] | 55 username = sys.argv[1] |
56 password = sys.argv[4] | 56 password = sys.argv[2] |
57 client_key = sys.argv[5] | 57 client_key = "desktop" |
58 client_secret = sys.argv[6] | 58 client_secret = "cpU92F1PT7VOCANjSknuCDp4DrubmujoBaF6b0miz8OpKNokEbGMHCaSFK5/lISbBmaaGVCgeADI2A39F3Hkeg==" |
59 storename = sys.argv[7] | 59 storename = sys.argv[3] |
60 path = sys.argv[8] | 60 path = sys.argv[4] |
61 fileType = sys.argv[5] | |
61 filename = "" | 62 filename = "" |
62 outputFile = "" | 63 outputFile = "" |
63 if len(sys.argv) > 10: | 64 if len(sys.argv) > 9: |
64 filename = sys.argv[9] | 65 filename = sys.argv[6] |
65 outputFile = sys.argv[10] | 66 outputFile = sys.argv[7] |
66 # outputFileId = sys.argv[11] | 67 outputFileId = sys.argv[8] |
67 # outputFileType = sys.argv[12] | 68 otherFilesDir = sys.argv[9] |
68 # otherFilesDir = sys.argv[13] | |
69 else: | 69 else: |
70 outputFile = sys.argv[9] | 70 outputFile = sys.argv[6] |
71 | 71 |
72 config = TrustStoreClient.Config(ims_url, kms_url, client_key, client_secret) | 72 config = TrustStoreClient.Config(ims_url, kms_url, client_key, client_secret) |
73 ts = TrustStoreClient.TrustStoreClient(headless=True, config=config) | 73 ts = TrustStoreClient.TrustStoreClient(headless=True, config=config) |
74 try: | 74 try: |
75 ts.authenticate(username, password) | 75 ts.authenticate(username, password) |
92 else: | 92 else: |
93 location = root | 93 location = root |
94 if filename and filename != "": | 94 if filename and filename != "": |
95 outputFileList = [outputFile] | 95 outputFileList = [outputFile] |
96 inputFileList = None | 96 inputFileList = None |
97 # if "," in filename: # we have multiple files guys. | 97 if "," in filename: # we have multiple files guys. |
98 # inputFileList = filename.split(",") | 98 inputFileList = filename.split(",") |
99 # for inputFile in inputFileList: | 99 for inputFile in inputFileList[1:]: # First file will be sent to outputFile. |
100 # outName = "%s_%s_%s_%s_%s" % ('primary', outputFileId, inputFile.replace(".","-"), 'visible', outputFileType) | 100 outName = "%s_%s_%s_%s_%s" % ('primary', outputFileId, inputFile.replace(".","-"), 'visible', fileType) |
101 # outputFileList.append(os.path.join(otherFilesDir, outName)) | 101 outputFileList.append(os.path.join(otherFilesDir, outName)) |
102 # else: | 102 else: |
103 inputFileList = [filename] | 103 inputFileList = [filename] |
104 for inFile, outFile in zip(inputFileList, outputFileList): | 104 for inFile, outFile in zip(inputFileList, outputFileList): |
105 downloadMe = ts_utils.ts_utils.recurseToChildNamed(location, inFile) | 105 downloadMe = ts_utils.ts_utils.recurseToChildNamed(location, inFile) |
106 if downloadMe: | 106 if downloadMe: |
107 download = ts.getFile(store, downloadMe) | 107 download = ts.getFile(store, downloadMe) |
108 ungzip(download, outFile) | 108 ungzip(download, outFile) |
116 printNice(child, f, 0) | 116 printNice(child, f, 0) |
117 except AttributeError as e: | 117 except AttributeError as e: |
118 print e | 118 print e |
119 print root | 119 print root |
120 if not found: | 120 if not found: |
121 print "Store not found" | 121 print "Store %s not found" % storename |
122 sys.exit(2) | 122 sys.exit(2) |