diff --git a/api/src/opentrons/system/time.py b/api/src/opentrons/system/time.py index b2e83135d89..282fe683ba5 100644 --- a/api/src/opentrons/system/time.py +++ b/api/src/opentrons/system/time.py @@ -1,6 +1,6 @@ import asyncio import logging -from typing import Dict, Tuple, Any +from typing import Dict, Tuple from datetime import datetime, timezone from dateutil.parser import parse @@ -20,9 +20,9 @@ def _str_to_dict(res_str): async def _time_status(loop: asyncio.AbstractEventLoop = None ) -> Dict[str, str]: """ - Get details of robot's date & system, with specifics of RTC (if present) + Get details of robot's date & time, with specifics of RTC (if present) & status of NTP synchronization. - :return: Dict with the above specified fields + :return: Dictionary of status params """ proc = await asyncio.create_subprocess_shell( 'timedatectl show', @@ -42,8 +42,8 @@ async def _set_time(time: str, stderr=asyncio.subprocess.PIPE, loop=loop or asyncio.get_event_loop() ) - out_b, err_b = await proc.communicate() - return out_b.decode(), err_b.decode() + out, err = await proc.communicate() + return out.decode(), err.decode() async def get_system_time(loop: asyncio.AbstractEventLoop = None) -> datetime: diff --git a/api/tests/opentrons/system/test_time.py b/api/tests/opentrons/system/test_time.py index d396f341c4b..bc69cc81cb4 100644 --- a/api/tests/opentrons/system/test_time.py +++ b/api/tests/opentrons/system/test_time.py @@ -30,14 +30,14 @@ async def async_mock_time_status(*args, **kwargs): datetime_val = await time.get_system_time() assert datetime_val == mock_time + # Test conversion from non-utc to utc async def async_mock_time_status(*args, **kwargs): _stat = mock_status - _stat.update(TimeUSec='Fri 2020-08-14 17:44:16 EST') + _stat.update(TimeUSec='Fri 2020-08-14 17:44:16 EDT') return _stat time._time_status = MagicMock(side_effect=async_mock_time_status) datetime_val = await time.get_system_time() - print(f'got datetime: {datetime_val}') assert datetime_val == mock_time