Mercurial > repos > cathywise > truststore_import
changeset 5:159d2159e745
Add list files.
author | Catherine Wise <catherine.wise@csiro.au> |
---|---|
date | Thu, 12 Dec 2013 16:17:43 +1100 |
parents | 32d9b3343955 |
children | ef29a9320038 |
files | TrustStoreGalaxyImport.py TrustStoreGalaxyImport.xml |
diffstat | 2 files changed, 37 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- 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)
--- 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 @@ <command interpreter="python">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</command> <inputs> <param name="file_type" type="select" label="File Format" help="Which format is the data you're downloading?"> + <option value="just list files"/> <option value="ab1"/> <option value="axt"/> <option value="bam"/> @@ -42,7 +43,7 @@ </param> <!-- <param name="kms_url" type="text" label="kms url" help="the remote url for your key management service" value="http://localhost:8080/TSSKeyManagementService-Collaboration" size="200" /> <param name="ims_url" type="text" label="ims url" help="the remote url for your integrity management service" value="http://localhost:8080/TSSIntegrityManagementService/services/IMS" size="200" /> --> - <param name="username" type="text" label="username" help="kms username" value="user" size="20" > + <param name="username" type="text" label="Username" help="Your KMS username, e.g. jo.blogs@workplace.com" value="user" size="20" > <sanitizer> <valid initial="string.printable"> <remove value="'"/> @@ -52,7 +53,7 @@ </mapping> </sanitizer> </param> - <param name="password" type="text" label="password" help="kms password" value="password" size="1"> + <param name="password" type="text" label="Password" help="Your KMS password" value="password" size="1"> <sanitizer> <valid initial="string.printable"> <remove value="'"/> @@ -65,11 +66,11 @@ <!-- <param name="client_key" type="text" label="client key" help="kms client name" value="my-trusted-client-with-secret" size="20" /> --> <!-- <param name="client_secret" type="text" label="client secret" help="kms client secret" value="somesecret" size="20" /> --> <param name="storename" type="text" label="Store Name" help="e.g.: My Galaxy Store" value="galaxy" size="20" /> - <param name="path" type="text" label="Path in store" help="e.g.: /rawdata/feb2014/, leave as / for top level files" value="/" size="20" /> - <param name="filename" type="text" label="File name" help="e.g.: export1.bam" value="1.png" size="20" /> + <param name="path" type="text" label="Path in Store" help="e.g.: /rawdata/feb2014/, leave as / for top level files" value="/" size="20" /> + <param name="filename" type="text" label="Filename" help="e.g.: export1.bam. Leave empty if 'just list files' is chosen above." value="" size="20" /> </inputs> <outputs> - <data name="output" format="ab1"> + <data name="output" format="txt"> <change_format> <when input="file_type" value="ab1" format="ab1" /> <when input="file_type" value="axt" format="axt" /> @@ -101,6 +102,7 @@ <when input="file_type" value="txt" format="txt" /> <when input="file_type" value="wig" format="wig" /> <when input="file_type" value="xml" format="xml" /> + <when input="file_type" value="just list files" format="txt"/> </change_format> </data> </outputs>