mmrelay 1.0.6__tar.gz → 1.0.7__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of mmrelay might be problematic. Click here for more details.

Files changed (39) hide show
  1. {mmrelay-1.0.6 → mmrelay-1.0.7}/MANIFEST.in +1 -0
  2. {mmrelay-1.0.6/src/mmrelay.egg-info → mmrelay-1.0.7}/PKG-INFO +2 -2
  3. {mmrelay-1.0.6 → mmrelay-1.0.7}/README.md +1 -1
  4. {mmrelay-1.0.6 → mmrelay-1.0.7}/setup.cfg +4 -1
  5. {mmrelay-1.0.6 → mmrelay-1.0.7}/src/mmrelay/cli.py +54 -16
  6. {mmrelay-1.0.6 → mmrelay-1.0.7}/src/mmrelay/setup_utils.py +137 -8
  7. mmrelay-1.0.7/src/mmrelay/tools/__init__.py +28 -0
  8. {mmrelay-1.0.6 → mmrelay-1.0.7/src/mmrelay}/tools/mmrelay.service +1 -1
  9. {mmrelay-1.0.6 → mmrelay-1.0.7/src/mmrelay.egg-info}/PKG-INFO +2 -2
  10. {mmrelay-1.0.6 → mmrelay-1.0.7}/src/mmrelay.egg-info/SOURCES.txt +3 -2
  11. {mmrelay-1.0.6 → mmrelay-1.0.7}/LICENSE +0 -0
  12. {mmrelay-1.0.6 → mmrelay-1.0.7}/pyproject.toml +0 -0
  13. {mmrelay-1.0.6 → mmrelay-1.0.7}/requirements.txt +0 -0
  14. {mmrelay-1.0.6 → mmrelay-1.0.7}/src/mmrelay/__init__.py +0 -0
  15. {mmrelay-1.0.6 → mmrelay-1.0.7}/src/mmrelay/config.py +0 -0
  16. {mmrelay-1.0.6 → mmrelay-1.0.7}/src/mmrelay/config_checker.py +0 -0
  17. {mmrelay-1.0.6 → mmrelay-1.0.7}/src/mmrelay/db_utils.py +0 -0
  18. {mmrelay-1.0.6 → mmrelay-1.0.7}/src/mmrelay/log_utils.py +0 -0
  19. {mmrelay-1.0.6 → mmrelay-1.0.7}/src/mmrelay/main.py +0 -0
  20. {mmrelay-1.0.6 → mmrelay-1.0.7}/src/mmrelay/matrix_utils.py +0 -0
  21. {mmrelay-1.0.6 → mmrelay-1.0.7}/src/mmrelay/meshtastic_utils.py +0 -0
  22. {mmrelay-1.0.6 → mmrelay-1.0.7}/src/mmrelay/plugin_loader.py +0 -0
  23. {mmrelay-1.0.6 → mmrelay-1.0.7}/src/mmrelay/plugins/__init__.py +0 -0
  24. {mmrelay-1.0.6 → mmrelay-1.0.7}/src/mmrelay/plugins/base_plugin.py +0 -0
  25. {mmrelay-1.0.6 → mmrelay-1.0.7}/src/mmrelay/plugins/debug_plugin.py +0 -0
  26. {mmrelay-1.0.6 → mmrelay-1.0.7}/src/mmrelay/plugins/drop_plugin.py +0 -0
  27. {mmrelay-1.0.6 → mmrelay-1.0.7}/src/mmrelay/plugins/health_plugin.py +0 -0
  28. {mmrelay-1.0.6 → mmrelay-1.0.7}/src/mmrelay/plugins/help_plugin.py +0 -0
  29. {mmrelay-1.0.6 → mmrelay-1.0.7}/src/mmrelay/plugins/map_plugin.py +0 -0
  30. {mmrelay-1.0.6 → mmrelay-1.0.7}/src/mmrelay/plugins/mesh_relay_plugin.py +0 -0
  31. {mmrelay-1.0.6 → mmrelay-1.0.7}/src/mmrelay/plugins/nodes_plugin.py +0 -0
  32. {mmrelay-1.0.6 → mmrelay-1.0.7}/src/mmrelay/plugins/ping_plugin.py +0 -0
  33. {mmrelay-1.0.6 → mmrelay-1.0.7}/src/mmrelay/plugins/telemetry_plugin.py +0 -0
  34. {mmrelay-1.0.6 → mmrelay-1.0.7}/src/mmrelay/plugins/weather_plugin.py +0 -0
  35. {mmrelay-1.0.6 → mmrelay-1.0.7/src/mmrelay/tools}/sample_config.yaml +0 -0
  36. {mmrelay-1.0.6 → mmrelay-1.0.7}/src/mmrelay.egg-info/dependency_links.txt +0 -0
  37. {mmrelay-1.0.6 → mmrelay-1.0.7}/src/mmrelay.egg-info/entry_points.txt +0 -0
  38. {mmrelay-1.0.6 → mmrelay-1.0.7}/src/mmrelay.egg-info/requires.txt +0 -0
  39. {mmrelay-1.0.6 → mmrelay-1.0.7}/src/mmrelay.egg-info/top_level.txt +0 -0
