Skip to content

Commit

Permalink
Startup fixes of modules
Browse files Browse the repository at this point in the history
- Removed unecessary subprocess errors from logs
- Added missing library for screenshot
- Fixed boot_select default entry
- Check if module works once it's imported
  • Loading branch information
bkbilly committed Apr 28, 2023
1 parent bab41be commit 5cdac30
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 6 deletions.
7 changes: 6 additions & 1 deletion lnxlink/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@ def __init__(self, config_path):
# Run each addon included in the modules folder
self.Addons = {}
for service, addon in modules.parse_modules(self.config['modules']).items():
self.Addons[addon.service] = addon(self)
try:
tmp_addon = addon(self)
self.Addons[addon.service] = tmp_addon
except Exception as e:
print(f"Error with addon {addon.service}, please remove it from your config")
traceback.print_exc()

# Setup MQTT
self.client = mqtt.Client()
Expand Down
2 changes: 1 addition & 1 deletion lnxlink/modules/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def parse_modules(list_modules=None):
addon.service = module_name
modules[module_name] = addon
retries = -1
print(f"Successfully loaded addon: {module_name}")
print(f"Loaded addon: {module_name}")
except ModuleNotFoundError as e:
print(f"Addon {module_name} is not supported, please remove it from your config")
print(e)
Expand Down
4 changes: 3 additions & 1 deletion lnxlink/modules/boot_select.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ def getControlInfo(self):
stderr=subprocess.PIPE).stdout.decode("UTF-8")
nextentry_pattern = re.compile(r"^next_entry=(\d+)")
nextentry_match = re.match(nextentry_pattern, stdout)
entry_ind = int(nextentry_match.group(1))
entry_ind = 0
if nextentry_match:
entry_ind = int(nextentry_match.group(1))

return self.options[entry_ind]

Expand Down
6 changes: 5 additions & 1 deletion lnxlink/modules/microphone_used.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ def __init__(self, lnxlink):
self.icon = 'mdi:microphone'
self.sensor_type = 'binary_sensor'

self.use_pactl = subprocess.run(f"which pactl && pactl -f json list", shell=True).returncode == 0
self.use_pactl = subprocess.run(
f"which pactl && pactl -f json list",
shell=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE).returncode == 0


def getInfo(self):
Expand Down
5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "lnxlink"
version = "2023.4.1"
version = "2023.5.0"
description = "Internet Of Things (IOT) integration with Linux using MQTT"
readme = "README.md"
keywords = ["lnxlink"]
Expand All @@ -30,7 +30,8 @@ dependencies = [
"requests>=2.28.1",
"jc>=1.23.0",
"dbus-idle>=2023.3.2",
"opencv-python>=4.7.0.68"
"opencv-python>=4.7.0.68",
"mss>=7.0.1"
]


Expand Down

0 comments on commit 5cdac30

Please sign in to comment.