Skip to content

Commit

Permalink
Supported registering a systemd service.
Browse files Browse the repository at this point in the history
  • Loading branch information
ATATC committed Dec 30, 2023
1 parent 177d7cd commit 16a7271
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions leads_vec/__main__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from argparse import ArgumentParser as _ArgumentParser
from platform import system as _system
from sys import exit as _exit

from leads_vec.config import load_config as _load_config, DEFAULT_CONFIG as _DEFAULT_CONFIG
Expand All @@ -7,13 +8,23 @@
parser = _ArgumentParser(prog="LEADS",
description="Lightweight Embedded Assisted Driving System",
epilog="GitHub: https://github.com/ProjectNeura/LEADS")
parser.add_argument("-c", "--config", default=None, help="configuration file")
parser.add_argument("-r", "--register", choices=("systemd", "script"), default=None, help="service to register")
parser.add_argument("-c", "--config", default=None, help="specified configuration file")
args = parser.parse_args()
if args.register == "systemd":
if _system().lower() != "linux":
_exit("ERROR: Unsupported operating system")
from ._bootloader import create_service

create_service()
_exit()
if args.register == "script":
_exit()
try:
from leads_emulation import SRWRandom as _Controller
except ImportError:
raise ImportError("At least one adapter has to be installed")
args = parser.parse_args()
config = _load_config(args.config) if args.config else _DEFAULT_CONFIG
from leads_vec.cli import main as _main
from leads_vec.cli import main

_exit(_main(_Controller("main"), config))
_exit(main(_Controller("main"), config))

0 comments on commit 16a7271

Please sign in to comment.