LowellObservatory / NightShift

Collection of sub-modules used in the NightWatch (and other Night*) project
Mozilla Public License 2.0
1 stars 1 forks source link

Unhandled webcam crash #18

Closed astrobokonon closed 3 years ago

astrobokonon commented 3 years ago
2021-03-04 17:49:09,498 INFO     Found the following sections in the configuration file:
2021-03-04 17:49:09,498 INFO     DCTAllSky UpperGate HeliumCompressor Genset TelescopeBuilding UtilityYard ObservingLevel DomeRoof
2021-03-04 17:49:09,498 INFO     Enabled:
2021-03-04 17:49:09,498 INFO     DCTAllSky UpperGate HeliumCompressor Genset TelescopeBuilding UtilityYard ObservingLevel DomeRoof
2021-03-04 17:49:09,500 INFO     Retrieving camera image: DCTAllSky
2021-03-04 17:49:09,531 INFO     Attempting to write image to ./outputs/images/dct//allsky.jpg
2021-03-04 17:49:09,532 INFO     Retrieving image from: http://dct-allsky.lowell.edu/allsky//as20210304_134802.jpg
2021-03-04 17:49:09,570 INFO     File will be archived as: ./outputs/images/dct//archive/allsky//20210304//20210304_174909.jpg
2021-03-04 17:49:10,071 INFO     Retrieving camera image: UpperGate
2021-03-04 17:49:10,072 INFO     Attempting to write image to ./outputs/images/dct//gate.jpg
2021-03-04 17:49:10,137 INFO     Good grab!
2021-03-04 17:49:10,138 INFO     File will be archived as: ./outputs/images/dct//archive/gate//20210304//20210304_174910.jpg
2021-03-04 17:49:10,639 INFO     Retrieving camera image: HeliumCompressor
2021-03-04 17:49:10,639 INFO     Attempting to write image to ./outputs/images/dct//heliumcomp.jpg
2021-03-04 17:49:10,710 INFO     Good grab!
2021-03-04 17:49:10,710 INFO     File will be archived as: ./outputs/images/dct//archive/heliumcomp//20210304//20210304_174910.jpg
2021-03-04 17:49:11,211 INFO     Retrieving camera image: Genset
2021-03-04 17:49:11,212 INFO     Attempting to write image to ./outputs/images/dct//genset.jpg
2021-03-04 17:49:16,222 ERROR    Traceback (most recent call last):
2021-03-04 17:49:16,222 ERROR      File "/opt/conda/lib/python3.7/site-packages/urllib3/connectionpool.py", line 421, in _make_request
2021-03-04 17:49:16,223 ERROR    six.raise_from(e, None)
2021-03-04 17:49:16,223 ERROR      File "<string>", line 3, in raise_from
2021-03-04 17:49:16,223 ERROR      File "/opt/conda/lib/python3.7/site-packages/urllib3/connectionpool.py", line 416, in _make_request
2021-03-04 17:49:16,223 ERROR    httplib_response = conn.getresponse()
2021-03-04 17:49:16,223 ERROR      File "/opt/conda/lib/python3.7/http/client.py", line 1344, in getresponse
2021-03-04 17:49:16,224 ERROR    response.begin()
2021-03-04 17:49:16,224 ERROR      File "/opt/conda/lib/python3.7/http/client.py", line 306, in begin
2021-03-04 17:49:16,224 ERROR    version, status, reason = self._read_status()
2021-03-04 17:49:16,224 ERROR      File "/opt/conda/lib/python3.7/http/client.py", line 267, in _read_status
2021-03-04 17:49:16,224 ERROR    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
2021-03-04 17:49:16,224 ERROR      File "/opt/conda/lib/python3.7/socket.py", line 589, in readinto
2021-03-04 17:49:16,225 ERROR    return self._sock.recv_into(b)
2021-03-04 17:49:16,225 ERROR    socket
2021-03-04 17:49:16,225 ERROR    .
2021-03-04 17:49:16,225 ERROR    timeout
2021-03-04 17:49:16,225 ERROR    :
2021-03-04 17:49:16,225 ERROR    timed out
2021-03-04 17:49:16,225 ERROR
During handling of the above exception, another exception occurred:
2021-03-04 17:49:16,225 ERROR    Traceback (most recent call last):
2021-03-04 17:49:16,225 ERROR      File "/opt/conda/lib/python3.7/site-packages/requests/adapters.py", line 449, in send
2021-03-04 17:49:16,225 ERROR    timeout=timeout
2021-03-04 17:49:16,226 ERROR      File "/opt/conda/lib/python3.7/site-packages/urllib3/connectionpool.py", line 720, in urlopen
2021-03-04 17:49:16,226 ERROR    method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
2021-03-04 17:49:16,226 ERROR      File "/opt/conda/lib/python3.7/site-packages/urllib3/util/retry.py", line 400, in increment
2021-03-04 17:49:16,226 ERROR    raise six.reraise(type(error), error, _stacktrace)
2021-03-04 17:49:16,226 ERROR      File "/opt/conda/lib/python3.7/site-packages/urllib3/packages/six.py", line 735, in reraise
2021-03-04 17:49:16,227 ERROR    raise value
2021-03-04 17:49:16,227 ERROR      File "/opt/conda/lib/python3.7/site-packages/urllib3/connectionpool.py", line 672, in urlopen
2021-03-04 17:49:16,227 ERROR    chunked=chunked,
2021-03-04 17:49:16,227 ERROR      File "/opt/conda/lib/python3.7/site-packages/urllib3/connectionpool.py", line 423, in _make_request
2021-03-04 17:49:16,227 ERROR    self._raise_timeout(err=e, url=url, timeout_value=read_timeout)
2021-03-04 17:49:16,227 ERROR      File "/opt/conda/lib/python3.7/site-packages/urllib3/connectionpool.py", line 331, in _raise_timeout
2021-03-04 17:49:16,227 ERROR    self, url, "Read timed out. (read timeout=%s)" % timeout_value
2021-03-04 17:49:16,228 ERROR    urllib3.exceptions
2021-03-04 17:49:16,228 ERROR    .
2021-03-04 17:49:16,228 ERROR    ReadTimeoutError
2021-03-04 17:49:16,228 ERROR    :
2021-03-04 17:49:16,228 ERROR    HTTPConnectionPool(host='10.x.x.x', port=80): Read timed out. (read timeout=5.0)
2021-03-04 17:49:16,228 ERROR
During handling of the above exception, another exception occurred:
2021-03-04 17:49:16,228 ERROR    Traceback (most recent call last):
2021-03-04 17:49:16,228 ERROR      File "looper_webcams.py", line 64, in <module>
2021-03-04 17:49:16,228 ERROR    main()
2021-03-04 17:49:16,228 ERROR      File "looper_webcams.py", line 56, in main
2021-03-04 17:49:16,228 ERROR    cams.grabSet(oncams, failimg=None, archive=True)
2021-03-04 17:49:16,228 ERROR      File "/home/lig/Codes/NightShift/nightshift/webcam/grab_cams.py", line 48, in grabSet
2021-03-04 17:49:16,229 ERROR    camGrabbie(currentCamera, outfile)
2021-03-04 17:49:16,229 ERROR      File "/home/lig/Codes/NightShift/nightshift/webcam/grab_cams.py", line 101, in camGrabbie
2021-03-04 17:49:16,229 ERROR    img = httpget(cam.url, auth=auth, timeout=5.)
2021-03-04 17:49:16,229 ERROR      File "/opt/conda/lib/python3.7/site-packages/requests/api.py", line 75, in get
2021-03-04 17:49:16,229 ERROR    return request('get', url, params=params, **kwargs)
2021-03-04 17:49:16,229 ERROR      File "/opt/conda/lib/python3.7/site-packages/requests/api.py", line 60, in request
2021-03-04 17:49:16,229 ERROR    return session.request(method=method, url=url, **kwargs)
2021-03-04 17:49:16,229 ERROR      File "/opt/conda/lib/python3.7/site-packages/requests/sessions.py", line 533, in request
2021-03-04 17:49:16,230 ERROR    resp = self.send(prep, **send_kwargs)
2021-03-04 17:49:16,230 ERROR      File "/opt/conda/lib/python3.7/site-packages/requests/sessions.py", line 653, in send
2021-03-04 17:49:16,230 ERROR    r = dispatch_hook('response', hooks, r, **kwargs)
2021-03-04 17:49:16,230 ERROR      File "/opt/conda/lib/python3.7/site-packages/requests/hooks.py", line 31, in dispatch_hook
2021-03-04 17:49:16,230 ERROR    _hook_data = hook(hook_data, **kwargs)
2021-03-04 17:49:16,230 ERROR      File "/opt/conda/lib/python3.7/site-packages/requests/auth.py", line 269, in handle_401
2021-03-04 17:49:16,230 ERROR    _r = r.connection.send(prep, **kwargs)
2021-03-04 17:49:16,231 ERROR      File "/opt/conda/lib/python3.7/site-packages/requests/adapters.py", line 529, in send
2021-03-04 17:49:16,231 ERROR    raise ReadTimeout(e, request=request)
2021-03-04 17:49:16,231 ERROR    requests.exceptions
2021-03-04 17:49:16,231 ERROR    .
2021-03-04 17:49:16,231 ERROR    ReadTimeout
2021-03-04 17:49:16,231 ERROR    :
2021-03-04 17:49:16,231 ERROR    HTTPConnectionPool(host='10.x.x.x', port=80): Read timed out. (read timeout=5.0)

Not sure which is the real exception to trace down, hopefully it's just a simple one not catching the timeout

astrobokonon commented 3 years ago

Hacked in a potential fix in 86c5815f281215a5d19fffbf150a5588bc3ce125; I'm ultimately not sure if it's the best idea but it's the easiest for now to make sure that the connection error is handled in the same way as the existing one I raise if the HTTP status is not ok.

astrobokonon commented 3 years ago

Looks like it worked!

2021-03-04 18:00:45,454 INFO     Retrieving camera image: Genset
2021-03-04 18:00:45,454 INFO     Attempting to write image to ./outputs/images/dct//genset.jpg
2021-03-04 18:00:50,465 INFO     Bad grab :(
2021-03-04 18:00:50,465 INFO     HTTPConnectionPool(host='10.x.x.x', port=80): Read timed out. (read timeout=5.0)