mirror of
https://github.com/gryf/linak-ctrl.git
synced 2025-12-20 04:38:01 +01:00
DRY. Simplifying get_status method.
This commit is contained in:
@@ -128,20 +128,17 @@ class LinakDevice:
|
|||||||
self._dev.detach_kernel_driver(0)
|
self._dev.detach_kernel_driver(0)
|
||||||
|
|
||||||
def get_position(self, args):
|
def get_position(self, args):
|
||||||
if args.loop:
|
try:
|
||||||
try:
|
while True:
|
||||||
while True:
|
report = self._get_report()
|
||||||
report = self._get_report()
|
LOG.warning('Position: %s, height: %.2fcm, moving: %s',
|
||||||
LOG.warning('Position: %s, height: %.2fcm, moving: %s',
|
report.position, report.position_in_cm,
|
||||||
report.position, report.position_in_cm,
|
report.moving)
|
||||||
report.moving)
|
if not args.loop:
|
||||||
time.sleep(0.2)
|
break
|
||||||
except KeyboardInterrupt:
|
time.sleep(0.2)
|
||||||
return
|
except KeyboardInterrupt:
|
||||||
else:
|
return
|
||||||
report = self._get_report()
|
|
||||||
LOG.warning('Position: %s, height: %.2fcm, moving: %s',
|
|
||||||
report.position, report.position_in_cm, report.moving)
|
|
||||||
|
|
||||||
def move(self, args):
|
def move(self, args):
|
||||||
retry_count = 3
|
retry_count = 3
|
||||||
|
|||||||
Reference in New Issue
Block a user