Exception handling

merge-requests/30/head
Bob Mottram 2021-12-24 20:43:54 +00:00
parent be75d250e0
commit abdc0ad957
1 changed files with 9 additions and 2 deletions

View File

@ -263,8 +263,15 @@ def isDormant(baseDir: str, nickname: str, domain: str, actor: str,
if not os.path.isfile(lastSeenFilename):
return False
with open(lastSeenFilename, 'r') as lastSeenFile:
daysSinceEpochStr = lastSeenFile.read()
daysSinceEpochStr = None
try:
with open(lastSeenFilename, 'r') as lastSeenFile:
daysSinceEpochStr = lastSeenFile.read()
except OSError:
print('EX: failed to read last seen ' + lastSeenFilename)
return False
if daysSinceEpochStr:
daysSinceEpoch = int(daysSinceEpochStr)
currTime = datetime.datetime.utcnow()
currDaysSinceEpoch = (currTime - datetime.datetime(1970, 1, 1)).days