Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions socs/agents/http_camera/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def acq(self, session, params=None):
"password": camera['password']}}}]
try:
resp = requests.post(login_url, data=json.dumps(login_payload), verify=False)
except (requests.exceptions.RequestException, ReadTimeoutError) as e:
except (requests.exceptions.ConnectionError, requests.exceptions.RequestException, ReadTimeoutError) as e:
self.log.error(f'{e}')
self.log.info("Unable to get response from camera.")
data[camera['location']]['last_attempt'] = time.time()
Expand Down Expand Up @@ -157,7 +157,7 @@ def acq(self, session, params=None):
response = requests.get(url, params=payload, stream=True, timeout=5, verify=False)
elif camera['brand'] == 'acti':
response = requests.get(url, params=payload, stream=True, timeout=5)
except (requests.exceptions.RequestException, ReadTimeoutError) as e:
except (requests.exceptions.ConnectionError, requests.exceptions.RequestException, ReadTimeoutError) as e:
self.log.error(f'{e}')
self.log.info("Unable to get response from camera.")
data[camera['location']]['last_attempt'] = time.time()
Expand All @@ -174,12 +174,18 @@ def acq(self, session, params=None):
out_file.flush()
os.fsync(out_file.fileno())
self.log.debug(f"Wrote {ctime}.jpg to /{camera['location']}/{ctime_dir}.")
except ReadTimeoutError as e:
except (requests.exceptions.ConnectionError, requests.exceptions.RequestException, ReadTimeoutError) as e:
self.log.error(f'{e}')
self.log.info("Timeout occurred while writing to file.")
data[camera['location']]['last_attempt'] = time.time()
data[camera['location']]['connected'] = False
continue
except Exception as e:
self.log.error(f'{e}')
self.log.info("Unexpected error occurred while writing to file.")
data[camera['location']]['last_attempt'] = time.time()
data[camera['location']]['connected'] = False
continue
finally:
response.close()
shutil.copy2(filename, latest_filename)
Expand Down