Skip to content

Commit

Permalink
cleaning up
Browse files Browse the repository at this point in the history
  • Loading branch information
sanni-t committed Aug 21, 2020
1 parent 96c1cb7 commit 694fa72
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions api/src/opentrons/system/time.py
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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',
Expand All @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions api/tests/opentrons/system/test_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down

0 comments on commit 694fa72

Please sign in to comment.