Skip to content
This repository has been archived by the owner on Mar 15, 2019. It is now read-only.

Commit

Permalink
Increase poll interval & send snapshots even when printer is idle
Browse files Browse the repository at this point in the history
  • Loading branch information
sameer committed Dec 6, 2018
1 parent 07f1fde commit 7c46ab7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion poller-pi.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ async def send_printer_status():
printer_jsons_str: str = json.dumps({'printers': printer_jsons, 'key': x_api_key})
logging.info(f'Sending {printer_jsons_str}')
await websocket.send(printer_jsons_str)
await asyncio.sleep(5)
await asyncio.sleep(3)


try:
Expand Down
6 changes: 6 additions & 0 deletions test/test_ultimaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,19 @@ class UltimakerJsonTest(unittest.TestCase):
def test_expected_json_is_produced_when_idle(self):
printer = default_printer_mock()
printer.credentials = Mock(return_value=mock_credentials)
printer.get_camera_snapshot_uri = Mock(
return_value=mock_camera_snapshot_uri
)
json = printer.into_ultimaker_json()
self.assertDictEqual({
'system': {
'name': mock_name
},
'printer': {
'status': 'idle'
},
'camera': {
'snapshot': mock_camera_snapshot_uri
}
}, json)

Expand Down
3 changes: 3 additions & 0 deletions ultimaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ def into_ultimaker_json(self) -> Dict[str, str]:
'printer': {
'status': status,
},
'camera': {
'snapshot': self.get_camera_snapshot_uri()
}
}
if status == 'printing':
ultimaker_json['print_job'] = {
Expand Down

0 comments on commit 7c46ab7

Please sign in to comment.