mirror of
https://git.yoctoproject.org/poky
synced 2026-05-31 12:49:46 +00:00
systemctl: Stop tracebacks use formated error messages
When systemctl fail it would throw an exception and dump a traceback. Lets use a more controlled workflow. [Yocto #14395] (From OE-Core rev: df510ae9a1494bc1be8d6673fbaa43d3f7cc8f40) Signed-off-by: Armin Kuster <akuster808@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
13ed11d909
commit
20026c7246
@@ -160,7 +160,9 @@ def add_link(path, target):
|
|||||||
|
|
||||||
|
|
||||||
class SystemdUnitNotFoundError(Exception):
|
class SystemdUnitNotFoundError(Exception):
|
||||||
pass
|
def __init__(self, path, unit):
|
||||||
|
self.path = path
|
||||||
|
self.unit = unit
|
||||||
|
|
||||||
|
|
||||||
class SystemdUnit():
|
class SystemdUnit():
|
||||||
@@ -224,7 +226,10 @@ class SystemdUnit():
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
for also in config.get('Install', 'Also'):
|
for also in config.get('Install', 'Also'):
|
||||||
SystemdUnit(self.root, also).enable()
|
try:
|
||||||
|
SystemdUnit(self.root, also).enable()
|
||||||
|
except SystemdUnitNotFoundError as e:
|
||||||
|
sys.exit("Error: Systemctl also enable issue with %s (%s)" % (service, e.unit))
|
||||||
|
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
@@ -265,7 +270,10 @@ def preset_all(root):
|
|||||||
state = presets.state(service)
|
state = presets.state(service)
|
||||||
|
|
||||||
if state == "enable" or state is None:
|
if state == "enable" or state is None:
|
||||||
SystemdUnit(root, service).enable()
|
try:
|
||||||
|
SystemdUnit(root, service).enable()
|
||||||
|
except SystemdUnitNotFoundError:
|
||||||
|
sys.exit("Error: Systemctl preset_all issue in %s" % service)
|
||||||
|
|
||||||
# If we populate the systemd links we also create /etc/machine-id, which
|
# If we populate the systemd links we also create /etc/machine-id, which
|
||||||
# allows systemd to boot with the filesystem read-only before generating
|
# allows systemd to boot with the filesystem read-only before generating
|
||||||
@@ -307,10 +315,16 @@ def main():
|
|||||||
|
|
||||||
if command == "mask":
|
if command == "mask":
|
||||||
for service in args.service:
|
for service in args.service:
|
||||||
SystemdUnit(root, service).mask()
|
try:
|
||||||
|
SystemdUnit(root, service).mask()
|
||||||
|
except SystemdUnitNotFoundError as e:
|
||||||
|
sys.exit("Error: Systemctl main mask issue in %s (%s)" % (service, e.unit))
|
||||||
elif command == "enable":
|
elif command == "enable":
|
||||||
for service in args.service:
|
for service in args.service:
|
||||||
SystemdUnit(root, service).enable()
|
try:
|
||||||
|
SystemdUnit(root, service).enable()
|
||||||
|
except SystemdUnitNotFoundError as e:
|
||||||
|
sys.exit("Error: Systemctl main enable issue in %s (%s)" % (service, e.unit))
|
||||||
elif command == "preset-all":
|
elif command == "preset-all":
|
||||||
if len(args.service) != 0:
|
if len(args.service) != 0:
|
||||||
sys.exit("Too many arguments.")
|
sys.exit("Too many arguments.")
|
||||||
|
|||||||
Reference in New Issue
Block a user