summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2019-06-25 09:44:40 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2019-06-25 09:47:37 -0700
commit610342bd3b5154e0bf2fe741efe42235ab602bf2 (patch)
tree66e2d4ce1cecf21ad0222f86564f1974f3fce906
parentfdbdc97b7f7bace8df63f11d452de4ff26567e6d (diff)
downloadchef-610342bd3b5154e0bf2fe741efe42235ab602bf2.tar.gz
yum exception handling improvementslcg/yum-exception-handling
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
-rw-r--r--lib/chef/provider/package/yum/yum_helper.py51
1 files changed, 27 insertions, 24 deletions
diff --git a/lib/chef/provider/package/yum/yum_helper.py b/lib/chef/provider/package/yum/yum_helper.py
index 7e99951555..8f41b6d188 100644
--- a/lib/chef/provider/package/yum/yum_helper.py
+++ b/lib/chef/provider/package/yum/yum_helper.py
@@ -185,27 +185,30 @@ else:
inpipe = os.fdopen(int(sys.argv[1]), "r")
outpipe = os.fdopen(int(sys.argv[2]), "w")
-while 1:
- # kill self if we get orphaned (tragic)
- ppid = os.getppid()
- if ppid == 1:
- sys.exit(0)
- setup_exit_handler()
- line = inpipe.readline()
-
- try:
- command = json.loads(line)
- except ValueError, e:
- base.closeRpmDB()
- sys.exit(0)
-
- if command['action'] == "whatinstalled":
- query(command)
- elif command['action'] == "whatavailable":
- query(command)
- elif command['action'] == "versioncompare":
- versioncompare(command['versions'])
- elif command['action'] == "installonlypkgs":
- install_only_packages(command['package'])
- else:
- raise RuntimeError("bad command")
+try:
+ while 1:
+ # kill self if we get orphaned (tragic)
+ ppid = os.getppid()
+ if ppid == 1:
+ raise RuntimeError("orphaned")
+
+ setup_exit_handler()
+ line = inpipe.readline()
+
+ try:
+ command = json.loads(line)
+ except ValueError, e:
+ raise RuntimeError("bad json parse")
+
+ if command['action'] == "whatinstalled":
+ query(command)
+ elif command['action'] == "whatavailable":
+ query(command)
+ elif command['action'] == "versioncompare":
+ versioncompare(command['versions'])
+ elif command['action'] == "installonlypkgs":
+ install_only_packages(command['package'])
+ else:
+ raise RuntimeError("bad command")
+finally:
+ base.closeRpmDB()