[firstboot] [PATCHv2] Don't crash firstboot with python-meh's Gtk3 UI (#849118)
Vratislav Podzimek
vpodzime at redhat.com
Wed Aug 22 17:37:16 UTC 2012
We can replace python-meh's handler with our simple handler creating
directory ABRT needs for reporting bug and running /usr/bin/setup, so
that user can create user account and login.
---
progs/firstboot | 58 +++++++++++++++++++++++++++++++++++++++++++++------------
1 file changed, 46 insertions(+), 12 deletions(-)
diff --git a/progs/firstboot b/progs/firstboot
index 1ad7e31..e45fb8c 100755
--- a/progs/firstboot
+++ b/progs/firstboot
@@ -36,20 +36,63 @@ from firstboot.constants import *
from firstboot.config import *
import meh
-import meh.handler
import meh.dump
+import gettext
+_ = lambda x: gettext.ldgettext("firstboot", x)
-def exception_handler(type, value, tb):
+def exception_handler(type, value, tb, obj):
+ # write exception to a file
fd, path = tempfile.mkstemp(prefix='firstboot-', suffix='.trace')
fo = os.fdopen(fd, 'w')
traceback.print_exception(type, value, tb, None, fo)
fo.close()
-sys.excepthook = exception_handler
+ meh_conf = meh.Config(programName='firstboot',
+ programVersion='@VERSION@')
+
+ dump_obj = meh.dump.ExceptionDump((type, value, tb), meh_conf)
+ exn_dump = dump_obj.traceback_and_object_dump(obj)
+
+ fd, path = tempfile.mkstemp(prefix='firstboot-tb-')
+ fo = os.fdopen(fd, 'w')
+ fo.write(exn_dump)
+ fo.close()
+
+ # that's basically what python-meh's Save button does, except that the
+ # following code just creates directories ABRT wants for reporting bug
+ import report
+ params = dict()
+ params.update(dump_obj.environment_info)
+
+ params.setdefault('component', 'firstboot')
+ params.setdefault('package', 'firstboot- at VERSION@')
+
+ params['hashmarkername'] = 'firstboot'
+ params['duphash'] = dump_obj.hash
+ params['reason'] = dump_obj.desc
+ params['description'] = 'Traceback from firstboot:\n%s' % str(dump_obj)
+ params['firstboot-tb'] = exn_dump
+ params['uid'] = "%d" % os.geteuid()
+
+ problem_data = report.createPythonUnhandledExceptionSignature(**params)
+
+ problem_data.create_dump_dir('/var/spool/abrt')
+
+ print _('Unhandled exception in firstboot occured.')
+ print _('Bugreport directory was created and once you login, ABRT should\n'
+ 'let you file a bug.')
+ answer = raw_input (_('Do you want to start /usr/bin/setup so that you can\n'
+ 'create your user account? [Y/n] '))
+
+ if not answer.lower() in [_('n'), _('no')]:
+ os.system('/usr/bin/setup')
if __name__ == '__main__':
+ # set up exception handling first
+ sys.excepthook = lambda ty, value, tb: exception_handler(ty, value, tb,
+ config)
# only root can do this
if not os.geteuid() == 0:
@@ -101,21 +144,12 @@ if __name__ == '__main__':
# these modules import gtk, so we need to have a display first
import firstboot.interface
- import meh.ui.gui
# XXX set up the interface
config.frontend = frontend
config.interface = firstboot.interface.Interface(opts.autoscreenshot,
opts.test)
- # XXX set up meh
- handler_conf = meh.Config(programName='firstboot',
- programVersion='@VERSION@')
- handler = meh.handler.ExceptionHandler(handler_conf,
- meh.ui.gui.GraphicalIntf(),
- meh.dump.ExceptionDump)
- handler.install(config)
-
# load modules
loader = firstboot.loader.Loader()
modules = loader.load_modules(module_dir=opts.module_dir,
--
1.7.11.2
More information about the anaconda-patches
mailing list