Skip to content

Commit

Permalink
python3.5: replaced datetime.isoformat(datespec=...) with .strftime
Browse files Browse the repository at this point in the history
  • Loading branch information
fphammerle committed Jun 18, 2020
1 parent f9af627 commit 5abc53b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- replaced [PEP526](https://www.python.org/dev/peps/pep-0526/#abstract)-style variable type hints
with [PEP484](https://www.python.org/dev/peps/pep-0484/)-compatible
- fixed `AttributeError` due to unavailable `MagicMock.assert_called_once`
- fixed `TypeError` when calling `datetime.datetime.isoformat(datespec=…)`

## [0.1.0] - 2020-06-16
### Added
Expand Down
6 changes: 3 additions & 3 deletions systemctl_mqtt/__init__.py
Expand Up @@ -46,10 +46,10 @@ def _schedule_shutdown(action: str) -> None:
# https://github.com/systemd/systemd/blob/v237/src/systemctl/systemctl.c#L8553
assert action in ["poweroff", "reboot"], action
shutdown_datetime = datetime.datetime.now() + _SHUTDOWN_DELAY
# datetime.datetime.isoformat(timespec=) not available in python3.5
# https://github.com/python/cpython/blob/v3.5.9/Lib/datetime.py#L1552
_LOGGER.info(
"scheduling %s for %s",
action,
shutdown_datetime.isoformat(sep=" ", timespec="seconds"),
"scheduling %s for %s", action, shutdown_datetime.strftime("%Y-%m-%d %H:%M:%S"),
)
shutdown_epoch_usec = int(shutdown_datetime.timestamp() * 10 ** 6)
try:
Expand Down

0 comments on commit 5abc53b

Please sign in to comment.