Skip to content

Commit

Permalink
fix: handle error when no suspend entry is there
Browse files Browse the repository at this point in the history
  • Loading branch information
RoguedBear committed Dec 5, 2021
1 parent 335d24b commit 657a37f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions smart_sleep.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,8 @@ def get_last_sleep_time() -> datetime.datetime:
sleep_entry_entries = subprocess.check_output(
'grep -E "PM: suspend entry" /var/log/syslog; exit 0', shell=True
).decode()
except subprocess.CalledProcessError:
assert len(sleep_entry_entries) != 0, "No last sleep time recorded"
except (subprocess.CalledProcessError, AssertionError):
last_sleep_entry = datetime.datetime.min
else:
sleep_entry_entries = sleep_entry_entries.split("\n")[:-1]
Expand Down Expand Up @@ -537,7 +538,7 @@ def sleep_computer_but_wake_at(time: datetime.timedelta, debug: bool = False):
["sudo", "-s", "rtcwake", "-m", "on", "-s", str(time_to_wake_up.seconds)]
)
logger.debug(output.decode())
sleep(0.5)
sleep(2)
logger.info('"Good Mawrning!" [read that in Tim Cook way] I am awake now.')


Expand Down

0 comments on commit 657a37f

Please sign in to comment.