[UPD] Change to APU leds
This commit is contained in:
+17
-12
@@ -389,7 +389,7 @@ available == True if actual rtt and loss are below the max_rtt and max_loss
|
||||
try:
|
||||
(retcode,routes) = run('ip route list table {}'.format(self.provider_name))
|
||||
if retcode == 0:
|
||||
routes = routes.splitlines()
|
||||
routes = routes.decode('utf-8').splitlines()
|
||||
self.last_enabled = len(routes)>0
|
||||
else:
|
||||
self.last_enabled = False
|
||||
@@ -399,28 +399,33 @@ available == True if actual rtt and loss are below the max_rtt and max_loss
|
||||
return self.last_enabled
|
||||
|
||||
def led_off(self):
|
||||
led_path = '/sys/class/leds/alix:{}'.format(self.led)
|
||||
# led_path = '/sys/class/leds/alix:{}'.format(self.led)
|
||||
print('led off')
|
||||
led_path = r'/sys/class/leds/apu:green:{}'.format(self.led)
|
||||
if os.path.isdir(led_path):
|
||||
with open(os.path.join(led_path,'brightness'),'wb') as f:
|
||||
f.write('0')
|
||||
f.write(bytes('0',encoding='utf-8'))
|
||||
with open(os.path.join(led_path,'trigger'),'wb') as f:
|
||||
f.write('none')
|
||||
f.write(bytes('none',encoding='utf-8'))
|
||||
|
||||
def led_on(self):
|
||||
led_path = '/sys/class/leds/alix:{}'.format(self.led)
|
||||
# led_path = '/sys/class/leds/alix:{}'.format(self.led)
|
||||
led_path = r'/sys/class/leds/apu:green:{}'.format(self.led)
|
||||
if os.path.isdir(led_path):
|
||||
with open(os.path.join(led_path,'trigger'),'wb') as f:
|
||||
f.write('none')
|
||||
f.write(bytes('none',encoding='utf-8'))
|
||||
with open(os.path.join(led_path,'brightness'),'wb') as f:
|
||||
f.write('1')
|
||||
f.write(bytes('1', encoding='utf-8'))
|
||||
|
||||
def led_blink(self):
|
||||
led_path = '/sys/class/leds/alix:{}'.format(self.led)
|
||||
# led_path = '/sys/class/leds/alix:{}'.format(self.led)
|
||||
print('led blink')
|
||||
led_path = r'/sys/class/leds/apu:green:{}'.format(self.led)
|
||||
if os.path.isdir(led_path):
|
||||
with open(os.path.join(led_path,'brightness'),'wb') as f:
|
||||
f.write('1')
|
||||
f.write(bytes('1',encoding='utf-8'))
|
||||
with open(os.path.join(led_path,'trigger'),'wb') as f:
|
||||
f.write('timer')
|
||||
f.write(bytes('heartbeat',encoding='utf-8'))
|
||||
|
||||
def update_leds(self):
|
||||
""""""
|
||||
@@ -430,7 +435,7 @@ available == True if actual rtt and loss are below the max_rtt and max_loss
|
||||
if self._available:
|
||||
self.led_on()
|
||||
elif self.device_up:
|
||||
self.led_blink()
|
||||
self.led_off()
|
||||
else:
|
||||
self.led_off()
|
||||
else:
|
||||
@@ -477,7 +482,7 @@ available == True if actual rtt and loss are below the max_rtt and max_loss
|
||||
"""Remove default route which could have been added in main routing table and will prevent fallback interface from taking over"""
|
||||
(retcode,routes) = run('ip route list table main dev {}'.format(self.device))
|
||||
if retcode == 0:
|
||||
if 'default ' in routes:
|
||||
if 'default ' in routes.decode('utf-8'):
|
||||
print(run('ip route del default table main dev {}'.format(self.device),dry_run=self.dry_run))
|
||||
|
||||
def __str__(self):
|
||||
|
||||
Reference in New Issue
Block a user