From a8615a2f700f82a5c1291fe29a6e24fdb2aed0f8 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 6 Mar 2026 19:14:37 +0100 Subject: [PATCH] [UPD] Change to APU leds --- check_providers.py | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/check_providers.py b/check_providers.py index 9992613..442be5d 100644 --- a/check_providers.py +++ b/check_providers.py @@ -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):