neil / rpms / anaconda

Forked from rpms/anaconda a year ago
Clone
fbcaed
From 67a9b1477ef706b6b47fc5f37d864076b653c017 Mon Sep 17 00:00:00 2001
fbcaed
From: Chris Lumens <clumens@redhat.com>
fbcaed
Date: Fri, 3 Oct 2014 11:04:35 -0400
fbcaed
Subject: [PATCH 21/21] Graphically handle errors arising from ostree repo pull
fbcaed
 problems.
fbcaed
fbcaed
This requires setting up a new glib main context as well, so ostree doesn't
fbcaed
nuke the one we're currently using and make it impossible to do anything
fbcaed
with GTK.
fbcaed
fbcaed
Resolves: rhbz#1131382
fbcaed
---
fbcaed
 pyanaconda/packaging/rpmostreepayload.py | 18 +++++++++++++++++-
fbcaed
 1 file changed, 17 insertions(+), 1 deletion(-)
fbcaed
fbcaed
diff --git a/pyanaconda/packaging/rpmostreepayload.py b/pyanaconda/packaging/rpmostreepayload.py
fbcaed
index aba85bb..8be6d3b 100644
fbcaed
--- a/pyanaconda/packaging/rpmostreepayload.py
fbcaed
+++ b/pyanaconda/packaging/rpmostreepayload.py
fbcaed
@@ -22,7 +22,9 @@
fbcaed
 
fbcaed
 import os
fbcaed
 import shutil
fbcaed
+import sys
fbcaed
 
fbcaed
+from pyanaconda import constants
fbcaed
 from pyanaconda import iutil
fbcaed
 from pyanaconda.i18n import _
fbcaed
 from pyanaconda.progress import progressQ
fbcaed
@@ -88,6 +90,9 @@ class RPMOSTreePayload(ArchivePayload):
fbcaed
             progressQ.send_message("Writing objects")
fbcaed
 
fbcaed
     def install(self):
fbcaed
+        mainctx = GLib.MainContext.new()
fbcaed
+        mainctx.push_thread_default()
fbcaed
+
fbcaed
         cancellable = None
fbcaed
         from gi.repository import OSTree
fbcaed
         ostreesetup = self.data.ostreesetup
fbcaed
@@ -120,7 +125,16 @@ class RPMOSTreePayload(ArchivePayload):
fbcaed
 
fbcaed
         progress = OSTree.AsyncProgress.new()
fbcaed
         progress.connect('changed', self._pullProgressCb)
fbcaed
-        repo.pull(ostreesetup.remote, [ostreesetup.ref], 0, progress, cancellable)
fbcaed
+
fbcaed
+        try:
fbcaed
+            repo.pull(ostreesetup.remote, [ostreesetup.ref], 0, progress, cancellable)
fbcaed
+        except GLib.GError as e:
fbcaed
+            exn = PayloadInstallError("Failed to pull from repository: %s" % e)
fbcaed
+            log.error(str(exn))
fbcaed
+            if errors.errorHandler.cb(exn) == errors.ERROR_RAISE:
fbcaed
+                progressQ.send_quit(1)
fbcaed
+                iutil.ipmi_report(constants.IPMI_ABORTED)
fbcaed
+                sys.exit(1)
fbcaed
 
fbcaed
         progressQ.send_message(_("Preparing deployment of %s") % (ostreesetup.ref, ))
fbcaed
 
fbcaed
@@ -164,6 +178,8 @@ class RPMOSTreePayload(ArchivePayload):
fbcaed
                 log.info("Copying bootloader data: " + fname)
fbcaed
                 shutil.copytree(srcpath, os.path.join(physboot, fname))
fbcaed
 
fbcaed
+        mainctx.pop_thread_default()
fbcaed
+
fbcaed
     def prepareMountTargets(self, storage):
fbcaed
         ostreesetup = self.data.ostreesetup
fbcaed
 
fbcaed
-- 
fbcaed
1.9.3
fbcaed