# (c) Copyright 2014. CodeWeavers, Inc.
import checkgtk
def check_all_bases():
gtk_status = checkgtk.ensure_present_gtk()
if gtk_status == checkgtk.MISSING or gtk_status == checkgtk.BROKEN:
# Make sure we're running in Python 2 before continuing
# pylint: disable=W0612
import checkpython
# Delayed imports in case we're running in Python 3
import cxdiag
import mountpoints
import cxfixes
cxfixes.clear_errors()
if gtk_status == checkgtk.MISSING or gtk_status == checkgtk.BROKEN:
cxfixes.add_error('gtk2')
diag = cxdiag.get(None)
for errid, (level, title, _description) in diag.warnings.iteritems():
if level == 'Require':
cxfixes.add_error(errid, title)
if cxfixes.has_errors():
# DBus is optional so only report/fix it opportunistically
mountpoints.check_dbus()
return gtk_status
def fix_all_bases(report=True):
gtk_status = check_all_bases()
# Delayed import in case we're running in Python 3
import cxfixes
cxfixes.fix_errors()
if report:
# Refresh the error list so we don't report errors that have been fixed
# as a side effect of others. For instance installing libgcc_s is
# likely to fix MissingLibPthread.
gtk_status = check_all_bases()
cxfixes.report_errors()
elif gtk_status != checkgtk.OK:
# The issues may not have all been fixed but if GTK+ is ok we can
# at least bring up the GUI.
gtk_status = checkgtk.ensure_present_gtk()
if gtk_status == checkgtk.NO_DISPLAY:
import cxlog
cxlog.err("Verify $DISPLAY: it is not set, invalid or you are not allowed to access it")
if gtk_status != checkgtk.OK:
# Only signal a failure if we won't be able to bring up the GUI
return False
return True