Code Sample, a minimal, complete, and verifiable piece of code
import os
import pyorbital.tlefile
os.environ["TLES"] = "/no/tles/found/here*"
pyorbital.tlefile.Tle("NOAA-18")
Problem description
When the environment variable TLES contains a globbing pattern that does not match any results, constructing the Tle class fails with ValueError. This crashes the gatherer script from pytroll-collectors. Either pyorbital should have some fallback option, or it should raise an exception that can be caught by gatherer which will then try to give up gracefully without crashing.
Expected Output
I expect that this code either decides to download TLEs as a fallback option when no TLEs are found locally, or raises a sufficiently specific exception that could then be caught by client libraries (such as pytroll-collectors) which can then implement their own fallback alternative.
Actual Result, Traceback if applicable
For the MCVE:
Traceback (most recent call last):
File "tle-valueerror.py", line 5, in <module>
pyorbital.tlefile.Tle("NOAA-18")
File "/data/gholl/miniconda3/envs/py38b/lib/python3.8/site-packages/pyorbital/tlefile.py", line 154, in __init__
self._read_tle()
File "/data/gholl/miniconda3/envs/py38b/lib/python3.8/site-packages/pyorbital/tlefile.py", line 200, in _read_tle
urls = (max(glob.glob(os.environ["TLES"]),
ValueError: max() arg is an empty sequence
From my gatherer log:
Exception in thread Thread-1:
Traceback (most recent call last):
File "/opt/pytroll/pytroll_inst/miniconda3/envs/pytroll-py38/lib/python3.8/threading.py", line 932, in _bootstrap_inner
self.run()
File "/opt/pytroll/pytroll_inst/miniconda3/envs/pytroll-py38/lib/python3.8/site-packages/pytroll_collectors/trigger.py", line 397, in run
self.process(msg)
File "/opt/pytroll/pytroll_inst/miniconda3/envs/pytroll-py38/lib/python3.8/site-packages/pytroll_collectors/trigger.py", line 111, in add_file
self._do(pathname)
File "/opt/pytroll/pytroll_inst/miniconda3/envs/pytroll-py38/lib/python3.8/site-packages/pytroll_collectors/trigger.py", line 107, in _do
Trigger._do(self, mda)
File "/opt/pytroll/pytroll_inst/miniconda3/envs/pytroll-py38/lib/python3.8/site-packages/pytroll_collectors/trigger.py", line 86, in _do
res = collector(metadata.copy())
File "/opt/pytroll/pytroll_inst/miniconda3/envs/pytroll-py38/lib/python3.8/site-packages/pytroll_collectors/region_collector.py", line 65, in __call__
return self.collect(granule_metadata)
File "/opt/pytroll/pytroll_inst/miniconda3/envs/pytroll-py38/lib/python3.8/site-packages/pytroll_collectors/region_collector.py", line 147, in collect
granule_pass = Pass(platform, start_time, end_time,
File "/opt/pytroll/pytroll_inst/miniconda3/envs/pytroll-py38/lib/python3.8/site-packages/trollsched/satpass.py", line 176, in __init__
self.orb = orbital.Orbital(satellite, line1=tle1, line2=tle2)
File "/opt/pytroll/pytroll_inst/miniconda3/envs/pytroll-py38/lib/python3.8/site-packages/pyorbital/orbital.py", line 164, in __init__
self.tle = tlefile.read(satellite, tle_file=tle_file,
File "/opt/pytroll/pytroll_inst/miniconda3/envs/pytroll-py38/lib/python3.8/site-packages/pyorbital/tlefile.py", line 106, in read
return Tle(platform, tle_file=tle_file, line1=line1, line2=line2)
File "/opt/pytroll/pytroll_inst/miniconda3/envs/pytroll-py38/lib/python3.8/site-packages/pyorbital/tlefile.py", line 154, in __init__
self._read_tle()
File "/opt/pytroll/pytroll_inst/miniconda3/envs/pytroll-py38/lib/python3.8/site-packages/pyorbital/tlefile.py", line 200, in _read_tle
urls = (max(glob.glob(os.environ["TLES"]),
ValueError: max() arg is an empty sequence
Versions of Python, package at hand and relevant dependencies
Code Sample, a minimal, complete, and verifiable piece of code
Problem description
When the environment variable
TLES
contains a globbing pattern that does not match any results, constructing theTle
class fails withValueError
. This crashes thegatherer
script frompytroll-collectors
. Either pyorbital should have some fallback option, or it should raise an exception that can be caught bygatherer
which will then try to give up gracefully without crashing.Expected Output
I expect that this code either decides to download TLEs as a fallback option when no TLEs are found locally, or raises a sufficiently specific exception that could then be caught by client libraries (such as
pytroll-collectors
) which can then implement their own fallback alternative.Actual Result, Traceback if applicable
For the MCVE:
From my
gatherer
log:Versions of Python, package at hand and relevant dependencies