Browse Source

led.py: `binfo.status` -> `binfo.control`

The MMGen Project 1 month ago
parent
commit
d39e1e5cd4
2 changed files with 14 additions and 14 deletions
  1. 12 12
      mmgen/led.py
  2. 2 2
      test/cmdtest_d/ct_autosign.py

+ 12 - 12
mmgen/led.py

@@ -29,31 +29,31 @@ from .color import blue, orange
 
 
 class LEDControl:
 class LEDControl:
 
 
-	binfo = namedtuple('board_info', ['name', 'status', 'trigger', 'trigger_states'])
+	binfo = namedtuple('board_info', ['name', 'control', 'trigger', 'trigger_states'])
 	boards = {
 	boards = {
 		'raspi_pi': binfo(
 		'raspi_pi': binfo(
 			name    = 'Raspberry Pi',
 			name    = 'Raspberry Pi',
-			status  = '/sys/class/leds/led0/brightness',
+			control = '/sys/class/leds/led0/brightness',
 			trigger = '/sys/class/leds/led0/trigger',
 			trigger = '/sys/class/leds/led0/trigger',
 			trigger_states = ('none', 'mmc0')),
 			trigger_states = ('none', 'mmc0')),
 		'orange_pi': binfo(
 		'orange_pi': binfo(
 			name    = 'Orange Pi (Armbian)',
 			name    = 'Orange Pi (Armbian)',
-			status  = '/sys/class/leds/orangepi:red:status/brightness',
+			control = '/sys/class/leds/orangepi:red:status/brightness',
 			trigger = None,
 			trigger = None,
 			trigger_states = None),
 			trigger_states = None),
 		'orange_pi_5': binfo(
 		'orange_pi_5': binfo(
 			name    = 'Orange Pi 5 (Armbian)',
 			name    = 'Orange Pi 5 (Armbian)',
-			status  = '/sys/class/leds/status_led/brightness',
+			control = '/sys/class/leds/status_led/brightness',
 			trigger = None,
 			trigger = None,
 			trigger_states = None),
 			trigger_states = None),
 		'rock_pi': binfo(
 		'rock_pi': binfo(
 			name    = 'Rock Pi (Armbian)',
 			name    = 'Rock Pi (Armbian)',
-			status  = '/sys/class/leds/status/brightness',
+			control = '/sys/class/leds/status/brightness',
 			trigger = '/sys/class/leds/status/trigger',
 			trigger = '/sys/class/leds/status/trigger',
 			trigger_states = ('none', 'heartbeat')),
 			trigger_states = ('none', 'heartbeat')),
 		'dummy': binfo(
 		'dummy': binfo(
 			name    = 'Fake',
 			name    = 'Fake',
-			status  = '/tmp/led_status',
+			control = '/tmp/led_status',
 			trigger = '/tmp/led_trigger',
 			trigger = '/tmp/led_trigger',
 			trigger_states = ('none', 'original_value')),
 			trigger_states = ('none', 'original_value')),
 	}
 	}
@@ -74,7 +74,7 @@ class LEDControl:
 			if board_id == 'dummy' and not simulate:
 			if board_id == 'dummy' and not simulate:
 				continue
 				continue
 			try:
 			try:
-				os.stat(board.status)
+				os.stat(board.control)
 			except:
 			except:
 				pass
 				pass
 			else:
 			else:
@@ -85,7 +85,7 @@ class LEDControl:
 		msg(f'{board.name} board detected')
 		msg(f'{board.name} board detected')
 
 
 		if self.debug:
 		if self.debug:
-			msg(f'\n  Status file:  {board.status}\n  Trigger file: {board.trigger}')
+			msg(f'\n  Control file:  {board.control}\n  Trigger file: {board.trigger}')
 
 
 		def check_access(fn, desc, init_val=None):
 		def check_access(fn, desc, init_val=None):
 
 
@@ -112,7 +112,7 @@ class LEDControl:
 					))
 					))
 					sys.exit(1)
 					sys.exit(1)
 
 
