本文整理汇总了Python中MunkiItems.optionalItemForName_方法的典型用法代码示例。如果您正苦于以下问题:Python MunkiItems.optionalItemForName_方法的具体用法?Python MunkiItems.optionalItemForName_怎么用?Python MunkiItems.optionalItemForName_使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MunkiItems
的用法示例。
在下文中一共展示了MunkiItems.optionalItemForName_方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: myItemsActionButtonClicked_
# 需要导入模块: import MunkiItems [as 别名]
# 或者: from MunkiItems import optionalItemForName_ [as 别名]
def myItemsActionButtonClicked_(self, item_name):
'''this method is called from JavaScript when the user clicks
the Install/Remove/Cancel button in the My Items view'''
document = self.webView.mainFrameDocument()
item = MunkiItems.optionalItemForName_(item_name)
status_line = document.getElementById_('%s_status_text' % item_name)
btn = document.getElementById_('%s_action_button_text' % item_name)
if not item or not btn or not status_line:
msclog.debug_log('User clicked MyItems action button for %s' % item_name)
msclog.debug_log('Unexpected error finding HTML elements')
return
prior_status = item['status']
item.update_status()
self.displayUpdateCount()
if item['status'] == 'not-installed':
# we removed item from list of things to install
# now remove from display
table_row = document.getElementById_('%s_myitems_table_row' % item_name)
if table_row:
node = table_row.parentNode().removeChild_(table_row)
else:
btn.setInnerText_(item['myitem_action_text'])
status_line.setInnerText_(item['status_text'])
status_line.setClassName_('status %s' % item['status'])
if item['status'] in ['install-requested', 'removal-requested']:
self._alertedUserToOutstandingUpdates = False
if not self._update_in_progress:
self.updateNow()
elif prior_status in ['will-be-installed', 'update-will-be-installed',
'will-be-removed']:
# cancelled a pending install or removal; should run an updatecheck
self.checkForUpdates(suppress_apple_update_check=True)
示例2: actionButtonClicked_
# 需要导入模块: import MunkiItems [as 别名]
# 或者: from MunkiItems import optionalItemForName_ [as 别名]
def actionButtonClicked_(self, item_name):
'''this method is called from JavaScript when the user clicks
the Install/Removel/Cancel button in the list or detail view'''
item = MunkiItems.optionalItemForName_(item_name)
if not item:
msclog.debug_log(
'User clicked Install/Removel/Cancel button in the list or detail view')
msclog.debug_log('Can\'t find item: %s' % item_name)
return
prior_status = item['status']
item.update_status()
self.displayUpdateCount()
self.updateDOMforOptionalItem(item)
if item['status'] in ['install-requested', 'removal-requested']:
self._alertedUserToOutstandingUpdates = False
if not self._update_in_progress:
self.updateNow()
elif prior_status in ['will-be-installed', 'update-will-be-installed',
'will-be-removed']:
# cancelled a pending install or removal; should run an updatecheck
self.checkForUpdates(suppress_apple_update_check=True)
示例3: updateOptionalInstallButtonClicked_
# 需要导入模块: import MunkiItems [as 别名]
# 或者: from MunkiItems import optionalItemForName_ [as 别名]
def updateOptionalInstallButtonClicked_(self, item_name):
'''this method is called from JavaScript when a user clicks
the cancel or add button in the updates list'''
# TO-DO: better handling of all the possible "unexpected error"s
document = self.webView.mainFrameDocument()
item = MunkiItems.optionalItemForName_(item_name)
if not item:
msclog.debug_log('Unexpected error: Can\'t find item for %s' % item_name)
return
update_table_row = document.getElementById_('%s_update_table_row' % item_name)
if not update_table_row:
msclog.debug_log('Unexpected error: Can\'t find table row for %s' % item_name)
return
# remove this row from its current table
node = update_table_row.parentNode().removeChild_(update_table_row)
previous_status = item['status']
# update item status
item.update_status()
# do we need to add a new node to the other list?
if item.get('needs_update'):
# make some new HTML for the updated item
managed_update_names = MunkiItems.getInstallInfo().get('managed_updates', [])
item_template = mschtml.get_template('update_row_template.html')
item_html = item_template.safe_substitute(item)
if item['status'] in ['install-requested', 'update-will-be-installed', 'installed']:
# add the node to the updates-to-install table
table = document.getElementById_('updates-to-install-table')
if item['status'] == 'update-available':
# add the node to the other-updates table
table = document.getElementById_('other-updates-table')
if not table:
msclog.debug_log('Unexpected error: could not find other-updates-table')
return
# this isn't the greatest way to add something to the DOM
# but it works...
table.setInnerHTML_(table.innerHTML() + item_html)
# might need to toggle visibility of other updates div
other_updates_div = document.getElementById_('other-updates')
other_updates_div_classes = other_updates_div.className().split(' ')
other_updates_table = document.getElementById_('other-updates-table')
if other_updates_table.innerHTML().strip():
if 'hidden' in other_updates_div_classes:
other_updates_div_classes.remove('hidden')
other_updates_div.setClassName_(' '.join(other_updates_div_classes))
else:
if not 'hidden' in other_updates_div_classes:
other_updates_div_classes.append('hidden')
other_updates_div.setClassName_(' '.join(other_updates_div_classes))
# update the updates-to-install header to reflect the new list of updates to install
updateCount = self.getUpdateCount()
update_count_message = msclib.updateCountMessage(updateCount)
update_count_element = document.getElementById_('update-count-string')
if update_count_element:
update_count_element.setInnerText_(update_count_message)
warning_text = mschtml.get_warning_text()
warning_text_element = document.getElementById_('update-warning-text')
if warning_text_element:
warning_text_element.setInnerHTML_(warning_text)
# update text of Install All button
install_all_button_element = document.getElementById_('install-all-button-text')
if install_all_button_element:
install_all_button_element.setInnerText_(
msclib.getInstallAllButtonTextForCount(updateCount))
# update count badges
self.displayUpdateCount()
if MunkiItems.updateCheckNeeded():
# check for updates after a short delay so UI changes visually complete first
self.performSelector_withObject_afterDelay_(self.checkForUpdates, True, 1.0)