runner: use osbuild.api.exception_handler

Wrap all calls to the various setup functions in the new exception
handler provided by `osbuild.api`. This will make sure that any
exception is properly printed to stderr, as well as communicated
to osbuild in a structured and machine readable way.
This commit is contained in:
Christian Kellner 2020-10-07 16:31:07 +02:00
parent 71f7bf8930
commit 0e6b4749f7
4 changed files with 39 additions and 27 deletions

View file

@ -4,6 +4,8 @@ import os
import subprocess import subprocess
import sys import sys
import osbuild.api
def ldconfig(): def ldconfig():
# ld.so.conf must exist, or `ldconfig` throws a warning # ld.so.conf must exist, or `ldconfig` throws a warning
@ -36,10 +38,11 @@ def nsswitch():
if __name__ == "__main__": if __name__ == "__main__":
ldconfig() with osbuild.api.exception_handler():
sysusers() ldconfig()
tmpfiles() sysusers()
nsswitch() tmpfiles()
nsswitch()
r = subprocess.run(sys.argv[1:], check=False) r = subprocess.run(sys.argv[1:], check=False)
sys.exit(r.returncode) sys.exit(r.returncode)

View file

@ -4,6 +4,8 @@ import os
import subprocess import subprocess
import sys import sys
import osbuild.api
def ldconfig(): def ldconfig():
# ld.so.conf must exist, or `ldconfig` throws a warning # ld.so.conf must exist, or `ldconfig` throws a warning
@ -70,12 +72,13 @@ def python_alternatives():
pass pass
if __name__ == "__main__": if __name__ == "__main__":
ldconfig() with osbuild.api.exception_handler():
sysusers() ldconfig()
tmpfiles() sysusers()
nsswitch() tmpfiles()
os_release() nsswitch()
python_alternatives() os_release()
python_alternatives()
r = subprocess.run(sys.argv[1:], check=False) r = subprocess.run(sys.argv[1:], check=False)
sys.exit(r.returncode) sys.exit(r.returncode)

View file

@ -4,6 +4,8 @@ import os
import subprocess import subprocess
import sys import sys
import osbuild.api
def ldconfig(): def ldconfig():
# ld.so.conf must exist, or `ldconfig` throws a warning # ld.so.conf must exist, or `ldconfig` throws a warning
@ -48,11 +50,12 @@ def python_alternatives():
pass pass
if __name__ == "__main__": if __name__ == "__main__":
ldconfig() with osbuild.api.exception_handler():
sysusers() ldconfig()
tmpfiles() sysusers()
nsswitch() tmpfiles()
python_alternatives() nsswitch()
python_alternatives()
r = subprocess.run(sys.argv[1:], check=False) r = subprocess.run(sys.argv[1:], check=False)
sys.exit(r.returncode) sys.exit(r.returncode)

View file

@ -4,6 +4,8 @@ import os
import subprocess import subprocess
import sys import sys
import osbuild.api
def ldconfig(): def ldconfig():
# ld.so.conf must exist, or `ldconfig` throws a warning # ld.so.conf must exist, or `ldconfig` throws a warning
@ -36,10 +38,11 @@ def nsswitch():
if __name__ == "__main__": if __name__ == "__main__":
ldconfig() with osbuild.api.exception_handler():
sysusers() ldconfig()
tmpfiles() sysusers()
nsswitch() tmpfiles()
nsswitch()
r = subprocess.run(sys.argv[1:], check=False) r = subprocess.run(sys.argv[1:], check=False)
sys.exit(r.returncode) sys.exit(r.returncode)