mirror of
https://github.com/munki/munki.git
synced 2026-04-24 05:49:42 -05:00
Code changes to avoid the indexError: NSRangeException error when returning from an update check.
git-svn-id: http://munki.googlecode.com/svn/trunk@943 a4e17f2e-e282-11dd-95e1-755cbddbdd66
This commit is contained in:
@@ -68,14 +68,17 @@ class MSUAppDelegate(NSObject):
|
||||
if not self._listofupdates:
|
||||
self.getAvailableUpdates()
|
||||
if self._listofupdates:
|
||||
self.buildUpdateTableData()
|
||||
self.mainWindowController.theWindow.makeKeyAndOrderFront_(self)
|
||||
NSApp.requestUserAttention_(NSCriticalRequest)
|
||||
if self._optionalInstalls:
|
||||
self.buildOptionalInstallsData()
|
||||
self.displayUpdatesWindow()
|
||||
else:
|
||||
# no updates available. Should we check for some?
|
||||
self.checkForUpdates()
|
||||
|
||||
def displayUpdatesWindow(self):
|
||||
self.buildUpdateTableData()
|
||||
if self._optionalInstalls:
|
||||
self.buildOptionalInstallsData()
|
||||
self.mainWindowController.theWindow.makeKeyAndOrderFront_(self)
|
||||
NSApp.requestUserAttention_(NSCriticalRequest)
|
||||
|
||||
def munkiStatusSessionEnded_(self, socketSessionResult):
|
||||
consoleuser = munki.getconsoleuser()
|
||||
@@ -124,7 +127,7 @@ class MSUAppDelegate(NSObject):
|
||||
#NSLog(u"Building table of available updates.")
|
||||
self.buildUpdateTableData()
|
||||
if self._optionalInstalls:
|
||||
NSLog(u"Building table of optional software.")
|
||||
#NSLog(u"Building table of optional software.")
|
||||
self.buildOptionalInstallsData()
|
||||
#NSLog(u"Showing main window.")
|
||||
self.mainWindowController.theWindow.makeKeyAndOrderFront_(self)
|
||||
@@ -180,7 +183,18 @@ class MSUAppDelegate(NSObject):
|
||||
|
||||
def checkForUpdates(self):
|
||||
# kick off an update check
|
||||
|
||||
# close main window
|
||||
self.mainWindowController.theWindow.orderOut_(self)
|
||||
# clear data structures
|
||||
self._listofupdates = []
|
||||
self._optionalInstalls = []
|
||||
self.update_view_controller.tableView.deselectAll_(self)
|
||||
self.update_view_controller.setUpdatelist_([])
|
||||
self.optional_view_controller.tableView.deselectAll_(self)
|
||||
self.optional_view_controller.setOptionallist_([])
|
||||
|
||||
# attempt to start the update check
|
||||
result = munki.startUpdateCheck()
|
||||
if result == 0:
|
||||
self.managedsoftwareupdate_task = "manualcheck"
|
||||
|
||||
@@ -32,15 +32,23 @@ class MSUOptionalInstallsViewController(NSViewController):
|
||||
array_controller = IBOutlet()
|
||||
window_controller = IBOutlet()
|
||||
AddRemoveBtn = IBOutlet()
|
||||
|
||||
_EMPTYOPTIONALLIST = NSArray.arrayWithArray_([{"installed": NO,
|
||||
"managed": NO,
|
||||
"original_managed": NO,
|
||||
"name": "",
|
||||
"version": "",
|
||||
"description": "",
|
||||
"size": "",
|
||||
"enabled": NO,
|
||||
"status": "",
|
||||
"original_status": ""}])
|
||||
|
||||
_optionallist = NSArray.arrayWithArray_([{"installed": NO, "managed": NO, "original_managed": NO,
|
||||
"name": "", "version": "",
|
||||
"description": "", "size": "", "enabled": NO,
|
||||
"status": "", "original_status": ""}])
|
||||
_optionallist = []
|
||||
|
||||
def optionallist(self):
|
||||
#NSLog(u"MSUOptionalInstallsViewController.optionallist")
|
||||
return self._optionallist
|
||||
return self._optionallist or self._EMPTYOPTIONALLIST
|
||||
objc.accessor(optionallist) # PyObjC KVO hack
|
||||
|
||||
def setOptionallist_(self, newlist):
|
||||
@@ -100,22 +108,24 @@ class MSUOptionalInstallsViewController(NSViewController):
|
||||
self.window_controller.theTabView.selectPreviousTabViewItem_(sender)
|
||||
NSApp.delegate().addOrRemoveOptionalSoftware()
|
||||
|
||||
def updateWebKitView_(self, description):
|
||||
if "</html>" in description or "</HTML>" in description:
|
||||
self.descriptionView.mainFrame().loadHTMLString_baseURL_(description, None)
|
||||
else:
|
||||
self.descriptionView.mainFrame().loadData_MIMEType_textEncodingName_baseURL_(
|
||||
buffer(description),
|
||||
u"text/plain", u"utf-8", None)
|
||||
def updateDescriptionView(self):
|
||||
#NSLog(u"MSUOptionalInstallsViewController.updateDescriptionView")
|
||||
if len(self.array_controller.selectedObjects()):
|
||||
row = self.array_controller.selectedObjects()[0]
|
||||
description = row.get("description","")
|
||||
if "</html>" in description or "</HTML>" in description:
|
||||
self.descriptionView.mainFrame().loadHTMLString_baseURL_(description, None)
|
||||
else:
|
||||
self.descriptionView.mainFrame().loadData_MIMEType_textEncodingName_baseURL_(
|
||||
buffer(description),
|
||||
u"text/plain", u"utf-8", None)
|
||||
description = row.get("description", u"")
|
||||
self.updateRowStatus()
|
||||
else:
|
||||
self.descriptionView.mainFrame().loadHTMLString_baseURL_(u"", None)
|
||||
description = u""
|
||||
self.performSelectorOnMainThread_withObject_waitUntilDone_(self.updateWebKitView_, description, NO)
|
||||
|
||||
def tableViewSelectionDidChange_(self, sender):
|
||||
#NSLog(u"MSUOptionalInstallsViewController.tableViewSelectionDidChange_")
|
||||
self.performSelectorOnMainThread_withObject_waitUntilDone_(self.updateDescriptionView, None, NO)
|
||||
|
||||
#self.performSelectorOnMainThread_withObject_waitUntilDone_(self.updateDescriptionView, None, NO)
|
||||
self.updateDescriptionView()
|
||||
|
||||
@@ -35,15 +35,16 @@ class MSUupdatesViewController(NSViewController):
|
||||
window_controller = IBOutlet()
|
||||
updateNowBtn = IBOutlet()
|
||||
|
||||
_updatelist = NSArray.arrayWithArray_([{"image": NSImage.imageNamed_("Empty.png"),
|
||||
"name": "",
|
||||
"version": "",
|
||||
"size": "",
|
||||
"description": ""}])
|
||||
_EMPTYUPDATELIST = NSArray.arrayWithArray_([{"image": NSImage.imageNamed_("Empty.png"),
|
||||
"name": "",
|
||||
"version": "",
|
||||
"size": "",
|
||||
"description": ""}])
|
||||
_updatelist = []
|
||||
|
||||
def updatelist(self):
|
||||
#NSLog(u"MSUupdatesViewController.updatelist")
|
||||
return self._updatelist
|
||||
return self._updatelist or self._EMPTYUPDATELIST
|
||||
objc.accessor(updatelist) # PyObjC KVO hack
|
||||
|
||||
def setUpdatelist_(self, newlist):
|
||||
@@ -65,24 +66,27 @@ class MSUupdatesViewController(NSViewController):
|
||||
# switch to optional software pane
|
||||
self.window_controller.theTabView.selectNextTabViewItem_(sender)
|
||||
NSApp.delegate().optional_view_controller.AddRemoveBtn.setEnabled_(NO)
|
||||
NSApp.delegate().buildOptionalInstallsData()
|
||||
#NSApp.delegate().buildOptionalInstallsData()
|
||||
|
||||
def updateWebKitView_(self, description):
|
||||
if "</html>" in description or "</HTML>" in description:
|
||||
self.descriptionView.mainFrame().loadHTMLString_baseURL_(description, None)
|
||||
else:
|
||||
self.descriptionView.mainFrame().loadData_MIMEType_textEncodingName_baseURL_(
|
||||
buffer(description),
|
||||
u"text/plain", u"utf-8", None)
|
||||
|
||||
def updateDescriptionView(self):
|
||||
#NSLog(u"MSUupdatesViewController.updateDescriptionView")
|
||||
if len(self.array_controller.selectedObjects()):
|
||||
row = self.array_controller.selectedObjects()[0]
|
||||
description = row.get("description","")
|
||||
if "</html>" in description or "</HTML>" in description:
|
||||
self.descriptionView.mainFrame().loadHTMLString_baseURL_(description, None)
|
||||
else:
|
||||
self.descriptionView.mainFrame().loadData_MIMEType_textEncodingName_baseURL_(
|
||||
buffer(description),
|
||||
u"text/plain", u"utf-8", None)
|
||||
description = row.get("description", u"")
|
||||
else:
|
||||
self.descriptionView.mainFrame().loadHTMLString_baseURL_(u"", None)
|
||||
description = u""
|
||||
self.performSelectorOnMainThread_withObject_waitUntilDone_(self.updateWebKitView_, description, NO)
|
||||
|
||||
def tableViewSelectionDidChange_(self, sender):
|
||||
#NSLog(u"MSUupdatesViewController.tableViewSelectionDidChange_")
|
||||
self.performSelectorOnMainThread_withObject_waitUntilDone_(self.updateDescriptionView, None, NO)
|
||||
|
||||
#self.performSelectorOnMainThread_withObject_waitUntilDone_(self.updateDescriptionView, None, NO)
|
||||
self.updateDescriptionView()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user