Load the images for the e-paper display, scaled for display size.
(self)
| 1628 | needs_regen = False |
| 1629 | py_modules = set() |
| 1630 | for filename in os.listdir(self.actions_dir): |
| 1631 | if filename.endswith('.py') and filename != '__init__.py': |
| 1632 | py_modules.add(filename[:-3]) |
| 1633 | py_path = os.path.join(self.actions_dir, filename) |
| 1634 | if os.path.getmtime(py_path) > json_mtime: |
| 1635 | needs_regen = True |
| 1636 | |
| 1637 | if not needs_regen: |
| 1638 | # Timestamps match — but verify no modules are missing |
| 1639 | try: |
| 1640 | with open(self.actions_file, 'r') as f: |
| 1641 | existing = json.load(f) |
| 1642 | json_modules = {a.get('b_module') for a in existing} |
| 1643 | # Modules that have .py files but no JSON entry may have |
| 1644 | # been skipped due to a transient import failure. Some |
| 1645 | # .py files are intentionally excluded (helpers without |
| 1646 | # b_class/b_status), so only flag if the count differs |
| 1647 | # significantly — or specifically if critical modules |
| 1648 | # like 'scanning' are absent. |
| 1649 | missing = py_modules - json_modules |
| 1650 | if missing: |
| 1651 | logger.info(f"actions.json missing modules {missing} — regenerating") |
| 1652 | needs_regen = True |
| 1653 | except Exception as e: |
| 1654 | logger.debug(f"Could not validate actions.json contents: {e}") |
| 1655 | needs_regen = True |
| 1656 | |
| 1657 | if not needs_regen: |
| 1658 | # actions.json is up to date — just load status_list from it |
| 1659 | self._load_status_list_from_actions_json() |
| 1660 | logger.info("actions.json is up to date — skipped regeneration") |
| 1661 | return |
| 1662 | except Exception as e: |
| 1663 | logger.debug(f"Actions freshness check failed, regenerating: {e}") |
| 1664 | # Fall through: regenerate |
| 1665 | self.generate_actions_json() |
| 1666 | |
| 1667 | def generate_actions_json(self): |
| 1668 | """Generate the actions JSON file, it will be used to store the actions configuration.""" |
| 1669 | actions_dir = self.actions_dir |
| 1670 | actions_config = [] |
| 1671 | try: |
| 1672 | for filename in os.listdir(actions_dir): |
| 1673 | if filename.endswith('.py') and filename != '__init__.py': |
| 1674 | module_name = filename[:-3] |
| 1675 | try: |
| 1676 | module = importlib.import_module(f'actions.{module_name}') |
| 1677 | if getattr(module, 'BYPASS_ACTION_MODULE', False): |
| 1678 | logger.debug(f"Skipping helper module {module_name} (BYPASS_ACTION_MODULE)") |
| 1679 | continue |
| 1680 | |
| 1681 | b_class = getattr(module, 'b_class', None) |
| 1682 | b_status = getattr(module, 'b_status', None) |
| 1683 | if not b_class or not b_status: |
| 1684 | logger.debug(f"Skipping module {module_name} without action metadata") |
| 1685 | continue |
| 1686 | |
| 1687 | b_port = getattr(module, 'b_port', None) |
no test coverage detected