# HG changeset patch # User tduigou # Date 1656941310 0 # Node ID e0b92d2038703f8722f189b3d60b945af7033fbc "planemo upload commit f40274f6b9f6a15eb4022aab21286d4c96cd8475-dirty" diff -r 000000000000 -r e0b92d203870 data_manager/cache_fetcher.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/data_manager/cache_fetcher.py Mon Jul 04 13:28:30 2022 +0000 @@ -0,0 +1,53 @@ +from os import ( + path as os_path, + mkdir as os_mkdir +) + +from requests import get as r_get + +from tempfile import ( + NamedTemporaryFile +) + +import argparse + +def download( + url: str, + file: str = "" +) -> str: + """ + Download a file from 'url' and save it as 'file'. + Parameters: + url -- URL the file is downloaded from + file -- (Optional) filename the downloaded file is saved into (default: "") + Returns: + A filename where the downloaded file has stored into + """ + r = r_get(url) + if not file: + f = NamedTemporaryFile( + mode='wb', + delete=False + ) + file = f.name + else: + f = open(file, 'wb') + f.write(r.content) + f.close() + return file + +parser = argparse.ArgumentParser(description="Download a cache file") +parser.add_argument('-u','--url', required=True, default=None, type=str, help="URL the file is downloaded from") +parser.add_argument('-o','--outfile', required=True, default=None, type=str, help="A filename where the downloaded file has stored into") + +args = parser.parse_args() + +url= args.url #"https://gitlab.com/breakthewall/rrCache-data/-/raw/master/" +filename= os_path.basename(args.outfile) #"cid_strc.json.gz" +cache_dir=os_path.dirname(args.outfile) #'${GALAXY_DATA_MANAGER_DATA_PATH}'+'/rpextractsink/cache/' +full_filename=os_path.join(cache_dir,filename) #'${GALAXY_DATA_MANAGER_DATA_PATH}'+'/rpextractsink/cache/cid_strc.json.gz' + +if not os_path.isdir(cache_dir): + os_mkdir(cache_dir) + +download(url+filename, full_filename) \ No newline at end of file diff -r 000000000000 -r e0b92d203870 data_manager/cache_fetcher.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/data_manager/cache_fetcher.xml Mon Jul 04 13:28:30 2022 +0000 @@ -0,0 +1,30 @@ + + + Download cache file + + python + + + + + + + + + + + + + + + + + + + diff -r 000000000000 -r e0b92d203870 data_manager_conf.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/data_manager_conf.xml Mon Jul 04 13:28:30 2022 +0000 @@ -0,0 +1,19 @@ + + + + + + + + + + ${path} + rpextractsink/cache/${name}.json.gz + + ${GALAXY_DATA_MANAGER_DATA_PATH}/rpextractsink/cache/${name}.json.gz + abspath + + + + + \ No newline at end of file diff -r 000000000000 -r e0b92d203870 tool-data/cache.loc.sample --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tool-data/cache.loc.sample Mon Jul 04 13:28:30 2022 +0000 @@ -0,0 +1,3 @@ +## Cache file +#Value Name Path +cid_strc cid_strc.json.gz rpextractsink/cache/cid_strc.json.gz diff -r 000000000000 -r e0b92d203870 tool_data_table_conf.xml.sample --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tool_data_table_conf.xml.sample Mon Jul 04 13:28:30 2022 +0000 @@ -0,0 +1,7 @@ + + + + value, name, path + +
+
\ No newline at end of file