Fix "NameError: name 'report_broken_python' is not defined" crash when attempting to report a broken Python install. The file hasn't been parsed at this point, so the report_broken_python function is nonexistent.

Broken in: https://code.google.com/p/munki/source/detail?r=cbb385f540643aa3a15a242ba5de513404af02ce

pylint warnings should either be ignored, or disabled using a "pylint: disable-msg" annotation.
This commit is contained in:
Justin McWilliams
2013-05-14 16:52:55 -07:00
parent cd15912feb
commit b166a908c0

View File

@@ -34,23 +34,8 @@ try:
from Foundation import NSNotificationDeliverImmediately
from Foundation import NSNotificationPostToAllSessions
except ImportError:
# Python is missing ObjC bindings. Run external report script.
from munkilib import utils
report_broken_python()
sys.exit(200)
else:
from munkilib import munkicommon
from munkilib import updatecheck
from munkilib import installer
from munkilib import munkistatus
from munkilib import appleupdates
from munkilib import FoundationPlist
from munkilib import utils
def report_broken_python():
"""Python is missing ObjC bindings. Run external report script."""
# Moved this to a function to prevent PyLint from complaining
# about redefining names from outer scope
print >> sys.stderr, 'Python is missing ObjC bindings.'
scriptdir = os.path.realpath(os.path.dirname(sys.argv[0]))
script = os.path.join(scriptdir, 'report_broken_client')
@@ -61,6 +46,15 @@ def report_broken_python():
pass # script is not required, so pass
except utils.RunExternalScriptError, err:
print >> sys.stderr, str(err)
sys.exit(200)
else:
from munkilib import munkicommon
from munkilib import updatecheck
from munkilib import installer
from munkilib import munkistatus
from munkilib import appleupdates
from munkilib import FoundationPlist
from munkilib import utils
def signal_handler(signum, unused_frame):