kete: fix log errors when the device is not paired anymore

Tuhi raise -EACCES if the UUID stored is not valid anymore.
Instead of shouting some obscure error, we should notify the
user that a pairing need to happen or the device will not talk
to us.

Also fix a small sign mistake in calling os.strerror() for general
errors

Fixes #6
pull/49/head
Benjamin Tissoires 2018-01-30 14:01:48 +01:00 committed by Peter Hutterer
parent e647e20426
commit 5889052fb1
1 changed files with 5 additions and 2 deletions

View File

@ -15,6 +15,7 @@ from gi.repository import GObject, Gio, GLib
import sys
import argparse
import cmd
import errno
import os
import json
import logging
@ -193,8 +194,10 @@ class TuhiKeteDevice(_DBusObject):
logger.info(f'{self}: Press button on device now')
elif signal == 'ListeningStopped':
err = parameters[0]
if err < 0:
logger.error(f'{self}: an error occured: {os.strerror(err)}')
if err == -errno.EACCES:
logger.error(f'{self}: wrong device, please redo pairing.')
elif err < 0:
logger.error(f'{self}: an error occured: {os.strerror(-err)}')
self.notify('listening')
def _on_properties_changed(self, proxy, changed_props, invalidated_props):