Make bt-tet less verbose
This commit is contained in:
parent
04e551600d
commit
aeb6002e10
@ -219,7 +219,7 @@ class BTNap:
|
|||||||
logging.debug('BT-TETHER: Trying to pair ...')
|
logging.debug('BT-TETHER: Trying to pair ...')
|
||||||
try:
|
try:
|
||||||
device.Pair()
|
device.Pair()
|
||||||
logging.info('BT-TETHER: Successful paired with device ;)')
|
logging.debug('BT-TETHER: Successful paired with device ;)')
|
||||||
return True
|
return True
|
||||||
except dbus.exceptions.DBusException as err:
|
except dbus.exceptions.DBusException as err:
|
||||||
if err.get_dbus_name() == 'org.bluez.Error.AlreadyExists':
|
if err.get_dbus_name() == 'org.bluez.Error.AlreadyExists':
|
||||||
@ -429,13 +429,17 @@ class BTTether(plugins.Plugin):
|
|||||||
# new config
|
# new config
|
||||||
if 'devices' in self.options:
|
if 'devices' in self.options:
|
||||||
for device, options in self.options['devices'].items():
|
for device, options in self.options['devices'].items():
|
||||||
for device_opt in ['enabled', 'priority', 'scantime', 'search_order', 'max_tries', 'share_internet', 'mac', 'ip', 'netmask', 'interval']:
|
if 'enabled' in options and options['enabled']:
|
||||||
if device_opt not in options or (device_opt in options and options[device_opt] is None):
|
for device_opt in ['enabled', 'priority', 'scantime', 'search_order',
|
||||||
logging.error("BT-TET: Pleace specify the %s for device %s.", device_opt, device)
|
'max_tries', 'share_internet', 'mac', 'ip',
|
||||||
break
|
'netmask', 'interval']:
|
||||||
else:
|
if device_opt not in options or (device_opt in options and options[device_opt] is None):
|
||||||
if options['enabled']:
|
logging.error("BT-TET: Pleace specify the %s for device %s.",
|
||||||
self.devices[device] = Device(name=device, **options)
|
device_opt, device)
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
if options['enabled']:
|
||||||
|
self.devices[device] = Device(name=device, **options)
|
||||||
|
|
||||||
# legacy
|
# legacy
|
||||||
if 'mac' in self.options:
|
if 'mac' in self.options:
|
||||||
@ -489,10 +493,10 @@ class BTTether(plugins.Plugin):
|
|||||||
bt = BTNap(device.mac)
|
bt = BTNap(device.mac)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
logging.info('BT-TETHER: Search %d secs for %s ...', device.scantime, device.name)
|
logging.debug('BT-TETHER: Search %d secs for %s ...', device.scantime, device.name)
|
||||||
dev_remote = bt.wait_for_device(timeout=device.scantime)
|
dev_remote = bt.wait_for_device(timeout=device.scantime)
|
||||||
if dev_remote is None:
|
if dev_remote is None:
|
||||||
logging.info('BT-TETHER: Could not find %s, try again in %d minutes.', device.name, device.interval)
|
logging.debug('BT-TETHER: Could not find %s, try again in %d minutes.', device.name, device.interval)
|
||||||
ui.set('bluetooth', 'NF')
|
ui.set('bluetooth', 'NF')
|
||||||
continue
|
continue
|
||||||
except Exception as bt_ex:
|
except Exception as bt_ex:
|
||||||
@ -503,9 +507,9 @@ class BTTether(plugins.Plugin):
|
|||||||
paired = bt.is_paired()
|
paired = bt.is_paired()
|
||||||
if not paired:
|
if not paired:
|
||||||
if BTNap.pair(dev_remote):
|
if BTNap.pair(dev_remote):
|
||||||
logging.info('BT-TETHER: Paired with %s.', device.name)
|
logging.debug('BT-TETHER: Paired with %s.', device.name)
|
||||||
else:
|
else:
|
||||||
logging.info('BT-TETHER: Pairing with %s failed ...', device.name)
|
logging.debug('BT-TETHER: Pairing with %s failed ...', device.name)
|
||||||
ui.set('bluetooth', 'PE')
|
ui.set('bluetooth', 'PE')
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
@ -518,15 +522,15 @@ class BTTether(plugins.Plugin):
|
|||||||
if success:
|
if success:
|
||||||
if device.interface() is None:
|
if device.interface() is None:
|
||||||
ui.set('bluetooth', 'BE')
|
ui.set('bluetooth', 'BE')
|
||||||
logging.info('BT-TETHER: Could not establish nap connection with %s', device.name)
|
logging.debug('BT-TETHER: Could not establish nap connection with %s', device.name)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
logging.info('BT-TETHER: Created interface (%s)', device.interface())
|
logging.debug('BT-TETHER: Created interface (%s)', device.interface())
|
||||||
ui.set('bluetooth', 'C')
|
ui.set('bluetooth', 'C')
|
||||||
any_device_connected = True
|
any_device_connected = True
|
||||||
device.tries = 0 # reset tries
|
device.tries = 0 # reset tries
|
||||||
else:
|
else:
|
||||||
logging.info('BT-TETHER: Could not establish nap connection with %s', device.name)
|
logging.debug('BT-TETHER: Could not establish nap connection with %s', device.name)
|
||||||
ui.set('bluetooth', 'NF')
|
ui.set('bluetooth', 'NF')
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@ -538,7 +542,7 @@ class BTTether(plugins.Plugin):
|
|||||||
logging.debug('BT-TETHER: Add ip to %s', interface)
|
logging.debug('BT-TETHER: Add ip to %s', interface)
|
||||||
if not wrapped_interface.set_addr(addr):
|
if not wrapped_interface.set_addr(addr):
|
||||||
ui.set('bluetooth', 'AE')
|
ui.set('bluetooth', 'AE')
|
||||||
logging.error("BT-TETHER: Could not add ip to %s", interface)
|
logging.debug("BT-TETHER: Could not add ip to %s", interface)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if device.share_internet:
|
if device.share_internet:
|
||||||
@ -551,7 +555,7 @@ class BTTether(plugins.Plugin):
|
|||||||
with open('/etc/resolv.conf', 'r+') as resolv:
|
with open('/etc/resolv.conf', 'r+') as resolv:
|
||||||
nameserver = resolv.read()
|
nameserver = resolv.read()
|
||||||
if 'nameserver 9.9.9.9' not in nameserver:
|
if 'nameserver 9.9.9.9' not in nameserver:
|
||||||
logging.info('BT-TETHER: Added nameserver')
|
logging.debug('BT-TETHER: Added nameserver')
|
||||||
resolv.seek(0)
|
resolv.seek(0)
|
||||||
resolv.write(nameserver + 'nameserver 9.9.9.9\n')
|
resolv.write(nameserver + 'nameserver 9.9.9.9\n')
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user