# HG changeset patch
# User greg
# Date 1581340025 18000
# Node ID d1bf63483e33658325089670594eddf22f27704d
# Parent 84a356e0950a6e23c1a5d767f987356911562f25
Uploaded
diff -r 84a356e0950a -r d1bf63483e33 data_manager/vsnp_excel_fetcher.py
--- a/data_manager/vsnp_excel_fetcher.py Fri Feb 07 13:02:25 2020 -0500
+++ b/data_manager/vsnp_excel_fetcher.py Mon Feb 10 08:07:05 2020 -0500
@@ -1,6 +1,7 @@
import argparse
import json
import os
+import sys
try:
# For Python 3.0 and later
from urllib.request import Request, urlopen
@@ -9,8 +10,8 @@
from urllib2 import Request, urlopen
-def url_download(url, target_directory):
- file_path = os.path.abspath(os.path.join(target_directory, os.path.basename(url)))
+def url_download(url, workdir):
+ file_path = os.path.abspath(os.path.join(workdir, os.path.basename(url)))
src = None
dst = None
try:
@@ -23,29 +24,30 @@
dst.write(chunk)
else:
break
+ except Exception as e:
+ sys.exit(str(e))
finally:
if src:
src.close()
return file_path
-def download(dbkey, display_name, url, out_file):
+def download(dbkey, name, url, out_file):
with open(out_file) as fh:
params = json.loads(fh.read())
- work_directory = params['output_data'][0]['extra_files_path']
- target_directory = os.path.abspath(os.path.join(work_directory, "vsnp", dbkey))
- os.mkdir(target_directory)
- file_path = url_download(url, target_directory)
- entry_name = "%s" % os.path.basename(file_path)
+ workdir = params['output_data'][0]['extra_files_path']
+ os.makedirs(workdir)
+ file_path = url_download(url, workdir)
+ entry_name = os.path.basename(file_path)
data_manager_json = {"data_tables": {}}
data_manager_entry = {}
data_manager_entry['value'] = dbkey
data_manager_entry['name'] = entry_name
data_manager_entry['path'] = file_path
- data_manager_entry['description'] = "Excel file for %s" % display_name
+ data_manager_entry['description'] = "Excel file for %s" % name
data_manager_json["data_tables"]["vsnp_excel"] = data_manager_entry
with open(out_file, 'w') as fh:
@@ -55,10 +57,10 @@
parser = argparse.ArgumentParser()
parser.add_argument('--dbkey', dest='dbkey', help='Genome reference dbkey')
-parser.add_argument('--display_name', dest='display_name', help='Reference display name')
+parser.add_argument('--name', dest='name', help='Reference display name')
parser.add_argument('--url', dest='url', help='URL to download Excel file')
parser.add_argument('--out_file', dest='out_file', help='JSON output file')
args = parser.parse_args()
-download(args.dbkey, args.display_name, args.url, args.out_file)
+download(args.dbkey, args.name, args.url, args.out_file)
diff -r 84a356e0950a -r d1bf63483e33 data_manager/vsnp_excel_fetcher.xml
--- a/data_manager/vsnp_excel_fetcher.xml Fri Feb 07 13:02:25 2020 -0500
+++ b/data_manager/vsnp_excel_fetcher.xml Mon Feb 10 08:07:05 2020 -0500
@@ -7,15 +7,16 @@
-
+
@@ -25,7 +26,7 @@
-
diff -r 84a356e0950a -r d1bf63483e33 data_manager_conf.xml
--- a/data_manager_conf.xml Fri Feb 07 13:02:25 2020 -0500
+++ b/data_manager_conf.xml Mon Feb 10 08:07:05 2020 -0500
@@ -8,12 +8,14 @@
- vsnp/${value}/excel
+ vsnp/${value}/excel/${name}
- ${GALAXY_DATA_MANAGER_DATA_PATH}/vsnp/${value}/excel
+ ${GALAXY_DATA_MANAGER_DATA_PATH}/vsnp/${value}/excel/${name}
abspath
+
+