@@ -3,3 +3,4 @@ include README.md
3
3
  include requirements.txt
4
4
  include sample_config.yaml
5
5
  recursive-include tools *
6
+ recursive-include src/mmrelay/tools *
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mmrelay
3
- Version: 1.0.6
3
+ Version: 1.0.7
4
4
  Summary: Bridge between Meshtastic mesh networks and Matrix chat rooms
5
5
  Home-page: https://github.com/geoffwhittington/meshtastic-matrix-relay
6
6
  Author: Geoff Whittington, Jeremiah K., and contributors
@@ -68,7 +68,7 @@ For pipx installation instructions, see: [pipx installation guide](https://pipx.
68
68
 
69
69
  - **New Users**: See [INSTRUCTIONS.md](INSTRUCTIONS.md) for setup and configuration
70
70
  - **Existing Users**: See [UPGRADE_TO_V1.md](UPGRADE_TO_V1.md) for migration guidance
71
- - **Configuration**: Review [sample_config.yaml](sample_config.yaml) for examples
71
+ - **Configuration**: Review [sample_config.yaml](src/mmrelay/tools/sample_config.yaml) for examples
72
72
 
73
73
  ### Command-Line Options
74
74
 
@@ -38,7 +38,7 @@ For pipx installation instructions, see: [pipx installation guide](https://pipx.
38
38
 
39
39
  - **New Users**: See [INSTRUCTIONS.md](INSTRUCTIONS.md) for setup and configuration
40
40
  - **Existing Users**: See [UPGRADE_TO_V1.md](UPGRADE_TO_V1.md) for migration guidance
41
- - **Configuration**: Review [sample_config.yaml](sample_config.yaml) for examples
41
+ - **Configuration**: Review [sample_config.yaml](src/mmrelay/tools/sample_config.yaml) for examples
42
42
 
43
43
  ### Command-Line Options
44
44
 
@@ -1,6 +1,6 @@
1
1
  [metadata]
2
2
  name = mmrelay
3
- version = 1.0.6
3
+ version = 1.0.7
4
4
  author = Geoff Whittington, Jeremiah K., and contributors
5
5
  author_email = jeremiahk@gmx.com
6
6
  description = Bridge between Meshtastic mesh networks and Matrix chat rooms
@@ -39,6 +39,9 @@ include_package_data = True
39
39
  [options.packages.find]
40
40
  where = src
41
41
 
42
+ [options.package_data]
43
+ mmrelay.tools = *.yaml, *.service
44
+
42
45
  [options.entry_points]
43
46
  console_scripts =
44
47
  mmrelay = mmrelay.cli:main
@@ -3,6 +3,7 @@ Command-line interface handling for the Meshtastic Matrix Relay.
3
3
  """
4
4
 
5
5
  import argparse
6
+ import importlib.resources
6
7
  import os
7
8
  import sys
8
9
 
@@ -11,6 +12,7 @@ from yaml.loader import SafeLoader
11
12
 
12
13
  # Import version from package
13
14
  from mmrelay import __version__
15
+ from mmrelay.tools import get_sample_config_path
14
16
 
15
17
 
16
18
  def parse_arguments():
@@ -363,29 +365,65 @@ def generate_sample_config():
363
365
  # Ensure the directory exists
364
366
  os.makedirs(os.path.dirname(target_path), exist_ok=True)
365
367
 
366
- # Try to find the sample config file
367
- # First, check in the package directory
368
- package_dir = os.path.dirname(__file__)
369
- sample_config_path = os.path.join(
370
- os.path.dirname(os.path.dirname(package_dir)), "sample_config.yaml"
371
- )
368
+ # Use the helper function to get the sample config path
369
+ sample_config_path = get_sample_config_path()
372
370
 
373
- # If not found, try the repository root
374
- if not os.path.exists(sample_config_path):
375
- repo_root = os.path.dirname(os.path.dirname(__file__))
376
- sample_config_path = os.path.join(repo_root, "sample_config.yaml")
371
+ if os.path.exists(sample_config_path):
372
+ # Copy the sample config file to the target path
373
+ import shutil
377
374
 
378
- # If still not found, try the current directory
379
- if not os.path.exists(sample_config_path):
380
- sample_config_path = os.path.join(os.getcwd(), "sample_config.yaml")
375
+ shutil.copy2(sample_config_path, target_path)
376
+ print(f"Generated sample config file at: {target_path}")
377
+ print(
378
+ "\nEdit this file with your Matrix and Meshtastic settings before running mmrelay."
379
+ )
380
+ return True
381
+
382
+ # If the helper function failed, try using importlib.resources directly
383
+ try:
384
+ # Try to get the sample config from the package resources
385
+ sample_config_content = (
386
+ importlib.resources.files("mmrelay.tools")
387
+ .joinpath("sample_config.yaml")
388
+ .read_text()
389
+ )
390
+
391
+ # Write the sample config to the target path
392
+ with open(target_path, "w") as f:
393
+ f.write(sample_config_content)
381
394
 
382
- if os.path.exists(sample_config_path):
383
- shutil.copy(sample_config_path, target_path)
384
395
  print(f"Generated sample config file at: {target_path}")
385
396
  print(
386
397
  "\nEdit this file with your Matrix and Meshtastic settings before running mmrelay."
387
398
  )
388
399
  return True
389
- else:
400
+ except (FileNotFoundError, ImportError, OSError) as e:
401
+ print(f"Error accessing sample_config.yaml: {e}")
402
+
403
+ # Fallback to traditional file paths if importlib.resources fails
404
+ # First, check in the package directory
405
+ package_dir = os.path.dirname(__file__)
406
+ sample_config_paths = [
407
+ # Check in the tools subdirectory of the package
408
+ os.path.join(package_dir, "tools", "sample_config.yaml"),
409
+ # Check in the package directory
410
+ os.path.join(package_dir, "sample_config.yaml"),
411
+ # Check in the repository root
412
+ os.path.join(
413
+ os.path.dirname(os.path.dirname(package_dir)), "sample_config.yaml"
414
+ ),
415
+ # Check in the current directory
416
+ os.path.join(os.getcwd(), "sample_config.yaml"),
417
+ ]
418
+
419
+ for path in sample_config_paths:
420
+ if os.path.exists(path):
421
+ shutil.copy(path, target_path)
422
+ print(f"Generated sample config file at: {target_path}")
423
+ print(
424
+ "\nEdit this file with your Matrix and Meshtastic settings before running mmrelay."
425
+ )
426
+ return True
427
+
390
428
  print("Error: Could not find sample_config.yaml")
391
429
  return False
@@ -5,6 +5,8 @@ This module provides simple functions for managing the systemd user service
5
5
  and generating configuration files.
6
6
  """
7
7
 
8
+ import importlib.resources
9
+
8
10
  # Import version from package
9
11
  import os
10
12
  import shutil
@@ -12,6 +14,8 @@ import subprocess
12
14
  import sys
13
15
  from pathlib import Path
14
16
 
17
+ from mmrelay.tools import get_service_template_path
18
+
15
19
 
16
20
  def get_executable_path():
17
21
  """Get the full path to the mmrelay executable.
@@ -103,16 +107,31 @@ def get_template_service_path():
103
107
  os.path.join(sys.prefix, "share", "mmrelay", "mmrelay.service"),
104
108
  os.path.join(sys.prefix, "share", "mmrelay", "tools", "mmrelay.service"),
105
109
  # Check in the user site-packages location
106
- os.path.join(os.path.expanduser("~"), ".local", "share", "mmrelay", "mmrelay.service"),
107
- os.path.join(os.path.expanduser("~"), ".local", "share", "mmrelay", "tools", "mmrelay.service"),
110
+ os.path.join(
111
+ os.path.expanduser("~"), ".local", "share", "mmrelay", "mmrelay.service"
112
+ ),
113
+ os.path.join(
114
+ os.path.expanduser("~"),
115
+ ".local",
116
+ "share",
117
+ "mmrelay",
118
+ "tools",
119
+ "mmrelay.service",
120
+ ),
108
121
  # Check one level up from the package directory
109
122
  os.path.join(os.path.dirname(package_dir), "tools", "mmrelay.service"),
110
123
  # Check two levels up from the package directory (for development)
111
- os.path.join(os.path.dirname(os.path.dirname(package_dir)), "tools", "mmrelay.service"),
124
+ os.path.join(
125
+ os.path.dirname(os.path.dirname(package_dir)), "tools", "mmrelay.service"
126
+ ),
112
127
  # Check in the repository root (for development)
113
- os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), "tools", "mmrelay.service"),
128
+ os.path.join(
129
+ os.path.dirname(os.path.dirname(os.path.dirname(__file__))),
130
+ "tools",
131
+ "mmrelay.service",
132
+ ),
114
133
  # Check in the current directory (fallback)
115
- os.path.join(os.getcwd(), "tools", "mmrelay.service")
134
+ os.path.join(os.getcwd(), "tools", "mmrelay.service"),
116
135
  ]
117
136
 
118
137
  # Try each path until we find one that exists
@@ -136,8 +155,10 @@ def get_template_service_content():
136
155
  Returns:
137
156
  str: The content of the template service file, or a default template if not found.
138
157
  """
139
- template_path = get_template_service_path()
140
- if template_path:
158
+ # Use the helper function to get the service template path
159
+ template_path = get_service_template_path()
160
+
161
+ if template_path and os.path.exists(template_path):
141
162
  # Read the template from file
142
163
  try:
143
164
  with open(template_path, "r") as f:
@@ -146,6 +167,28 @@ def get_template_service_content():
146
167
  except Exception as e:
147
168
  print(f"Error reading service template file: {e}")
148
169
 
170
+ # If the helper function failed, try using importlib.resources directly
171
+ try:
172
+ service_template = (
173
+ importlib.resources.files("mmrelay.tools")
174
+ .joinpath("mmrelay.service")
175
+ .read_text()
176
+ )
177
+ return service_template
178
+ except (FileNotFoundError, ImportError, OSError) as e:
179
+ print(f"Error accessing mmrelay.service via importlib.resources: {e}")
180
+
181
+ # Fall back to the file path method
182
+ template_path = get_template_service_path()
183
+ if template_path:
184
+ # Read the template from file
185
+ try:
186
+ with open(template_path, "r") as f:
187
+ service_template = f.read()
188
+ return service_template
189
+ except Exception as e:
190
+ print(f"Error reading service template file: {e}")
191
+
149
192
  # If we couldn't find or read the template file, use a default template
150
193
  print("Using default service template")
151
194
  return """[Unit]
@@ -154,7 +197,7 @@ After=network-online.target
154
197
  Wants=network-online.target
155
198
 
156
199
  [Service]
157
- Type=idle
200
+ Type=simple
158
201
  # The mmrelay binary can be installed via pipx or pip
159
202
  ExecStart=%h/.local/bin/mmrelay --config %h/.mmrelay/config.yaml --logfile %h/.mmrelay/logs/mmrelay.log
160
203
  WorkingDirectory=%h/.mmrelay
@@ -310,6 +353,69 @@ def service_needs_update():
310
353
  return False, "Service file is up to date"
311
354
 
312
355
 
356
+ def check_loginctl_available():
357
+ """Check if loginctl is available on the system.
358
+
359
+ Returns:
360
+ bool: True if loginctl is available, False otherwise.
361
+ """
362
+ try:
363
+ result = subprocess.run(
364
+ ["which", "loginctl"],
365
+ check=False,
366
+ capture_output=True,
367
+ text=True,
368
+ )
369
+ return result.returncode == 0
370
+ except Exception:
371
+ return False
372
+
373
+
374
+ def check_lingering_enabled():
375
+ """Check if user lingering is enabled.
376
+
377
+ Returns:
378
+ bool: True if lingering is enabled, False otherwise.
379
+ """
380
+ try:
381
+ username = os.environ.get("USER", os.environ.get("USERNAME"))
382
+ result = subprocess.run(
383
+ ["loginctl", "show-user", username, "--property=Linger"],
384
+ check=False,
385
+ capture_output=True,
386
+ text=True,
387
+ )
388
+ return result.returncode == 0 and "Linger=yes" in result.stdout
389
+ except Exception:
390
+ return False
391
+
392
+
393
+ def enable_lingering():
394
+ """Enable user lingering using sudo.
395
+
396
+ Returns:
397
+ bool: True if lingering was enabled successfully, False otherwise.
398
+ """
399
+ try:
400
+ username = os.environ.get("USER", os.environ.get("USERNAME"))
401
+ print(f"Enabling lingering for user {username}...")
402
+ result = subprocess.run(
403
+ ["sudo", "loginctl", "enable-linger", username],
404
+ check=False,
405
+ capture_output=True,
406
+ text=True,
407
+ )
408
+ if result.returncode == 0:
409
+ print("Lingering enabled successfully")
410
+ return True
411
+ else:
412
+ print(f"Error enabling lingering: {result.stderr}")
413
+ return False
414
+ except Exception as e:
415
+ print(f"Error enabling lingering: {e}")
416
+ return False
417
+
418
+
313
419
  def install_service():
314
420
  """Install or update the MMRelay user service."""
315
421
  # Check if service already exists
@@ -355,6 +461,27 @@ def install_service():
355
461
 
356
462
  # We don't need to validate the config here as it will be validated when the service starts
357
463
 
464
+ # Check if loginctl is available
465
+ loginctl_available = check_loginctl_available()
466
+ if loginctl_available:
467
+ # Check if user lingering is enabled
468
+ lingering_enabled = check_lingering_enabled()
469
+ if not lingering_enabled:
470
+ print(
471
+ "\nUser lingering is not enabled. This is required for the service to start automatically at boot."
472
+ )
473
+ print(
474
+ "Lingering allows user services to run even when you're not logged in."
475
+ )
476
+ if (
477
+ input(
478
+ "Do you want to enable lingering for your user? (requires sudo) (y/n): "
479
+ )
480
+ .lower()
481
+ .startswith("y")
482
+ ):
483
+ enable_lingering()
484
+
358
485
  # Check if the service is already enabled
359
486
  service_enabled = is_service_enabled()
360
487
  if service_enabled:
@@ -417,6 +544,8 @@ def install_service():
417
544
  print("\nService Status Summary:")
418
545
  print(f" Service File: {service_path}")
419
546
  print(f" Enabled at Boot: {'Yes' if service_enabled else 'No'}")
547
+ if loginctl_available:
548
+ print(f" User Lingering: {'Yes' if check_lingering_enabled() else 'No'}")
420
549
  print(f" Currently Running: {'Yes' if is_service_active() else 'No'}")
421
550
  print("\nService Management Commands:")
422
551
  print_service_commands()
@@ -0,0 +1,28 @@
1
+ """Tools and resources for MMRelay."""
2
+
3
+ import importlib.resources
4
+ import pathlib
5
+
6
+
7
+ def get_sample_config_path():
8
+ """Get the path to the sample config file."""
9
+ try:
10
+ # For Python 3.9+
11
+ return str(
12
+ importlib.resources.files("mmrelay.tools").joinpath("sample_config.yaml")
13
+ )
14
+ except AttributeError:
15
+ # Fallback for older Python versions
16
+ return str(pathlib.Path(__file__).parent / "sample_config.yaml")
17
+
18
+
19
+ def get_service_template_path():
20
+ """Get the path to the service template file."""
21
+ try:
22
+ # For Python 3.9+
23
+ return str(
24
+ importlib.resources.files("mmrelay.tools").joinpath("mmrelay.service")
25
+ )
26
+ except AttributeError:
27
+ # Fallback for older Python versions
28
+ return str(pathlib.Path(__file__).parent / "mmrelay.service")
@@ -4,7 +4,7 @@ After=network-online.target
4
4
  Wants=network-online.target
5
5
 
6
6
  [Service]
7
- Type=idle
7
+ Type=simple
8
8
  # The mmrelay binary can be installed via pipx or pip
9
9
  ExecStart=%h/.local/bin/mmrelay --config %h/.mmrelay/config.yaml --logfile %h/.mmrelay/logs/mmrelay.log
10
10
  WorkingDirectory=%h/.mmrelay
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mmrelay
3
- Version: 1.0.6
3
+ Version: 1.0.7
4
4
  Summary: Bridge between Meshtastic mesh networks and Matrix chat rooms
5
5
  Home-page: https://github.com/geoffwhittington/meshtastic-matrix-relay
6
6
  Author: Geoff Whittington, Jeremiah K., and contributors
@@ -68,7 +68,7 @@ For pipx installation instructions, see: [pipx installation guide](https://pipx.
68
68
 
69
69
  - **New Users**: See [INSTRUCTIONS.md](INSTRUCTIONS.md) for setup and configuration
70
70
  - **Existing Users**: See [UPGRADE_TO_V1.md](UPGRADE_TO_V1.md) for migration guidance
71
- - **Configuration**: Review [sample_config.yaml](sample_config.yaml) for examples
71
+ - **Configuration**: Review [sample_config.yaml](src/mmrelay/tools/sample_config.yaml) for examples
72
72
 
73
73
  ### Command-Line Options
74
74
 
@@ -3,7 +3,6 @@ MANIFEST.in
3
3
  README.md
4
4
  pyproject.toml
5
5
  requirements.txt
6
- sample_config.yaml
7
6
  setup.cfg
8
7
  src/mmrelay/__init__.py
9
8
  src/mmrelay/cli.py
@@ -34,4 +33,6 @@ src/mmrelay/plugins/nodes_plugin.py
34
33
  src/mmrelay/plugins/ping_plugin.py
35
34
  src/mmrelay/plugins/telemetry_plugin.py
36
35
  src/mmrelay/plugins/weather_plugin.py
37
- tools/mmrelay.service
36
+ src/mmrelay/tools/__init__.py
37
+ src/mmrelay/tools/mmrelay.service
38
+ src/mmrelay/tools/sample_config.yaml
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes