Skip to content

Commit

Permalink
Wrapping bytes_to_datetime in a try except decorator
Browse files Browse the repository at this point in the history
  • Loading branch information
ventris authored Jun 14, 2019
1 parent 07445c7 commit 2315184
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions snmpexporter/prometheus.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,12 @@ def bytes_to_datetime(b):
utc_hour=hour-int(b[9])
utc_minutes=minutes-int(b[10])

ct = datetime.datetime(year,month,day,utc_hour,utc_minutes,seconds,
try:
ct = datetime.datetime(year,month,day,utc_hour,utc_minutes,seconds,
tzinfo=datetime.timezone.utc).timestamp()
return ct
return ct
except:
return float('nan')


CONVERTERS = {
Expand Down

0 comments on commit 2315184

Please sign in to comment.