Mercurial > repos > jay > gaiac_heatmap
comparison gaiac_pm_data_pulling/gaiac_pm_data_pulling.py @ 2:6f9ed7f12aad draft
planemo upload for repository https://github.com/jaidevjoshi83/gaiac commit c31ef5726cd1d2659da9aeb956c22fb834b177ff
| author | jay |
|---|---|
| date | Fri, 23 May 2025 17:55:10 +0000 |
| parents | e35898450a3c |
| children | ea3a11b428d9 |
comparison
equal
deleted
inserted
replaced
| 1:e35898450a3c | 2:6f9ed7f12aad |
|---|---|
| 13 import urllib.request | 13 import urllib.request |
| 14 import json | 14 import json |
| 15 | 15 |
| 16 def get_file_list(ip): | 16 def get_file_list(ip): |
| 17 | 17 |
| 18 url = "%s/list-files"%(ip) | 18 url = "%s/api/list-files"%(ip) |
| 19 | 19 |
| 20 with urllib.request.urlopen(url) as response: | 20 with urllib.request.urlopen(url) as response: |
| 21 data = response.read() | 21 data = response.read() |
| 22 file_list = json.loads(data) | 22 file_list = json.loads(data) |
| 23 | 23 |
| 31 api_data = {ip:{ | 31 api_data = {ip:{ |
| 32 | 32 |
| 33 }} | 33 }} |
| 34 | 34 |
| 35 for i in get_file_list(ip): | 35 for i in get_file_list(ip): |
| 36 # print("http://"+ip+'/download/'+i) | 36 api_data[ip][i] = ip+'/api/download/'+i |
| 37 api_data[ip][i] = ip+'/download/'+i | |
| 38 | |
| 39 | 37 |
| 40 ul = [] | 38 ul = [] |
| 41 for dataset, url in api_data[ip].items(): | 39 for dataset, url in api_data[ip].items(): |
| 42 | 40 |
| 43 ul.append({ | 41 ul.append({ |
| 45 'value': url, | 43 'value': url, |
| 46 'options': [], | 44 'options': [], |
| 47 'selected': False | 45 'selected': False |
| 48 }) | 46 }) |
| 49 | 47 |
| 50 # for urlname, genomes in api_data.items(): | |
| 51 # # URL-safe base64 encoding for the URL name | |
| 52 # urlname_64 = urlname | |
| 53 # ul = [] | |
| 54 # for genome, assets in genomes.items(): | |
| 55 # al = [] | |
| 56 | |
| 57 # ul.append({ | |
| 58 # 'name': genome, | |
| 59 # 'value': genome, | |
| 60 # 'options': [], | |
| 61 # 'selected': False | |
| 62 # }) | |
| 63 | |
| 64 return ul | 48 return ul |
| 65 except Exception as e: | 49 except Exception as e: |
| 66 # Handle any potential errors | 50 # Handle any potential errors |
| 67 return [{ | 51 return [{ |
| 68 'name': escape(str(e)), | 52 'name': escape(str(e)), |
| 71 'selected': False | 55 'selected': False |
| 72 }] | 56 }] |
| 73 | 57 |
| 74 if __name__ == '__main__': | 58 if __name__ == '__main__': |
| 75 | 59 |
| 76 simulate_dynamic_options('http://192.168.1.202:8080') | 60 simulate_dynamic_options('http://iotprojects.ddns.net') |
| 77 | |
| 78 # for i in simulate_dynamic_options('192.168.1.202:8080')[0]['options']: | |
| 79 # print(i) | |
| 80 # print(i) | |
| 81 # parser = argparse.ArgumentParser() | |
| 82 # parser.add_argument('-n', '--names', dest='names', action='store', default=None, help='Table names to reload') | |
| 83 # parser.add_argument('-u', '--url', dest='url', action='store', default=None, help='Base url for reload') | |
| 84 # parser.add_argument('-k', '--key', dest='key', action='store', default=None, help='Galaxy API Key') | |
| 85 # parser.add_argument('-g', '--graceful', dest='graceful', action='store_true', help='Fail gracefully') | |
| 86 | |
| 87 # args = parser.parse_args() | |
| 88 # try: | |
| 89 # if not args.names: | |
| 90 # tables = requests.get(urljoin(args.url, "api/tool_data"), params={'key': args.key}).json() | |
| 91 # args.names = [d.get('name') for d in tables] | |
| 92 # for name in args.names: | |
| 93 # print(requests.get(urljoin(args.url, "api/tool_data/%s/reload" % (name)), params={'key': args.key}).json()) | |
| 94 # except Exception as e: | |
| 95 # if args.graceful: | |
| 96 # print("Failed to reload data tables:\n%s" % (e)) | |
| 97 # else: | |
| 98 # raise e |