-		check_access(board.status, desc='status LED control')
+		check_access(board.control, desc='status LED control')
 
 
 		if board.trigger:
 		if board.trigger:
 			check_access(board.trigger, desc='LED trigger', init_val=board.trigger_states[0])
 			check_access(board.trigger, desc='LED trigger', init_val=board.trigger_states[0])
@@ -122,7 +122,7 @@ class LEDControl:
 	@classmethod
 	@classmethod
 	def create_dummy_control_files(cls):
 	def create_dummy_control_files(cls):
 		db = cls.boards['dummy']
 		db = cls.boards['dummy']
-		with open(db.status, 'w') as fp:
+		with open(db.control, 'w') as fp:
 			fp.write('0\n')
 			fp.write('0\n')
 		with open(db.trigger, 'w') as fp:
 		with open(db.trigger, 'w') as fp:
 			fp.write(db.trigger_states[1]+'\n')
 			fp.write(db.trigger_states[1]+'\n')
@@ -140,7 +140,7 @@ class LEDControl:
 			msg(f'led_loop({on_secs}, {off_secs})')
 			msg(f'led_loop({on_secs}, {off_secs})')
 
 
 		if not on_secs:
 		if not on_secs:
-			with open(self.board.status, 'w') as fp:
+			with open(self.board.control, 'w') as fp:
 				fp.write('0\n')
 				fp.write('0\n')
 			while True:
 			while True:
 				if self.ev_sleep(3600):
 				if self.ev_sleep(3600):
@@ -150,7 +150,7 @@ class LEDControl:
 			for s_time, val in ((on_secs, 255), (off_secs, 0)):
 			for s_time, val in ((on_secs, 255), (off_secs, 0)):
 				if self.debug:
 				if self.debug:
 					msg_r(('^', '+')[bool(val)])
 					msg_r(('^', '+')[bool(val)])
-				with open(self.board.status, 'w') as fp:
+				with open(self.board.control, 'w') as fp:
 					fp.write(f'{val}\n')
 					fp.write(f'{val}\n')
 				if self.ev_sleep(s_time):
 				if self.ev_sleep(s_time):
 					if self.debug:
 					if self.debug:

+ 2 - 2
test/cmdtest_d/ct_autosign.py

@@ -91,7 +91,7 @@ class CmdTestAutosignBase(CmdTestBase):
 	def __del__(self):
 	def __del__(self):
 		if hasattr(self, 'have_dummy_control_files'):
 		if hasattr(self, 'have_dummy_control_files'):
 			db = LEDControl.boards['dummy']
 			db = LEDControl.boards['dummy']
-			for fn in (db.status, db.trigger):
+			for fn in (db.control, db.trigger):
 				run(f'sudo rm -f {fn}'.split(), check=True)
 				run(f'sudo rm -f {fn}'.split(), check=True)
 
 
 		if hasattr(self, 'txdev'):
 		if hasattr(self, 'txdev'):
@@ -609,7 +609,7 @@ class CmdTestAutosign(CmdTestAutosignBase):
 			LEDControl.create_dummy_control_files()
 			LEDControl.create_dummy_control_files()
 			db = LEDControl.boards['dummy']
 			db = LEDControl.boards['dummy']
 			usrgrp = {'linux': 'root:root', 'darwin': 'root:wheel'}[sys.platform]
 			usrgrp = {'linux': 'root:root', 'darwin': 'root:wheel'}[sys.platform]
-			for fn in (db.status, db.trigger): # trigger the auto-chmod feature
+			for fn in (db.control, db.trigger): # trigger the auto-chmod feature
 				run(f'sudo chmod 644 {fn}'.split(), check=True)
 				run(f'sudo chmod 644 {fn}'.split(), check=True)
 				run(f'sudo chown {usrgrp} {fn}'.split(), check=True)
 				run(f'sudo chown {usrgrp} {fn}'.split(), check=True)
 			self.have_dummy_control_files = True
 			self.have_dummy_control_files = True