mirror of
https://github.com/gryf/linak-ctrl.git
synced 2025-12-19 12:18:05 +01:00
Handle keyboard interrupt exception for status with loop.
This commit is contained in:
@@ -115,12 +115,15 @@ class LinakDevice:
|
|||||||
|
|
||||||
def get_position(self, loop=False):
|
def get_position(self, loop=False):
|
||||||
if loop:
|
if loop:
|
||||||
while True:
|
try:
|
||||||
report = self._get_report()
|
while True:
|
||||||
LOG.warning('Position: %s, height: %.2fcm, moving: %s',
|
report = self._get_report()
|
||||||
report.position, report.position_in_cm,
|
LOG.warning('Position: %s, height: %.2fcm, moving: %s',
|
||||||
report.moving)
|
report.position, report.position_in_cm,
|
||||||
time.sleep(0.2)
|
report.moving)
|
||||||
|
time.sleep(0.2)
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
return
|
||||||
else:
|
else:
|
||||||
report = self._get_report()
|
report = self._get_report()
|
||||||
LOG.warning('Position: %s, height: %scm, moving: %s',
|
LOG.warning('Position: %s, height: %scm, moving: %s',
|
||||||
|
|||||||
Reference in New Issue
Block a user