diff options
author | David Timber <dxdt@dev.snart.me> | 2025-04-14 19:37:42 +0200 |
---|---|---|
committer | David Timber <dxdt@dev.snart.me> | 2025-04-14 19:37:42 +0200 |
commit | c2178aa9e7af2bff38af7f62df07b0858b66abeb (patch) | |
tree | 88c7b87ef7d6268419f25ca06ce5c28a487958a4 | |
parent | c2e41c5baca02e15c1b9d282280314d3e13d4814 (diff) |
Change command invocation semantics to ...
`python -m palhm`
-rw-r--r-- | .vscode/launch.json | 28 | ||||
-rwxr-xr-x | src/palhm/__main__.py (renamed from src/palhm.py) | 14 | ||||
-rw-r--r-- | src/palhm/conf/crontab | 4 | ||||
-rw-r--r-- | src/palhm/conf/palhm-boot-report.service | 2 |
4 files changed, 24 insertions, 24 deletions
diff --git a/.vscode/launch.json b/.vscode/launch.json index 1e96b2f..a81f27b 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -8,9 +8,9 @@ "name": "palhm config", "type": "python", "request": "launch", - "cwd": "${workspaceFolder}", - "program": "src/palhm.py", - "args": [ "-f", "src/conf/py-debug/palhm.jsonc", "config" ], + "cwd": "${workspaceFolder}/src", + "module": "palhm", + "args": [ "-f", "palhm/conf/py-debug/palhm.jsonc", "config" ], "console": "integratedTerminal", "justMyCode": true }, @@ -18,8 +18,8 @@ "name": "palhm mods", "type": "python", "request": "launch", - "cwd": "${workspaceFolder}", - "program": "src/palhm.py", + "cwd": "${workspaceFolder}/src", + "module": "palhm", "args": [ "mods" ], "console": "integratedTerminal", "justMyCode": true @@ -28,9 +28,9 @@ "name": "palhm boot-report", "type": "python", "request": "launch", - "cwd": "${workspaceFolder}", - "program": "src/palhm.py", - "args": [ "-f", "src/conf/py-debug/palhm.jsonc", "boot-report" ], + "cwd": "${workspaceFolder}/src", + "module": "palhm", + "args": [ "-f", "palhm/conf/py-debug/palhm.jsonc", "boot-report" ], "console": "integratedTerminal", "justMyCode": true }, @@ -38,9 +38,9 @@ "name": "palhm run default", "type": "python", "request": "launch", - "cwd": "${workspaceFolder}", - "program": "src/palhm.py", - "args": [ "-f", "src/conf/py-debug/palhm.jsonc", "run" ], + "cwd": "${workspaceFolder}/src", + "module": "palhm", + "args": [ "-f", "palhm/conf/py-debug/palhm.jsonc", "run" ], "console": "integratedTerminal", "justMyCode": true }, @@ -48,11 +48,11 @@ "name": "palhm run check-dnssec", "type": "python", "request": "launch", - "cwd": "${workspaceFolder}", - "program": "src/palhm.py", + "cwd": "${workspaceFolder}/src", + "module": "palhm", "args": [ "-f", - "src/conf/py-debug/palhm.jsonc", + "palhm/conf/py-debug/palhm.jsonc", "run", "check-dnssec" ], diff --git a/src/palhm.py b/src/palhm/__main__.py index b0ce2d4..cdb21b7 100755 --- a/src/palhm.py +++ b/src/palhm/__main__.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python3 # Copyright (c) 2022 David Timber <dxdt@dev.snart.me> # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -41,7 +40,8 @@ class ProgConf: ProgConf.ctx.l.setLevel(ProgConf.override_vl) def err_unknown_cmd (): - sys.stderr.write("Unknown command. Run '" + sys.argv[0] + " help' for usage.\n") + sys.stderr.write( + "Unknown command. Run '" + sys.executable + " -m palhm help' for usage.\n") exit(2) class Cmd (ABC): @@ -60,7 +60,7 @@ class ConfigCmd (Cmd): def print_help (): print( -"Usage: " + sys.argv[0] + " config" + ''' +"Usage: " + sys.executable + " -m palhm config" + ''' Load and parse config. Print the structure to stdout.''') class RunCmd (Cmd): @@ -82,7 +82,7 @@ class RunCmd (Cmd): def print_help (): print( -"Usage: " + sys.argv[0] + " run [TASK]" + ''' +"Usage: " + sys.executable + " -m palhm run [TASK]" + ''' Run a task in config. Run the "''' + palhm.DEFAULT.RUN_TASK.value + '''" task if [TASK] is not specified.''') @@ -130,7 +130,7 @@ class ModsCmd (Cmd): def print_help (): print( -"Usage: " + sys.argv[0] + " mods" + ''' +"Usage: " + sys.executable + " -m palhm mods" + ''' Prints the available modules to stdout.''') class BootReportCmd (Cmd): @@ -147,7 +147,7 @@ class BootReportCmd (Cmd): def print_help (): print( -"Usage: " + sys.argv[0] + " boot-report" + ''' +"Usage: " + sys.executable + " -m palhm boot-report" + ''' Send mail of boot report to recipients configured.''') class HelpCmd (Cmd): @@ -168,7 +168,7 @@ class HelpCmd (Cmd): def print_help (): print( -"Usage: " + sys.argv[0] + " [options] CMD [command options ...]" + ''' +"Usage: " + sys.executable + " -m palhm [options] CMD [command options ...]" + ''' Options: -q Set the verbosity level to 0(CRITIAL). Overrides config -v Increase the verbosity level by 1. Overrides config diff --git a/src/palhm/conf/crontab b/src/palhm/conf/crontab index d0eeda6..9e59a16 100644 --- a/src/palhm/conf/crontab +++ b/src/palhm/conf/crontab @@ -1,6 +1,6 @@ # PALHM will produce stderr on exception. Mail the output to root MAILTO="root" # Run default task every Sunday at midnight -0 0 * * sun root /var/lib/PALHM/src/palhm.py -q run +0 0 * * sun root python -m palhm -q run # Check dnssec validity every hour -# 0 * * * * root systemd-run -qP -p User=palhm -p Nice=15 -p ProtectSystem=strict -p ReadOnlyPaths=/ -p PrivateDevices=true --wait /var/lib/PALHM/src/palhm.py -q run check-dnssec +# 0 * * * * root systemd-run -qP -p User=palhm -p Nice=15 -p ProtectSystem=strict -p ReadOnlyPaths=/ -p PrivateDevices=true --wait python -m palhm -q run check-dnssec diff --git a/src/palhm/conf/palhm-boot-report.service b/src/palhm/conf/palhm-boot-report.service index 0b4ba67..16a7c6d 100644 --- a/src/palhm/conf/palhm-boot-report.service +++ b/src/palhm/conf/palhm-boot-report.service @@ -4,7 +4,7 @@ After=postfix.service sendmail.service exim.service dovecot.service network-onli [Service] Type=oneshot -ExecStart=/var/lib/PALHM/src/palhm.py -q boot-report +ExecStart=/usr/bin/python -m palhm -q boot-report Nice=10 [Install] |