Mercurial > repos > astroteam > astronomical_archives
annotate astronomical_archives.py @ 2:7398ea3d9ac4 draft default tip
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit b77ceb5085f378a8bef9b202b80e3ca7ef1e9a8e
author | astroteam |
---|---|
date | Tue, 26 Mar 2024 10:03:55 +0000 |
parents | 667fc28d803c |
children |
rev | line source |
---|---|
1
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
1 import errno |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
2 import functools |
0
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
3 import json |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
4 import os |
2
7398ea3d9ac4
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit b77ceb5085f378a8bef9b202b80e3ca7ef1e9a8e
astroteam
parents:
1
diff
changeset
|
5 import re |
1
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
6 import signal |
0
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
7 import sys |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
8 import urllib |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
9 from urllib import request |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
10 |
1
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
11 from astropy.coordinates import SkyCoord |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
12 |
0
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
13 import pyvo |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
14 from pyvo import DALAccessError, DALQueryError, DALServiceError |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
15 from pyvo import registry |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
16 |
1
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
17 |
0
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
18 MAX_ALLOWED_ENTRIES = 100 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
19 MAX_REGISTRIES_TO_SEARCH = 100 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
20 |
2
7398ea3d9ac4
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit b77ceb5085f378a8bef9b202b80e3ca7ef1e9a8e
astroteam
parents:
1
diff
changeset
|
21 ARCHIVES_TIMEOUT_BYPASS = [ |
7398ea3d9ac4
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit b77ceb5085f378a8bef9b202b80e3ca7ef1e9a8e
astroteam
parents:
1
diff
changeset
|
22 "https://datalab.noirlab.edu/tap" |
7398ea3d9ac4
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit b77ceb5085f378a8bef9b202b80e3ca7ef1e9a8e
astroteam
parents:
1
diff
changeset
|
23 ] |
7398ea3d9ac4
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit b77ceb5085f378a8bef9b202b80e3ca7ef1e9a8e
astroteam
parents:
1
diff
changeset
|
24 |
0
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
25 |
1
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
26 class TimeoutException(Exception): |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
27 pass |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
28 |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
29 |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
30 def timeout(seconds=10, error_message=os.strerror(errno.ETIME)): |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
31 def decorator(func): |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
32 def _handle_timeout(signum, frame): |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
33 raise TimeoutException(error_message) |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
34 |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
35 @functools.wraps(func) |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
36 def wrapper(*args, **kwargs): |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
37 signal.signal(signal.SIGALRM, _handle_timeout) |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
38 signal.alarm(seconds) |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
39 try: |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
40 result = func(*args, **kwargs) |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
41 finally: |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
42 signal.alarm(0) |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
43 return result |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
44 |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
45 return wrapper |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
46 |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
47 return decorator |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
48 |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
49 |
0
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
50 class Service: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
51 # https://pyvo.readthedocs.io/en/latest/api/pyvo.registry.Servicetype.html |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
52 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
53 services = { |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
54 'TAP': 'tap', |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
55 'SIA': 'sia', |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
56 'SIA2': 'sia2', |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
57 'SPECTRUM': 'spectrum', |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
58 'SCS': 'scs', |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
59 'LINE': 'line' |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
60 } |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
61 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
62 supported_services = { |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
63 'TAP': 'tap' |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
64 } |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
65 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
66 def __init__(self): |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
67 pass |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
68 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
69 @staticmethod |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
70 def is_service_supported(service_type) -> bool: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
71 is_supported = True |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
72 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
73 if service_type not in Service.services.keys(): |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
74 is_supported = False |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
75 elif service_type not in Service.supported_services.keys(): |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
76 is_supported = False |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
77 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
78 return is_supported |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
79 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
80 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
81 class Waveband: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
82 # https://pyvo.readthedocs.io/en/latest/api/pyvo.registry.Waveband.html |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
83 # https://www.ivoa.net/rdf/messenger/2020-08-26/messenger.html |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
84 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
85 wavebands = { |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
86 'Extreme UV': 'EUV', |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
87 'Gamma ray': 'Gamma-ray', |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
88 'Infrared': 'Infrared', |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
89 'Millimeter': 'Millimeter', |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
90 'Neutrino': 'Neutrino', |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
91 'Optical': 'Optical', |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
92 'Photon': 'Photon', |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
93 'Radio': 'Radio', |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
94 'Ultra violet': 'UV', |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
95 'X-ray': 'X-ray' |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
96 } |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
97 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
98 def __init__(self): |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
99 pass |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
100 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
101 @staticmethod |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
102 def is_waveband_supported(waveband) -> bool: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
103 is_supported = True |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
104 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
105 if waveband not in Waveband.wavebands.keys(): |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
106 is_supported = False |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
107 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
108 return is_supported |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
109 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
110 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
111 class TapArchive: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
112 # https://www.ivoa.net/documents/ObsCore/20170509/REC-ObsCore-v1.1-20170509 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
113 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
114 service_type = Service.services['TAP'] |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
115 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
116 def __init__(self, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
117 id=1, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
118 title="Unknown title", |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
119 name="Unknown name", |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
120 access_url=""): |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
121 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
122 self.id = id, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
123 self.title = title, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
124 self.name = name, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
125 self.access_url = access_url |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
126 self.initialized = False |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
127 self.archive_service = None |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
128 self.tables = None |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
129 |
1
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
130 @timeout(10) |
0
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
131 def get_resources(self, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
132 query, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
133 number_of_results, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
134 url_field='access_url'): |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
135 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
136 resource_list_hydrated = [] |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
137 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
138 error_message = None |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
139 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
140 if self.initialized: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
141 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
142 try: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
143 raw_resource_list = self.archive_service.search(query) |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
144 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
145 for i, resource in enumerate(raw_resource_list): |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
146 if i < number_of_results: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
147 resource_list_hydrated.append( |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
148 self._get_resource_object(resource)) |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
149 else: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
150 break |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
151 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
152 except DALQueryError: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
153 if self.has_obscore_table(): |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
154 error_message = "Error in query -> " + query |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
155 Logger.create_action_log( |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
156 Logger.ACTION_ERROR, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
157 Logger.ACTION_TYPE_DOWNLOAD, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
158 error_message) |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
159 else: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
160 error_message = "No obscore table in the archive" |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
161 Logger.create_action_log( |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
162 Logger.ACTION_ERROR, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
163 Logger.ACTION_TYPE_DOWNLOAD, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
164 error_message) |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
165 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
166 except DALServiceError: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
167 error_message = "Error communicating with the service" |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
168 Logger.create_action_log( |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
169 Logger.ACTION_ERROR, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
170 Logger.ACTION_TYPE_DOWNLOAD, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
171 error_message) |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
172 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
173 except Exception: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
174 error_message = "Unknow error while querying the service" |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
175 Logger.create_action_log( |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
176 Logger.ACTION_ERROR, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
177 Logger.ACTION_TYPE_DOWNLOAD, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
178 error_message) |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
179 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
180 return resource_list_hydrated, error_message |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
181 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
182 def _get_resource_object(self, resource): |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
183 resource_hydrated = {} |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
184 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
185 for key, value in resource.items(): |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
186 resource_hydrated[key] = value |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
187 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
188 return resource_hydrated |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
189 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
190 def initialize(self): |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
191 error_message = None |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
192 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
193 try: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
194 self._get_service() |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
195 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
196 if self.archive_service: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
197 self._set_archive_tables() |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
198 self.initialized = True |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
199 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
200 except DALAccessError: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
201 error_message = \ |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
202 "A connection to the service could not be established" |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
203 Logger.create_action_log( |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
204 Logger.ACTION_ERROR, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
205 Logger.ACTION_TYPE_ARCHIVE_CONNECTION, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
206 error_message) |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
207 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
208 except Exception: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
209 error_message = "Unknow error while initializing TAP service" |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
210 Logger.create_action_log( |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
211 Logger.ACTION_ERROR, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
212 Logger.ACTION_TYPE_ARCHIVE_CONNECTION, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
213 error_message) |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
214 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
215 return self.initialized, error_message |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
216 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
217 def _get_service(self): |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
218 if self.access_url: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
219 self.archive_service = pyvo.dal.TAPService(self.access_url) |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
220 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
221 def _set_archive_tables(self): |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
222 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
223 self.tables = [] |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
224 |
2
7398ea3d9ac4
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit b77ceb5085f378a8bef9b202b80e3ca7ef1e9a8e
astroteam
parents:
1
diff
changeset
|
225 try: |
7398ea3d9ac4
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit b77ceb5085f378a8bef9b202b80e3ca7ef1e9a8e
astroteam
parents:
1
diff
changeset
|
226 for table in self.archive_service.tables: |
7398ea3d9ac4
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit b77ceb5085f378a8bef9b202b80e3ca7ef1e9a8e
astroteam
parents:
1
diff
changeset
|
227 archive_table = { |
7398ea3d9ac4
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit b77ceb5085f378a8bef9b202b80e3ca7ef1e9a8e
astroteam
parents:
1
diff
changeset
|
228 'name': table.name, |
7398ea3d9ac4
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit b77ceb5085f378a8bef9b202b80e3ca7ef1e9a8e
astroteam
parents:
1
diff
changeset
|
229 'type': table.type, |
7398ea3d9ac4
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit b77ceb5085f378a8bef9b202b80e3ca7ef1e9a8e
astroteam
parents:
1
diff
changeset
|
230 'fields': None |
0
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
231 } |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
232 |
2
7398ea3d9ac4
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit b77ceb5085f378a8bef9b202b80e3ca7ef1e9a8e
astroteam
parents:
1
diff
changeset
|
233 fields = [] |
7398ea3d9ac4
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit b77ceb5085f378a8bef9b202b80e3ca7ef1e9a8e
astroteam
parents:
1
diff
changeset
|
234 |
7398ea3d9ac4
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit b77ceb5085f378a8bef9b202b80e3ca7ef1e9a8e
astroteam
parents:
1
diff
changeset
|
235 for table_field in table.columns: |
7398ea3d9ac4
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit b77ceb5085f378a8bef9b202b80e3ca7ef1e9a8e
astroteam
parents:
1
diff
changeset
|
236 field = { |
7398ea3d9ac4
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit b77ceb5085f378a8bef9b202b80e3ca7ef1e9a8e
astroteam
parents:
1
diff
changeset
|
237 'name': table_field.name, |
7398ea3d9ac4
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit b77ceb5085f378a8bef9b202b80e3ca7ef1e9a8e
astroteam
parents:
1
diff
changeset
|
238 'description': table_field.description, |
7398ea3d9ac4
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit b77ceb5085f378a8bef9b202b80e3ca7ef1e9a8e
astroteam
parents:
1
diff
changeset
|
239 'unit': table_field.unit, |
7398ea3d9ac4
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit b77ceb5085f378a8bef9b202b80e3ca7ef1e9a8e
astroteam
parents:
1
diff
changeset
|
240 'datatype': table_field.datatype.content |
7398ea3d9ac4
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit b77ceb5085f378a8bef9b202b80e3ca7ef1e9a8e
astroteam
parents:
1
diff
changeset
|
241 } |
0
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
242 |
2
7398ea3d9ac4
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit b77ceb5085f378a8bef9b202b80e3ca7ef1e9a8e
astroteam
parents:
1
diff
changeset
|
243 fields.append(field) |
7398ea3d9ac4
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit b77ceb5085f378a8bef9b202b80e3ca7ef1e9a8e
astroteam
parents:
1
diff
changeset
|
244 |
7398ea3d9ac4
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit b77ceb5085f378a8bef9b202b80e3ca7ef1e9a8e
astroteam
parents:
1
diff
changeset
|
245 archive_table['fields'] = fields |
0
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
246 |
2
7398ea3d9ac4
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit b77ceb5085f378a8bef9b202b80e3ca7ef1e9a8e
astroteam
parents:
1
diff
changeset
|
247 self.tables.append(archive_table) |
7398ea3d9ac4
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit b77ceb5085f378a8bef9b202b80e3ca7ef1e9a8e
astroteam
parents:
1
diff
changeset
|
248 |
7398ea3d9ac4
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit b77ceb5085f378a8bef9b202b80e3ca7ef1e9a8e
astroteam
parents:
1
diff
changeset
|
249 # Exception is raised when a table schema is missing |
7398ea3d9ac4
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit b77ceb5085f378a8bef9b202b80e3ca7ef1e9a8e
astroteam
parents:
1
diff
changeset
|
250 # Missing table will be omitted so no action needed |
7398ea3d9ac4
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit b77ceb5085f378a8bef9b202b80e3ca7ef1e9a8e
astroteam
parents:
1
diff
changeset
|
251 except DALServiceError: |
7398ea3d9ac4
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit b77ceb5085f378a8bef9b202b80e3ca7ef1e9a8e
astroteam
parents:
1
diff
changeset
|
252 pass |
0
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
253 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
254 def _is_query_valid(self, query) -> bool: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
255 is_valid = True |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
256 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
257 attribute_from = 'from' |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
258 attribute_where = 'where' |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
259 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
260 idx_from = query.index(attribute_from) |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
261 idx_where = query.index(attribute_where) |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
262 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
263 table_name = '' |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
264 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
265 for idx in range(idx_from + len('from') + 1, idx_where): |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
266 table_name = table_name + query[idx] |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
267 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
268 if not next( |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
269 (item for item in self.tables if |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
270 item["name"] == table_name), |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
271 False): |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
272 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
273 is_valid = False |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
274 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
275 return is_valid |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
276 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
277 def has_obscore_table(self) -> bool: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
278 has_obscore_table = self._has_table("ivoa.obscore") |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
279 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
280 return has_obscore_table |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
281 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
282 def _has_table(self, table_name) -> bool: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
283 _has_table = False |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
284 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
285 _has_table = next( |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
286 (item for item in self.tables if item["name"] == table_name), |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
287 False) |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
288 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
289 return _has_table |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
290 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
291 def get_archive_name(self, archive_type): |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
292 try: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
293 if archive_type == 'registry': |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
294 name = str(self.title).strip("',()") |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
295 else: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
296 name = self.access_url |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
297 except Exception: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
298 name = 'Unknown archive title' |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
299 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
300 return name |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
301 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
302 |
1
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
303 class ConeService(TapArchive): |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
304 |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
305 def _get_service(self): |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
306 if self.access_url: |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
307 self.archive_service = pyvo.dal.SCSService(self.access_url) |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
308 |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
309 def get_resources_from_service_list(self, service_list, target, radius): |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
310 |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
311 resource_list_hydrated = [] |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
312 |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
313 for service in service_list: |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
314 resources = service.search(target, radius) |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
315 for i in range(resources.__len__()): |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
316 resource_url = resources.getrecord(i).getdataurl() |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
317 if resource_url: |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
318 resource_list_hydrated.append(resource_url) |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
319 |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
320 return resource_list_hydrated |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
321 |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
322 |
0
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
323 class RegistrySearchParameters: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
324 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
325 def __init__(self, keyword=None, waveband=None, service_type=None): |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
326 self.keyword = keyword |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
327 self.waveband = waveband |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
328 self.service_type = service_type |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
329 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
330 def get_parameters(self): |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
331 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
332 parameters = { |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
333 'keywords': '', |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
334 'waveband': '', |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
335 'service_type': '' |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
336 } |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
337 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
338 if self.keyword: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
339 parameters['keywords'] = self.keyword |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
340 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
341 if Waveband.is_waveband_supported(self.waveband): |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
342 parameters['waveband'] = \ |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
343 Waveband.wavebands[self.waveband] |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
344 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
345 if Service.is_service_supported(self.service_type): |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
346 parameters['service_type'] = \ |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
347 Service.services[self.service_type] |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
348 else: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
349 parameters['service_type'] = Service.services['TAP'] |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
350 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
351 return parameters |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
352 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
353 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
354 class Registry: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
355 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
356 def __init__(self): |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
357 pass |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
358 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
359 @staticmethod |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
360 def search_registries(rsp: RegistrySearchParameters, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
361 number_of_registries): |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
362 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
363 parameters = rsp.get_parameters() |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
364 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
365 keywords = parameters['keywords'] |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
366 waveband = parameters['waveband'] |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
367 service_type = parameters['service_type'] |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
368 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
369 if not waveband: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
370 registry_list = registry.search( |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
371 keywords=keywords, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
372 servicetype=service_type) |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
373 else: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
374 registry_list = registry.search( |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
375 keywords=keywords, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
376 waveband=waveband, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
377 servicetype=service_type) |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
378 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
379 if registry_list: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
380 registry_list = Registry._get_registries_from_list( |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
381 registry_list, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
382 number_of_registries) |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
383 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
384 return registry_list |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
385 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
386 @staticmethod |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
387 def _get_registries_from_list(registry_list, number_of_registries): |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
388 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
389 archive_list = [] |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
390 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
391 for i, ivoa_registry in enumerate(registry_list): |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
392 if i < number_of_registries: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
393 archive = TapArchive(ivoa_registry.standard_id, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
394 ivoa_registry.res_title, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
395 ivoa_registry.short_name, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
396 ivoa_registry.access_url) |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
397 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
398 archive_list.append(archive) |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
399 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
400 return archive_list |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
401 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
402 |
1
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
403 class ConeServiceRegistry: |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
404 |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
405 def __init__(self): |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
406 pass |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
407 |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
408 @staticmethod |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
409 def search_services(keyword, number_of_registries): |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
410 |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
411 service_list = [] |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
412 |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
413 service_list = registry.search(servicetype="scs", keywords=keyword) |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
414 |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
415 if service_list: |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
416 service_list = service_list[:number_of_registries] |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
417 |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
418 return service_list |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
419 |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
420 |
0
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
421 class TapQuery: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
422 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
423 def __init__(self, query): |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
424 self.raw_query = query |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
425 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
426 def get_query(self): |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
427 return urllib.parse.unquote(self.raw_query).replace("+", " ") |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
428 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
429 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
430 class BaseADQLQuery: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
431 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
432 def __init__(self): |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
433 pass |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
434 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
435 def _get_order_by_clause(self, order_type): |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
436 order_by_clause = 'ORDER BY ' + order_type |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
437 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
438 return order_by_clause |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
439 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
440 def _get_where_clause(self, parameters): |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
441 where_clause = '' |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
442 is_first_statement = True |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
443 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
444 for key, value in parameters.items(): |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
445 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
446 if value != '': |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
447 statement = str(key) + ' = ' + '\'' + str(value) + '\' ' |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
448 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
449 if is_first_statement: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
450 is_first_statement = False |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
451 where_clause += 'WHERE ' |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
452 else: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
453 statement = 'AND ' + statement |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
454 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
455 where_clause += statement |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
456 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
457 return where_clause |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
458 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
459 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
460 class ToolRunner: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
461 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
462 def __init__(self, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
463 run_parameters, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
464 output, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
465 output_csv, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
466 output_html, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
467 output_basic_html, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
468 output_error): |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
469 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
470 self._raw_parameters_path = run_parameters |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
471 self._json_parameters = json.load(open(run_parameters, "r")) |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
472 self._archive_type = '' |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
473 self._query_type = '' |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
474 self._archives = [] |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
475 self._adql_query = '' |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
476 self._services_access_url = '' |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
477 self._url_field = 'access_url' |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
478 self._number_of_files = '' |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
479 self._is_initialised = False |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
480 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
481 self._csv_file = False |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
482 self._image_file = False |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
483 self._html_file = False |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
484 self._basic_html_file = False |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
485 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
486 self._output = output |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
487 self._output_csv = output_csv |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
488 self._output_html = output_html |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
489 self._output_basic_html = output_basic_html |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
490 self._output_error = output_error |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
491 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
492 self._set_run_main_parameters() |
1
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
493 |
0
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
494 self._is_initialised, error_message = self._set_archive() |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
495 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
496 if self._is_initialised and error_message is None: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
497 self._set_query() |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
498 self._set_output() |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
499 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
500 def _set_run_main_parameters(self): |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
501 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
502 qs = "query_section" |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
503 qsl = "query_selection" |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
504 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
505 self._archive_type = \ |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
506 self._json_parameters['archive_selection']['archive_type'] |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
507 self._query_type = \ |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
508 self._json_parameters[qs][qsl]['query_type'] |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
509 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
510 def _set_archive(self): |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
511 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
512 error_message = None |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
513 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
514 if self._archive_type == 'archive': |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
515 self._service_access_url =\ |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
516 self._json_parameters['archive_selection']['archive'] |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
517 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
518 self._archives.append( |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
519 TapArchive(access_url=self._service_access_url)) |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
520 |
2
7398ea3d9ac4
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit b77ceb5085f378a8bef9b202b80e3ca7ef1e9a8e
astroteam
parents:
1
diff
changeset
|
521 elif self._archive_type == 'custom': |
7398ea3d9ac4
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit b77ceb5085f378a8bef9b202b80e3ca7ef1e9a8e
astroteam
parents:
1
diff
changeset
|
522 self._service_access_url = \ |
7398ea3d9ac4
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit b77ceb5085f378a8bef9b202b80e3ca7ef1e9a8e
astroteam
parents:
1
diff
changeset
|
523 self._json_parameters['archive_selection']['access_url'] |
7398ea3d9ac4
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit b77ceb5085f378a8bef9b202b80e3ca7ef1e9a8e
astroteam
parents:
1
diff
changeset
|
524 |
7398ea3d9ac4
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit b77ceb5085f378a8bef9b202b80e3ca7ef1e9a8e
astroteam
parents:
1
diff
changeset
|
525 if Utils.is_valid_url(self._service_access_url): |
7398ea3d9ac4
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit b77ceb5085f378a8bef9b202b80e3ca7ef1e9a8e
astroteam
parents:
1
diff
changeset
|
526 self._archives.append( |
7398ea3d9ac4
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit b77ceb5085f378a8bef9b202b80e3ca7ef1e9a8e
astroteam
parents:
1
diff
changeset
|
527 TapArchive(access_url=self._service_access_url)) |
7398ea3d9ac4
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit b77ceb5085f378a8bef9b202b80e3ca7ef1e9a8e
astroteam
parents:
1
diff
changeset
|
528 else: |
7398ea3d9ac4
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit b77ceb5085f378a8bef9b202b80e3ca7ef1e9a8e
astroteam
parents:
1
diff
changeset
|
529 error_message = "archive access url is not a valid url" |
7398ea3d9ac4
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit b77ceb5085f378a8bef9b202b80e3ca7ef1e9a8e
astroteam
parents:
1
diff
changeset
|
530 Logger.create_action_log( |
7398ea3d9ac4
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit b77ceb5085f378a8bef9b202b80e3ca7ef1e9a8e
astroteam
parents:
1
diff
changeset
|
531 Logger.ACTION_ERROR, |
7398ea3d9ac4
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit b77ceb5085f378a8bef9b202b80e3ca7ef1e9a8e
astroteam
parents:
1
diff
changeset
|
532 Logger.ACTION_TYPE_ARCHIVE_CONNECTION, |
7398ea3d9ac4
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit b77ceb5085f378a8bef9b202b80e3ca7ef1e9a8e
astroteam
parents:
1
diff
changeset
|
533 error_message) |
7398ea3d9ac4
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit b77ceb5085f378a8bef9b202b80e3ca7ef1e9a8e
astroteam
parents:
1
diff
changeset
|
534 |
0
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
535 else: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
536 keyword = \ |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
537 self._json_parameters['archive_selection']['keyword'] |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
538 waveband = \ |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
539 self._json_parameters['archive_selection']['wavebands'] |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
540 service_type = \ |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
541 self._json_parameters['archive_selection']['service_type'] |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
542 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
543 rsp = RegistrySearchParameters( |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
544 keyword=keyword, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
545 waveband=waveband, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
546 service_type=service_type) |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
547 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
548 archive_list = Registry.search_registries( |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
549 rsp, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
550 MAX_REGISTRIES_TO_SEARCH) |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
551 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
552 if len(archive_list) >= 1: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
553 self._archives = archive_list |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
554 else: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
555 error_message = "no archive matching search parameters" |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
556 Logger.create_action_log( |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
557 Logger.ACTION_ERROR, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
558 Logger.ACTION_TYPE_ARCHIVE_CONNECTION, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
559 error_message) |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
560 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
561 if error_message is None: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
562 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
563 self._archives[:] = \ |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
564 [archive for archive in self._archives if |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
565 archive.initialize()[0]] |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
566 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
567 if len(self._archives) >= 1: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
568 return True, None |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
569 else: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
570 return False, \ |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
571 "no archive matching search" \ |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
572 " parameters could be initialized" |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
573 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
574 else: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
575 return False, error_message |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
576 |
1
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
577 def _set_cone_service(self): |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
578 |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
579 qs = 'query_section' |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
580 qsl = 'query_selection' |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
581 csts = 'cone_search_target_selection' |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
582 |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
583 error_message = None |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
584 is_service_initialised = True |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
585 |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
586 keyword = self._json_parameters[qs][qsl][csts]['keyword'] |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
587 |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
588 service_list = ConeServiceRegistry.search_services( |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
589 keyword, |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
590 MAX_REGISTRIES_TO_SEARCH) |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
591 |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
592 if len(service_list) >= 1: |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
593 self._services = service_list |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
594 else: |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
595 is_service_initialised = False |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
596 error_message = "no services matching search parameters" |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
597 Logger.create_action_log( |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
598 Logger.ACTION_ERROR, |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
599 Logger.ACTION_TYPE_ARCHIVE_CONNECTION, |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
600 error_message) |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
601 |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
602 return is_service_initialised, error_message |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
603 |
0
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
604 def _set_query(self): |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
605 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
606 qs = 'query_section' |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
607 qsl = 'query_selection' |
1
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
608 csts = 'cone_search_target_selection' |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
609 cs = 'cone_section' |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
610 ts = 'target_selection' |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
611 con = 'cone_object_name' |
0
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
612 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
613 if self._query_type == 'obscore_query': |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
614 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
615 dataproduct_type = \ |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
616 self._json_parameters[qs][qsl]['dataproduct_type'] |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
617 obs_collection = \ |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
618 self._json_parameters[qs][qsl]['obs_collection'] |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
619 obs_title = \ |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
620 self._json_parameters[qs][qsl]['obs_title'] |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
621 obs_id = \ |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
622 self._json_parameters[qs][qsl]['obs_id'] |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
623 facility_name = \ |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
624 self._json_parameters[qs][qsl]['facility_name'] |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
625 instrument_name = \ |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
626 self._json_parameters[qs][qsl]['instrument_name'] |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
627 em_min = \ |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
628 self._json_parameters[qs][qsl]['em_min'] |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
629 em_max = \ |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
630 self._json_parameters[qs][qsl]['em_max'] |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
631 target_name = \ |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
632 self._json_parameters[qs][qsl]['target_name'] |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
633 obs_publisher_id = \ |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
634 self._json_parameters[qs][qsl]['obs_publisher_id'] |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
635 s_fov = \ |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
636 self._json_parameters[qs][qsl]['s_fov'] |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
637 calibration_level = \ |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
638 self._json_parameters[qs][qsl]['calibration_level'] |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
639 t_min = \ |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
640 self._json_parameters[qs][qsl]['t_min'] |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
641 t_max = \ |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
642 self._json_parameters[qs][qsl]['t_max'] |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
643 order_by = \ |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
644 self._json_parameters[qs][qsl]['order_by'] |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
645 |
1
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
646 if self._json_parameters[qs][qsl][cs][csts][ts] == 'coordinates': |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
647 ra = self._json_parameters[qs][qsl][cs][csts]['ra'] |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
648 dec = self._json_parameters[qs][qsl][cs][csts]['dec'] |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
649 else: |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
650 obs_target = self._json_parameters[qs][qsl][cs][csts][con] |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
651 |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
652 if obs_target != 'none' and obs_target is not None: |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
653 target = CelestialObject(obs_target) |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
654 target_coordinates = target.get_coordinates_in_degrees() |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
655 |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
656 ra = target_coordinates['ra'] |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
657 dec = target_coordinates['dec'] |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
658 else: |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
659 ra = None |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
660 dec = None |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
661 |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
662 radius = self._json_parameters[qs][qsl][cs]['radius'] |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
663 |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
664 if (ra != '' and ra is not None)\ |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
665 and (dec != '' and dec is not None)\ |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
666 and (radius != '' and radius is not None): |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
667 cone_condition = \ |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
668 ADQLConeSearchQuery.get_search_circle_condition(ra, |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
669 dec, |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
670 radius) |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
671 else: |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
672 cone_condition = None |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
673 |
0
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
674 obscore_query_object = ADQLObscoreQuery(dataproduct_type, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
675 obs_collection, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
676 obs_title, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
677 obs_id, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
678 facility_name, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
679 instrument_name, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
680 em_min, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
681 em_max, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
682 target_name, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
683 obs_publisher_id, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
684 s_fov, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
685 calibration_level, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
686 t_min, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
687 t_max, |
1
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
688 cone_condition, |
0
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
689 order_by) |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
690 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
691 self._adql_query = obscore_query_object.get_query() |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
692 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
693 elif self._query_type == 'raw_query': |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
694 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
695 wc = 'where_clause' |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
696 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
697 tap_table = \ |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
698 self._json_parameters[qs][qsl]['table'] |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
699 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
700 where_field = \ |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
701 self._json_parameters[qs][qsl][wc]['where_field'] |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
702 where_condition = \ |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
703 self._json_parameters[qs][qsl][wc]['where_condition'] |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
704 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
705 self._url_field = \ |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
706 self._json_parameters[qs][qsl]['url_field'] |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
707 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
708 self._adql_query = \ |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
709 ADQLTapQuery().get_query( |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
710 tap_table, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
711 where_field, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
712 where_condition) |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
713 else: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
714 self._adql_query = ADQLObscoreQuery.base_query |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
715 |
1
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
716 def _set_cone_query(self): |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
717 |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
718 qs = 'query_section' |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
719 qsl = 'query_selection' |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
720 csts = 'cone_search_target_selection' |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
721 ts = 'target_selection' |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
722 con = 'cone_object_name' |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
723 |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
724 search_radius = self._json_parameters[qs][qsl]['radius'] |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
725 time = None |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
726 |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
727 if self._json_parameters[qs][qsl][csts][ts] == 'coordinates': |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
728 ra = self._json_parameters[qs][qsl][csts]['ra'] |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
729 dec = self._json_parameters[qs][qsl][csts]['dec'] |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
730 time = self._json_parameters[qs][qsl][csts]['time'] |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
731 else: |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
732 target = CelestialObject(self._json_parameters[qs][qsl][csts][con]) |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
733 |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
734 target_coordinates = target.get_coordinates_in_degrees() |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
735 |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
736 ra = target_coordinates['ra'] |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
737 dec = target_coordinates['dec'] |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
738 |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
739 cone_query_object = ADQLConeSearchQuery(ra, dec, search_radius, time) |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
740 |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
741 self._adql_query = cone_query_object.get_query() |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
742 |
0
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
743 def _set_output(self): |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
744 self._number_of_files = \ |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
745 int( |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
746 self._json_parameters['output_section']['number_of_files'] |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
747 ) |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
748 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
749 if self._number_of_files < 1: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
750 self._number_of_files = 1 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
751 elif self._number_of_files > 100: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
752 self._number_of_files = MAX_ALLOWED_ENTRIES |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
753 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
754 output_selection = \ |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
755 self._json_parameters['output_section']['output_selection'] |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
756 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
757 if output_selection is not None: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
758 if 'c' in output_selection: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
759 self._csv_file = True |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
760 if 'i' in output_selection: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
761 self._image_file = True |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
762 if 'h' in output_selection: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
763 self._html_file = True |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
764 if 'b' in output_selection: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
765 self._basic_html_file = True |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
766 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
767 def _validate_json_parameters(self, json_parameters): |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
768 self._json_parameters = json.load(open(json_parameters, "r")) |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
769 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
770 def run(self): |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
771 if self._is_initialised: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
772 error_message = None |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
773 file_url = [] |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
774 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
775 archive_name = self._archives[0].get_archive_name( |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
776 self._archive_type) |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
777 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
778 for archive in self._archives: |
1
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
779 try: |
2
7398ea3d9ac4
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit b77ceb5085f378a8bef9b202b80e3ca7ef1e9a8e
astroteam
parents:
1
diff
changeset
|
780 |
7398ea3d9ac4
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit b77ceb5085f378a8bef9b202b80e3ca7ef1e9a8e
astroteam
parents:
1
diff
changeset
|
781 if archive.access_url in ARCHIVES_TIMEOUT_BYPASS: |
7398ea3d9ac4
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit b77ceb5085f378a8bef9b202b80e3ca7ef1e9a8e
astroteam
parents:
1
diff
changeset
|
782 archive.get_resources = \ |
7398ea3d9ac4
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit b77ceb5085f378a8bef9b202b80e3ca7ef1e9a8e
astroteam
parents:
1
diff
changeset
|
783 timeout(40)(TapArchive.get_resources.__get__(archive)) # noqa: E501 |
7398ea3d9ac4
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit b77ceb5085f378a8bef9b202b80e3ca7ef1e9a8e
astroteam
parents:
1
diff
changeset
|
784 |
1
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
785 _file_url, error_message = archive.get_resources( |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
786 self._adql_query, |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
787 self._number_of_files, |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
788 self._url_field) |
0
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
789 |
1
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
790 file_url.extend(_file_url) |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
791 except TimeoutException: |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
792 error_message = \ |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
793 "Archive is taking too long to respond (timeout)" |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
794 Logger.create_action_log( |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
795 Logger.ACTION_ERROR, |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
796 Logger.ACTION_TYPE_ARCHIVE_CONNECTION, |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
797 error_message) |
0
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
798 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
799 if len(file_url) >= int(self._number_of_files): |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
800 file_url = file_url[:int(self._number_of_files)] |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
801 break |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
802 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
803 if file_url: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
804 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
805 if self._csv_file: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
806 FileHandler.write_urls_to_output( |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
807 file_url, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
808 self._output_csv, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
809 self._url_field) |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
810 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
811 if self._image_file: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
812 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
813 try: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
814 fits_file = FileHandler.download_file_from_url( |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
815 file_url[0][self._url_field]) |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
816 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
817 FileHandler.write_file_to_output( |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
818 fits_file, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
819 self._output, "wb") |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
820 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
821 log_message = "from url " +\ |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
822 file_url[0][self._url_field] |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
823 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
824 Logger.create_action_log( |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
825 Logger.ACTION_SUCCESS, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
826 Logger.ACTION_TYPE_DOWNLOAD, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
827 log_message) |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
828 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
829 except Exception: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
830 error_message = "from url " + \ |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
831 file_url[0][self._url_field] |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
832 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
833 Logger.create_action_log( |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
834 Logger.ACTION_ERROR, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
835 Logger.ACTION_TYPE_DOWNLOAD, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
836 error_message) |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
837 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
838 for i, url in enumerate(file_url[1:], start=1): |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
839 try: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
840 fits_file = \ |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
841 FileHandler.download_file_from_url( |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
842 url[self._url_field]) |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
843 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
844 FileHandler.write_file_to_subdir( |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
845 fits_file, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
846 FileHandler.get_file_name_from_url( |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
847 url[self._url_field])) |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
848 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
849 log_message = "from url " + \ |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
850 url[self._url_field] |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
851 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
852 Logger.create_action_log( |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
853 Logger.ACTION_SUCCESS, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
854 Logger.ACTION_TYPE_DOWNLOAD, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
855 log_message) |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
856 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
857 except Exception: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
858 error_message = "from url " + \ |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
859 url[self._url_field] |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
860 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
861 Logger.create_action_log( |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
862 Logger.ACTION_ERROR, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
863 Logger.ACTION_TYPE_DOWNLOAD, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
864 error_message) |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
865 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
866 if self._html_file: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
867 html_file = OutputHandler.generate_html_output( |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
868 file_url, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
869 archive_name, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
870 self._adql_query) |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
871 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
872 FileHandler.write_file_to_output(html_file, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
873 self._output_html) |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
874 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
875 if self._basic_html_file: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
876 html_file = \ |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
877 OutputHandler.generate_basic_html_output( |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
878 file_url, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
879 archive_name, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
880 self._adql_query) |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
881 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
882 FileHandler.write_file_to_output( |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
883 html_file, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
884 self._output_basic_html) |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
885 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
886 summary_file = Logger.create_log_file(archive_name, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
887 self._adql_query) |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
888 summary_file += "\n Tool run executed with success" |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
889 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
890 FileHandler.write_file_to_output(summary_file, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
891 self._output_error) |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
892 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
893 else: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
894 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
895 summary_file = Logger.create_log_file(archive_name, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
896 self._adql_query) |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
897 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
898 if error_message is None: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
899 summary_file += \ |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
900 "\n No resources matching parameters found" |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
901 else: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
902 summary_file += error_message |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
903 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
904 FileHandler.write_file_to_output(summary_file, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
905 self._output_error) |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
906 else: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
907 summary_file = Logger.create_log_file("Archive", |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
908 self._adql_query) |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
909 |
1
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
910 summary_file += "Unable to initialize archives" |
0
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
911 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
912 FileHandler.write_file_to_output(summary_file, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
913 self._output_error) |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
914 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
915 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
916 class ADQLObscoreQuery(BaseADQLQuery): |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
917 order_by_field = { |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
918 'size': 'access_estsize', |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
919 'collection': 'obs_collection', |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
920 'object': 'target_name' |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
921 } |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
922 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
923 base_query = 'SELECT TOP ' + \ |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
924 str(MAX_ALLOWED_ENTRIES) + \ |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
925 ' * FROM ivoa.obscore ' |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
926 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
927 def __init__(self, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
928 dataproduct_type, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
929 obs_collection, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
930 obs_title, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
931 obs_id, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
932 facility_name, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
933 instrument_name, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
934 em_min, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
935 em_max, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
936 target_name, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
937 obs_publisher_id, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
938 s_fov, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
939 calibration_level, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
940 t_min, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
941 t_max, |
1
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
942 cone_condition, |
0
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
943 order_by): |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
944 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
945 super().__init__() |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
946 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
947 if calibration_level == 'none': |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
948 calibration_level = '' |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
949 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
950 if order_by == 'none': |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
951 order_by = '' |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
952 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
953 if t_min == 'None' or t_min is None: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
954 t_min = '' |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
955 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
956 if t_max == 'None' or t_max is None: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
957 t_max = '' |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
958 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
959 if em_min == 'None' or em_min is None: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
960 em_min = '' |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
961 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
962 if em_max == 'None' or em_max is None: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
963 em_max = '' |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
964 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
965 if dataproduct_type == 'none' or dataproduct_type is None: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
966 dataproduct_type = '' |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
967 |
1
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
968 if cone_condition is not None: |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
969 self.cone_condition = cone_condition |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
970 else: |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
971 self.cone_condition = None |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
972 |
0
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
973 self.parameters = { |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
974 'dataproduct_type': dataproduct_type, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
975 'obs_collection': obs_collection, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
976 'obs_title': obs_title, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
977 'obs_id': obs_id, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
978 'facility_name': facility_name, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
979 'instrument_name': instrument_name, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
980 'em_min': em_min, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
981 'em_max': em_max, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
982 'target_name': target_name, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
983 'obs_publisher_id': obs_publisher_id, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
984 's_fov': s_fov, |
1
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
985 'calib_level': calibration_level, |
0
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
986 't_min': t_min, |
1
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
987 't_max': t_max, |
0
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
988 } |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
989 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
990 self.order_by = order_by |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
991 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
992 def get_query(self): |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
993 return ADQLObscoreQuery.base_query + \ |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
994 self.get_where_statement() + \ |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
995 self.get_order_by_statement() |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
996 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
997 def get_order_by_statement(self): |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
998 if self.order_by != '': |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
999 return self._get_order_by_clause(self.order_by) |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1000 else: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1001 return '' |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1002 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1003 def _get_order_by_clause(self, order_type): |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1004 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1005 obscore_order_type = ADQLObscoreQuery.order_by_field[order_type] |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1006 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1007 return super()._get_order_by_clause(obscore_order_type) |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1008 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1009 def get_where_statement(self): |
1
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
1010 where_clause = self._get_where_clause(self.parameters) |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
1011 |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
1012 if where_clause == '' and self.cone_condition is not None: |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
1013 where_clause = 'WHERE ' + self.get_cone_condition() |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
1014 elif where_clause != '' and self.cone_condition is not None: |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
1015 where_clause += 'AND ' + self.get_cone_condition() |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
1016 |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
1017 return where_clause |
0
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1018 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1019 def _get_where_clause(self, parameters): |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1020 return super()._get_where_clause(parameters) |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1021 |
1
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
1022 def get_cone_condition(self): |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
1023 return self.cone_condition |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
1024 |
0
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1025 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1026 class ADQLTapQuery(BaseADQLQuery): |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1027 base_query = 'SELECT TOP '+str(MAX_ALLOWED_ENTRIES)+' * FROM ' |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1028 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1029 def __init__(self): |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1030 super().__init__() |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1031 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1032 def get_order_by_clause(self, order_type): |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1033 return super()._get_order_by_clause(order_type) |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1034 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1035 def get_query(self, table, where_field, where_condition): |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1036 if where_field != '' and where_condition != '': |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1037 return ADQLTapQuery.base_query + \ |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1038 str(table) + \ |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1039 ' WHERE ' + \ |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1040 str(where_field) + ' = ' + '\'' + \ |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1041 str(where_condition) + '\'' |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1042 else: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1043 return ADQLTapQuery.base_query + str(table) |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1044 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1045 |
1
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
1046 class ADQLConeSearchQuery: |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
1047 |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
1048 base_query = "SELECT TOP 100 * FROM ivoa.obscore" |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
1049 |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
1050 def __init__(self, ra, dec, radius, time=None): |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
1051 |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
1052 self.ra = ra |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
1053 self.dec = dec |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
1054 self.radius = radius |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
1055 self.time = time |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
1056 |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
1057 self._query = ADQLObscoreQuery.base_query |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
1058 |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
1059 if self.ra and self.dec and self.radius: |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
1060 self._query += " WHERE " |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
1061 self._query += self._get_search_circle(ra, dec, radius) |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
1062 |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
1063 if self.time: |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
1064 self._query += self._get_search_time() |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
1065 |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
1066 def _get_search_circle(self, ra, dec, radius): |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
1067 return "(CONTAINS" \ |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
1068 "(POINT('ICRS', s_ra, s_dec), " \ |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
1069 "CIRCLE('ICRS', "+str(ra)+", "+str(dec)+", "+str(radius)+")" \ |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
1070 ") = 1)" |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
1071 |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
1072 def _get_search_time(self): |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
1073 return " AND t_min <= "+self.time+" AND t_max >= "+self.time |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
1074 |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
1075 def get_query(self): |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
1076 return self._query |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
1077 |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
1078 @staticmethod |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
1079 def get_search_circle_condition(ra, dec, radius): |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
1080 return "(CONTAINS" \ |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
1081 "(POINT('ICRS', s_ra, s_dec)," \ |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
1082 "CIRCLE('ICRS', "+str(ra)+", "+str(dec)+", "+str(radius)+")" \ |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
1083 ") = 1) " |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
1084 |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
1085 |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
1086 class CelestialObject: |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
1087 |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
1088 def __init__(self, name): |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
1089 self.name = name |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
1090 self.coordinates = None |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
1091 |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
1092 self.coordinates = SkyCoord.from_name(self.name) |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
1093 |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
1094 def get_coordinates_in_degrees(self): |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
1095 |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
1096 coordinates = { |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
1097 'ra': '', |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
1098 'dec': '' |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
1099 } |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
1100 |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
1101 ra_dec = self.coordinates.ravel() |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
1102 |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
1103 coordinates['ra'] = ra_dec.ra.degree[0] |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
1104 coordinates['dec'] = ra_dec.dec.degree[0] |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
1105 |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
1106 return coordinates |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
1107 |
667fc28d803c
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit f9ba105adfaad1b2a16dd570652aa27c508d3c4d
astroteam
parents:
0
diff
changeset
|
1108 |
0
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1109 class HTMLReport: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1110 _html_report_base_header = '' |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1111 _html_report_base_body = '' |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1112 _html_report_base_footer = '' |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1113 _html_report_base_script = '' |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1114 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1115 def __init__(self): |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1116 pass |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1117 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1118 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1119 class OutputHandler: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1120 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1121 def __init__(self): |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1122 pass |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1123 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1124 @staticmethod |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1125 def generate_html_output(urls_data, archive_name, adql_query): |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1126 return OutputHandler.html_header + \ |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1127 OutputHandler.generate_html_content( |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1128 urls_data, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1129 archive_name, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1130 adql_query, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1131 div_attr='class="title"', |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1132 table_attr='class="fl-table"') |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1133 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1134 @staticmethod |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1135 def generate_basic_html_output(urls_data, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1136 archive_name, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1137 adql_query, ): |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1138 return OutputHandler.generate_html_content(urls_data, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1139 archive_name, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1140 adql_query) |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1141 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1142 @staticmethod |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1143 def generate_html_content(urls_data, archive_name, adql_query, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1144 div_attr="", table_attr="border='1'"): |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1145 html_file = \ |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1146 f""" |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1147 <div {div_attr}> |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1148 <h2>Resources Preview archive: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1149 <span> |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1150 {archive_name} |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1151 </span> |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1152 </h2> |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1153 <span>ADQL query : {adql_query}</span> |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1154 </div>""" |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1155 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1156 html_file += f'<table {table_attr}><thead><tr>' |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1157 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1158 for key in Utils.collect_resource_keys(urls_data): |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1159 html_file += '<th>' + str(key) + '</th>' |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1160 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1161 html_file += '</thead></tr><tbody>' |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1162 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1163 for resource in urls_data: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1164 html_file += '<tr>' |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1165 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1166 for key, value in resource.items(): |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1167 html_file += f'<td>{value}</td>' |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1168 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1169 html_file += '<td>' |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1170 for preview_key in \ |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1171 ['preview', 'preview_url', 'postcard_url']: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1172 if preview_key in resource: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1173 html_file += ( |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1174 '<details><summary>Preview</summary>' |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1175 f'<img src="{resource[preview_key]}"/>' |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1176 '</details>' |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1177 ) |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1178 html_file += '</td>' |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1179 html_file += '</tr>' |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1180 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1181 html_file += '</tbody></table>' |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1182 return html_file |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1183 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1184 html_header = """ <head><style> |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1185 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1186 details { |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1187 padding: 10px; |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1188 } |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1189 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1190 .table-wrapper { |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1191 margin: 10px 70px 70px; |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1192 box-shadow: 0px 35px 50px rgba( 0, 0, 0, 0.2 ); |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1193 } |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1194 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1195 .fl-table { |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1196 border-radius: 5px; |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1197 font-size: 12px; |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1198 font-weight: normal; |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1199 border: none; |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1200 border-collapse: collapse; |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1201 width: 100%; |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1202 max-width: 100%; |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1203 white-space: nowrap; |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1204 background-color: white; |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1205 } |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1206 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1207 .fl-table td, .fl-table th { |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1208 text-align: center; |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1209 padding: 8px; |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1210 } |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1211 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1212 .fl-table td { |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1213 border: 1px solid #999999; |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1214 font-size: 15px; |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1215 } |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1216 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1217 .fl-table thead th { |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1218 color: #ffffff; |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1219 background: #4FC3A1; |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1220 border: 1px solid #999999; |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1221 } |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1222 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1223 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1224 .fl-table thead th:nth-child(odd) { |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1225 color: #ffffff; |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1226 background: #324960; |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1227 } |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1228 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1229 .fl-table tr:nth-child(even) { |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1230 background: #F8F8F8; |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1231 } |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1232 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1233 .title h2 { |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1234 text-align: center; |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1235 font-size: 22px; |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1236 font-weight: 700; color:#202020; |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1237 text-transform: uppercase; |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1238 word-spacing: 1px; letter-spacing:2px; |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1239 margin-bottom: 50px; |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1240 } |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1241 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1242 .title h2 span { |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1243 padding-top: 40px; |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1244 text-transform: none; |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1245 font-size:.80em; |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1246 font-weight: bold; |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1247 font-family: "Playfair Display","Bookman",serif; |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1248 color:#999; |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1249 letter-spacing:-0.005em; |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1250 word-spacing:1px; |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1251 letter-spacing:none; |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1252 } |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1253 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1254 .title h1:before { |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1255 background-color: #dfdfdf; |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1256 } |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1257 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1258 </style></head>""" |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1259 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1260 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1261 class FileHandler: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1262 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1263 def __init__(self): |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1264 pass |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1265 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1266 @staticmethod |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1267 def download_file_from_url(file_url): |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1268 with request.urlopen(file_url) as response: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1269 fits_file = response.read() |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1270 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1271 return fits_file |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1272 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1273 @staticmethod |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1274 def write_file_to_output(file, output, write_type="w"): |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1275 with open(output, write_type) as file_output: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1276 file_output.write(file) |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1277 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1278 @staticmethod |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1279 def write_urls_to_output(urls: [], output, access_url="access_url"): |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1280 with open(output, "w") as file_output: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1281 for url in urls: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1282 try: |
2
7398ea3d9ac4
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit b77ceb5085f378a8bef9b202b80e3ca7ef1e9a8e
astroteam
parents:
1
diff
changeset
|
1283 file_output.write(str(url[access_url]) + ',') |
0
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1284 except Exception: |
2
7398ea3d9ac4
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit b77ceb5085f378a8bef9b202b80e3ca7ef1e9a8e
astroteam
parents:
1
diff
changeset
|
1285 error_message = f"url field {access_url} not found for url" |
0
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1286 Logger.create_action_log( |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1287 Logger.ACTION_ERROR, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1288 Logger.ACTION_TYPE_WRITE_URL, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1289 error_message) |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1290 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1291 @staticmethod |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1292 def write_file_to_subdir(file, index): |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1293 dir = os.getcwd() |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1294 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1295 dir += '/fits' |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1296 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1297 upload_dir = os.path.join(dir, str(index) + '.fits') |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1298 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1299 with open(upload_dir, "wb") as file_output: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1300 file_output.write(file) |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1301 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1302 @staticmethod |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1303 def get_file_name_from_url(url, index=None): |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1304 url_parts = url.split('/') |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1305 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1306 file_name = '' |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1307 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1308 try: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1309 if (url_parts[-1]) != '': |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1310 file_name = url_parts[-1] |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1311 elif len(url_parts) > 1: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1312 file_name = url_parts[-2] |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1313 except Exception: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1314 file_name = 'archive file ' |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1315 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1316 return file_name |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1317 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1318 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1319 class Utils: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1320 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1321 def __init__(self): |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1322 pass |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1323 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1324 @staticmethod |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1325 def collect_resource_keys(urls_data: list) -> list: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1326 """ |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1327 Collect all the keys from the resources, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1328 keeping the order in the order of key appearance in the resources |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1329 """ |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1330 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1331 resource_keys = [] |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1332 for resource in urls_data: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1333 for key in resource.keys(): |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1334 if key not in resource_keys: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1335 resource_keys.append(key) |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1336 return resource_keys |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1337 |
2
7398ea3d9ac4
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit b77ceb5085f378a8bef9b202b80e3ca7ef1e9a8e
astroteam
parents:
1
diff
changeset
|
1338 @staticmethod |
7398ea3d9ac4
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit b77ceb5085f378a8bef9b202b80e3ca7ef1e9a8e
astroteam
parents:
1
diff
changeset
|
1339 def is_valid_url(url: str) -> bool: |
7398ea3d9ac4
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit b77ceb5085f378a8bef9b202b80e3ca7ef1e9a8e
astroteam
parents:
1
diff
changeset
|
1340 regex_url = re.compile(r'^https?://(?:[A-Za-z0-9-]+\.)+[A-Za-z]{2,6}(?::\d+)?(?:/[^\s]*)?$') # noqa: E501 |
7398ea3d9ac4
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit b77ceb5085f378a8bef9b202b80e3ca7ef1e9a8e
astroteam
parents:
1
diff
changeset
|
1341 return re.match(regex_url, url) is not None |
7398ea3d9ac4
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit b77ceb5085f378a8bef9b202b80e3ca7ef1e9a8e
astroteam
parents:
1
diff
changeset
|
1342 |
0
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1343 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1344 class Logger: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1345 _logs = [] |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1346 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1347 ACTION_SUCCESS = 1 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1348 ACTION_ERROR = 2 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1349 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1350 ACTION_TYPE = 1 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1351 INFO_TYPE = 2 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1352 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1353 ACTION_TYPE_DOWNLOAD = 1 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1354 ACTION_TYPE_ARCHIVE_CONNECTION = 2 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1355 ACTION_TYPE_WRITE_URL = 3 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1356 ACTION_TYPE_WRITE_FILE = 4 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1357 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1358 def __init__(self): |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1359 pass |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1360 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1361 @staticmethod |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1362 def create_action_log(outcome, action, message) -> bool: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1363 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1364 is_log_created = False |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1365 log = "" |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1366 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1367 if action == Logger.ACTION_TYPE_DOWNLOAD: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1368 if outcome == Logger.ACTION_SUCCESS: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1369 log += "Success downloading file : " + message |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1370 else: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1371 log += "Error downloading file : " + message |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1372 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1373 is_log_created = True |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1374 elif action == Logger.ACTION_TYPE_ARCHIVE_CONNECTION: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1375 if outcome == Logger.ACTION_SUCCESS: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1376 log += "Success connecting to archive : " + message |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1377 else: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1378 log += "Error connecting to archive : " + message |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1379 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1380 is_log_created = True |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1381 elif action == Logger.ACTION_TYPE_WRITE_URL: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1382 if outcome == Logger.ACTION_SUCCESS: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1383 log += "Success writing url to file : " + message |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1384 else: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1385 log += "Error writing to file : " + message |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1386 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1387 is_log_created = True |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1388 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1389 if is_log_created: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1390 Logger._insert_log(Logger.ACTION_TYPE, log) |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1391 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1392 return is_log_created |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1393 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1394 @staticmethod |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1395 def create_info_log(message): |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1396 pass |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1397 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1398 @staticmethod |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1399 def _insert_log(type, log): |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1400 Logger._logs.append(log) |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1401 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1402 @staticmethod |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1403 def create_log_file(archive_name, query): |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1404 log_file = "" |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1405 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1406 log_file += "Run summary for archive : " + archive_name + "\n" |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1407 log_file += "With query : " + query + "\n" |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1408 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1409 for log in Logger._logs: |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1410 log_file += log + "\n" |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1411 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1412 return log_file |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1413 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1414 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1415 if __name__ == "__main__": |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1416 output = sys.argv[1] |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1417 output_csv = sys.argv[2] |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1418 output_html = sys.argv[3] |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1419 output_basic_html = sys.argv[4] |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1420 output_error = sys.argv[5] |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1421 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1422 inputs = sys.argv[6] |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1423 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1424 tool_runner = ToolRunner(inputs, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1425 output, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1426 output_csv, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1427 output_html, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1428 output_basic_html, |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1429 output_error) |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1430 |
0ddfc343f9f9
planemo upload for repository https://github.com/esg-epfl-apc/tools-astro/tree/main/tools/ commit d68858614f92df46c58724928d918e989d916db0
astroteam
parents:
diff
changeset
|
1431 tool_runner.run() |