本文整理匯總了Python中zeroinstall.injector.policy.Policy.refresh_all方法的典型用法代碼示例。如果您正苦於以下問題:Python Policy.refresh_all方法的具體用法?Python Policy.refresh_all怎麽用?Python Policy.refresh_all使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類zeroinstall.injector.policy.Policy
的用法示例。
在下文中一共展示了Policy.refresh_all方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _check_for_updates
# 需要導入模塊: from zeroinstall.injector.policy import Policy [as 別名]
# 或者: from zeroinstall.injector.policy.Policy import refresh_all [as 別名]
def _check_for_updates(old_policy, verbose):
from zeroinstall.injector.policy import Policy
from zeroinstall.injector.config import load_config
iface_cache = old_policy.config.iface_cache
root_iface = iface_cache.get_interface(old_policy.root).get_name()
background_config = load_config(BackgroundHandler(root_iface, old_policy.root))
policy = Policy(config = background_config, requirements = old_policy.requirements)
info(_("Checking for updates to '%s' in a background process"), root_iface)
if verbose:
policy.handler.notify("Zero Install", _("Checking for updates to '%s'...") % root_iface, timeout = 1)
network_state = policy.handler.get_network_state()
if network_state != _NetworkState.NM_STATE_CONNECTED:
info(_("Not yet connected to network (status = %d). Sleeping for a bit..."), network_state)
import time
time.sleep(120)
if network_state in (_NetworkState.NM_STATE_DISCONNECTED, _NetworkState.NM_STATE_ASLEEP):
info(_("Still not connected to network. Giving up."))
sys.exit(1)
else:
info(_("NetworkManager says we're on-line. Good!"))
policy.freshness = 0 # Don't bother trying to refresh when getting the interface
refresh = policy.refresh_all() # (causes confusing log messages)
tasks.wait_for_blocker(refresh)
# We could even download the archives here, but for now just
# update the interfaces.
if not policy.need_download():
if verbose:
policy.handler.notify("Zero Install", _("No updates to download."), timeout = 1)
sys.exit(0)
policy.handler.notify("Zero Install",
_("Updates ready to download for '%s'.") % root_iface,
timeout = 1)
_exec_gui(policy.root, '--refresh', '--systray')
sys.exit(1)
示例2: _check_for_updates
# 需要導入模塊: from zeroinstall.injector.policy import Policy [as 別名]
# 或者: from zeroinstall.injector.policy.Policy import refresh_all [as 別名]
def _check_for_updates(old_policy, verbose):
from zeroinstall.injector.policy import load_config, Policy
iface_cache = old_policy.config.iface_cache
root_iface = iface_cache.get_interface(old_policy.root).get_name()
background_config = load_config(BackgroundHandler(root_iface, old_policy.root))
policy = Policy(config = background_config, requirements = old_policy.requirements)
info(_("Checking for updates to '%s' in a background process"), root_iface)
if verbose:
policy.handler.notify("Zero Install", _("Checking for updates to '%s'...") % root_iface, timeout = 1)
network_state = policy.handler.get_network_state()
if network_state != _NetworkState.NM_STATE_CONNECTED:
info(_("Not yet connected to network (status = %d). Sleeping for a bit..."), network_state)
import time
time.sleep(120)
if network_state in (_NetworkState.NM_STATE_DISCONNECTED, _NetworkState.NM_STATE_ASLEEP):
info(_("Still not connected to network. Giving up."))
sys.exit(1)
else:
info(_("NetworkManager says we're on-line. Good!"))
policy.freshness = 0 # Don't bother trying to refresh when getting the interface
refresh = policy.refresh_all() # (causes confusing log messages)
policy.handler.wait_for_blocker(refresh)
# We could even download the archives here, but for now just
# update the interfaces.
if not policy.need_download():
if verbose:
policy.handler.notify("Zero Install", _("No updates to download."), timeout = 1)
sys.exit(0)
if not policy.handler.have_actions_support():
# Can't ask the user to choose, so just notify them
# In particular, Ubuntu/Jaunty doesn't support actions
policy.handler.notify("Zero Install",
_("Updates ready to download for '%s'.") % root_iface,
timeout = 1)
_exec_gui(policy.root, '--refresh', '--systray')
sys.exit(1)
notification_closed = tasks.Blocker("wait for notification response")
def _NotificationClosed(nid, *unused):
if nid != our_question: return
notification_closed.trigger()
def _ActionInvoked(nid, action):
if nid != our_question: return
if action == 'download':
_exec_gui(policy.root)
notification_closed.trigger()
policy.handler.notification_service.connect_to_signal('NotificationClosed', _NotificationClosed)
policy.handler.notification_service.connect_to_signal('ActionInvoked', _ActionInvoked)
our_question = policy.handler.notify("Zero Install", _("Updates ready to download for '%s'.") % root_iface,
actions = ['download', 'Download'])
policy.handler.wait_for_blocker(notification_closed)