[elbe-devel] [PATCH 5/5] elbepack: clean up exception handling from PreprocessWrapper removal
Thomas Weißschuh
thomas.weissschuh at linutronix.de
Wed Jul 3 11:10:59 CEST 2024
These exceptions will not happen anymore.
Signed-off-by: Thomas Weißschuh <thomas.weissschuh at linutronix.de>
---
elbepack/initvmaction.py | 43 ++++++++++++++++++-------------------------
elbepack/pbuilderaction.py | 45 +++++++++++++++++++--------------------------
2 files changed, 37 insertions(+), 51 deletions(-)
diff --git a/elbepack/initvmaction.py b/elbepack/initvmaction.py
index 0b0af59a7c59..51a618cee431 100644
--- a/elbepack/initvmaction.py
+++ b/elbepack/initvmaction.py
@@ -452,31 +452,24 @@ def submit_with_repodir_and_dl_result(xmlfile, cdrom, opt):
def submit_and_dl_result(xmlfile, cdrom, opt):
- try:
- with preprocess_file(xmlfile, opt.variants) as xmlfile:
-
- ps = run_elbe(['control', 'create_project'], capture_output=True, encoding='utf-8')
- if ps.returncode != 0:
- print('elbe control create_project failed.', file=sys.stderr)
- print(ps.stderr, file=sys.stderr)
- print('Giving up', file=sys.stderr)
- sys.exit(128)
-
- prjdir = ps.stdout.strip()
-
- ps = run_elbe(['control', 'set_xml', prjdir, xmlfile],
- capture_output=True, encoding='utf-8')
- if ps.returncode != 0:
- print('elbe control set_xml failed2', file=sys.stderr)
- print(ps.stderr, file=sys.stderr)
- print('Giving up', file=sys.stderr)
- sys.exit(129)
- except subprocess.CalledProcessError:
- # this is the failure from PreprocessWrapper
- # it already printed the error message from
- # elbe preprocess
- print('Giving up', file=sys.stderr)
- sys.exit(130)
+ with preprocess_file(xmlfile, opt.variants) as xmlfile:
+
+ ps = run_elbe(['control', 'create_project'], capture_output=True, encoding='utf-8')
+ if ps.returncode != 0:
+ print('elbe control create_project failed.', file=sys.stderr)
+ print(ps.stderr, file=sys.stderr)
+ print('Giving up', file=sys.stderr)
+ sys.exit(128)
+
+ prjdir = ps.stdout.strip()
+
+ ps = run_elbe(['control', 'set_xml', prjdir, xmlfile],
+ capture_output=True, encoding='utf-8')
+ if ps.returncode != 0:
+ print('elbe control set_xml failed2', file=sys.stderr)
+ print(ps.stderr, file=sys.stderr)
+ print('Giving up', file=sys.stderr)
+ sys.exit(129)
if opt.writeproject:
with open(opt.writeproject, 'w') as wpf:
diff --git a/elbepack/pbuilderaction.py b/elbepack/pbuilderaction.py
index dccef0d7b8d6..32f6a38f4e34 100644
--- a/elbepack/pbuilderaction.py
+++ b/elbepack/pbuilderaction.py
@@ -68,32 +68,25 @@ class CreateAction(PBuilderAction):
ccacheopt = ['--ccache-size', opt.ccachesize]
if opt.xmlfile:
- try:
- with preprocess_file(opt.xmlfile, opt.variants) as preproc:
- ps = run_elbe(['control', 'create_project'],
- capture_output=True, encoding='utf-8')
- if ps.returncode != 0:
- print('elbe control create_project failed.',
- file=sys.stderr)
- print(ps.stderr, file=sys.stderr)
- print('Giving up', file=sys.stderr)
- sys.exit(152)
-
- prjdir = ps.stdout.strip()
- ps = run_elbe(['control', 'set_xml', prjdir, preproc],
- capture_output=True, encoding='utf-8')
-
- if ps.returncode != 0:
- print('elbe control set_xml failed.', file=sys.stderr)
- print(ps.stderr, file=sys.stderr)
- print('Giving up', file=sys.stderr)
- sys.exit(153)
- except subprocess.CalledProcessError:
- # this is the failure from PreprocessWrapper
- # it already printed the error message from
- # elbe preprocess
- print('Giving up', file=sys.stderr)
- sys.exit(154)
+ with preprocess_file(opt.xmlfile, opt.variants) as preproc:
+ ps = run_elbe(['control', 'create_project'],
+ capture_output=True, encoding='utf-8')
+ if ps.returncode != 0:
+ print('elbe control create_project failed.',
+ file=sys.stderr)
+ print(ps.stderr, file=sys.stderr)
+ print('Giving up', file=sys.stderr)
+ sys.exit(152)
+
+ prjdir = ps.stdout.strip()
+ ps = run_elbe(['control', 'set_xml', prjdir, preproc],
+ capture_output=True, encoding='utf-8')
+
+ if ps.returncode != 0:
+ print('elbe control set_xml failed.', file=sys.stderr)
+ print(ps.stderr, file=sys.stderr)
+ print('Giving up', file=sys.stderr)
+ sys.exit(153)
if opt.writeproject:
wpf = open(opt.writeproject, 'w')
--
2.45.2
More information about the elbe-devel
mailing list