Skip to content
Merged
Show file tree
Hide file tree
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
9 changes: 6 additions & 3 deletions ring_doorbell/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def _process_cached_session(self):
# if not, it should continue to get a new auth token
url = API_URI + DEVICES_ENDPOINT
req = self.query(url, raw=True)
if req.status_code == 200:
if req and req.status_code == 200:
self._authenticate(session=req)
else:
self._authenticate()
Expand All @@ -99,7 +99,8 @@ def _authenticate(self, attempts=RETRY_TOKEN, session=None):
headers=HEADERS)
else:
req = session
except:
except requests.exceptions.RequestException as err_msg:
_LOGGER.error("Error!! %s", err_msg)
raise

# if token is expired, refresh credentials and try again
Expand Down Expand Up @@ -173,7 +174,9 @@ def query(self,

if self.debug:
_LOGGER.debug("_query %s ret %s", loop, req.status_code)
except:

except requests.exceptions.RequestException as err_msg:
_LOGGER.error("Error!! %s", err_msg)
raise

# if token is expired, refresh credentials and try again
Expand Down
16 changes: 5 additions & 11 deletions ring_doorbell/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,8 @@ def _locator(lst, key, value):

def _clean_cache(filename):
"""Remove filename if pickle version mismatch."""
try:
if os.path.isfile(filename):
os.remove(filename)
except:
raise
if os.path.isfile(filename):
os.remove(filename)

# initialize cache since file was removed
initial_cache_data = CACHE_ATTRS
Expand All @@ -40,12 +37,9 @@ def _exists_cache(filename):

def _save_cache(data, filename):
"""Dump data into a pickle file."""
try:
with open(filename, 'wb') as pickle_db:
pickle.dump(data, pickle_db)
return True
except:
raise
with open(filename, 'wb') as pickle_db:
pickle.dump(data, pickle_db)
return True


def _read_cache(filename):
Expand Down