# HG changeset patch # User Catherine Wise # Date 1386825463 -39600 # Node ID 159d2159e745605b972cb3e97c69c5c00b792fc5 # Parent 32d9b3343955dfbdbf905c3d17ee0d627ed40610 Add list files. diff -r 32d9b3343955 -r 159d2159e745 TrustStoreGalaxyImport.py --- a/TrustStoreGalaxyImport.py Thu Dec 12 13:07:45 2013 +1100 +++ b/TrustStoreGalaxyImport.py Thu Dec 12 16:17:43 2013 +1100 @@ -2,6 +2,14 @@ import shutil from py_ts import TrustStoreClient, ts_utils +def printNice(elem, f, depth): + try: + f.write('\t'*depth + elem.name + " (" + str(len(elem.fragments)) + " parts)\n") + except AttributeError: + f.write('\t'*depth + elem.name + "\n") + for child in elem.children: + printNice(child, f, depth+1) + if __name__ == '__main__': kms_url = sys.argv[1] @@ -12,8 +20,13 @@ client_secret = sys.argv[6] storename = sys.argv[7] path = sys.argv[8] - filename = sys.argv[9] - outputFile = sys.argv[10] + filename = "" + outputFile = "" + if len(sys.argv) > 10: + filename = sys.argv[9] + outputFile = sys.argv[10] + else: + outputFile = sys.argv[9] config = TrustStoreClient.Config(ims_url, kms_url, client_key, client_secret) ts = TrustStoreClient.TrustStoreClient(headless=True, config=config) @@ -37,13 +50,22 @@ sys.exit(3) else: location = root - downloadMe = ts_utils.ts_utils.recurseToChildNamed(location, filename) - if downloadMe: - download = ts.getFile(store, downloadMe) - shutil.copy(download, outputFile) + if filename and filename != "": + downloadMe = ts_utils.ts_utils.recurseToChildNamed(location, filename) + if downloadMe: + download = ts.getFile(store, downloadMe) + shutil.copy(download, outputFile) + else: + print "File not found" + sys.exit(4) else: - print "File not found" - sys.exit(4) + with open(outputFile, 'w+') as f: + try: + for child in root.children: + printNice(child, f, 0) + except AttributeError as e: + print e + print root if not found: print "Store not found" sys.exit(2) diff -r 32d9b3343955 -r 159d2159e745 TrustStoreGalaxyImport.xml --- a/TrustStoreGalaxyImport.xml Thu Dec 12 13:07:45 2013 +1100 +++ b/TrustStoreGalaxyImport.xml Thu Dec 12 16:17:43 2013 +1100 @@ -9,6 +9,7 @@ TrustStoreGalaxyImport.py https://tstest-kms.it.csiro.au/kmscolab_3_0 https://tstest-ims.it.csiro.au/ims_3_0/services/IMS $username $password desktop cpU92F1PT7VOCANjSknuCDp4DrubmujoBaF6b0miz8OpKNokEbGMHCaSFK5/lISbBmaaGVCgeADI2A39F3Hkeg== $storename $path $filename $output + - + @@ -101,6 +102,7 @@ +