[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:
|
try:
|
||||||
(retcode,routes) = run('ip route list table {}'.format(self.provider_name))
|
(retcode,routes) = run('ip route list table {}'.format(self.provider_name))
|
||||||
if retcode == 0:
|
if retcode == 0:
|
||||||
routes = routes.splitlines()
|
routes = routes.decode('utf-8').splitlines()
|
||||||
self.last_enabled = len(routes)>0
|
self.last_enabled = len(routes)>0
|
||||||
else:
|
else:
|
||||||
self.last_enabled = False
|
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
|
return self.last_enabled
|
||||||
|
|
||||||
def led_off(self):
|
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):
|
if os.path.isdir(led_path):
|
||||||
with open(os.path.join(led_path,'brightness'),'wb') as f:
|
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:
|
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):
|
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):
|
if os.path.isdir(led_path):
|
||||||
with open(os.path.join(led_path,'trigger'),'wb') as f:
|
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:
|
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):
|
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):
|
if os.path.isdir(led_path):
|
||||||
with open(os.path.join(led_path,'brightness'),'wb') as f:
|
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:
|
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):
|
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:
|
if self._available:
|
||||||
self.led_on()
|
self.led_on()
|
||||||
elif self.device_up:
|
elif self.device_up:
|
||||||
self.led_blink()
|
self.led_off()
|
||||||
else:
|
else:
|
||||||
self.led_off()
|
self.led_off()
|
||||||
else:
|
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"""
|
"""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))
|
(retcode,routes) = run('ip route list table main dev {}'.format(self.device))
|
||||||
if retcode == 0:
|
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))
|
print(run('ip route del default table main dev {}'.format(self.device),dry_run=self.dry_run))
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user