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

View file

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

View file

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

View file

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