本文整理汇总了Python中zeroinstall.injector.driver.Driver.solve_and_download_impls方法的典型用法代码示例。如果您正苦于以下问题:Python Driver.solve_and_download_impls方法的具体用法?Python Driver.solve_and_download_impls怎么用?Python Driver.solve_and_download_impls使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类zeroinstall.injector.driver.Driver
的用法示例。
在下文中一共展示了Driver.solve_and_download_impls方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ensure_cached
# 需要导入模块: from zeroinstall.injector.driver import Driver [as 别名]
# 或者: from zeroinstall.injector.driver.Driver import solve_and_download_impls [as 别名]
def ensure_cached(uri, command = 'run', config = None):
"""Ensure that an implementation of uri is cached.
If not, it downloads one. It uses the GUI if a display is
available, or the console otherwise.
@param uri: the required interface
@type uri: str
@return: the selected implementations, or None if the user cancelled
@rtype: L{zeroinstall.injector.selections.Selections}
"""
from zeroinstall.injector.driver import Driver
if config is None:
from zeroinstall.injector.config import load_config
config = load_config()
from zeroinstall.injector.requirements import Requirements
requirements = Requirements(uri)
requirements.command = command
d = Driver(config, requirements)
if d.need_download() or not d.solver.ready:
sels = get_selections_gui(uri, ['--command', command], use_gui = None)
if sels != DontUseGUI:
return sels
done = d.solve_and_download_impls()
tasks.wait_for_blocker(done)
return d.solver.selections
示例2: testAbsMain
# 需要导入模块: from zeroinstall.injector.driver import Driver [as 别名]
# 或者: from zeroinstall.injector.driver.Driver import solve_and_download_impls [as 别名]
def testAbsMain(self):
with tempfile.NamedTemporaryFile(prefix = 'test-', delete = False) as tmp:
tmp.write((
"""<?xml version="1.0" ?>
<interface last-modified="1110752708"
uri="%s"
xmlns="http://zero-install.sourceforge.net/2004/injector/interface">
<name>Foo</name>
<summary>Foo</summary>
<description>Foo</description>
<group main='/bin/sh'>
<implementation id='.' version='1'/>
</group>
</interface>""" % foo_iface_uri).encode('utf-8'))
driver = Driver(requirements = Requirements(tmp.name), config = self.config)
try:
downloaded = driver.solve_and_download_impls()
if downloaded:
tasks.wait_for_blocker(downloaded)
run.execute_selections(driver.solver.selections, [], stores = self.config.stores)
assert False
except SafeException as ex:
assert 'Command path must be relative' in str(ex), ex
示例3: get_selections_for
# 需要导入模块: from zeroinstall.injector.driver import Driver [as 别名]
# 或者: from zeroinstall.injector.driver.Driver import solve_and_download_impls [as 别名]
def get_selections_for(requirements, config, options, select_only, download_only, test_callback):
"""Get selections for given requirements.
@since: 1.9"""
if options.offline:
config.network_use = model.network_offline
iface_cache = config.iface_cache
driver = Driver(config = config, requirements = requirements)
# Note that need_download() triggers a solve
if options.refresh or options.gui:
# We could run immediately, but the user asked us not to
can_run_immediately = False
else:
if select_only:
# --select-only: we only care that we've made a selection, not that we've cached the implementations
driver.need_download()
can_run_immediately = driver.solver.ready
else:
can_run_immediately = not driver.need_download()
stale_feeds = [feed for feed in driver.solver.feeds_used if
not feed.startswith('distribution:') and # Ignore (memory-only) PackageKit feeds
iface_cache.is_stale(feed, config.freshness)]
if download_only and stale_feeds:
can_run_immediately = False
if can_run_immediately:
if stale_feeds:
if config.network_use == model.network_offline:
logger.debug(_("No doing background update because we are in off-line mode."))
else:
# There are feeds we should update, but we can run without them.
# Do the update in the background while the program is running.
from zeroinstall.injector import background
background.spawn_background_update(driver, options.verbose)
return driver.solver.selections
# If we need to download anything, we might as well
# refresh all the feeds first.
options.refresh = True
if options.gui != False:
# If the user didn't say whether to use the GUI, choose for them.
gui_args = driver.requirements.get_as_options()
if download_only:
# Just changes the button's label
gui_args.append('--download-only')
if options.refresh:
gui_args.append('--refresh')
if options.verbose:
gui_args.insert(0, '--verbose')
if options.verbose > 1:
gui_args.insert(0, '--verbose')
if options.with_store:
for x in options.with_store:
gui_args += ['--with-store', x]
if select_only:
gui_args.append('--select-only')
from zeroinstall import helpers
sels = helpers.get_selections_gui(requirements.interface_uri, gui_args, test_callback, use_gui = options.gui)
if not sels:
return None # Aborted
elif sels is helpers.DontUseGUI:
sels = None
else:
sels = None
if sels is None:
# Note: --download-only also makes us stop and download stale feeds first.
downloaded = driver.solve_and_download_impls(refresh = options.refresh or download_only or False,
select_only = select_only)
if downloaded:
tasks.wait_for_blocker(downloaded)
sels = driver.solver.selections
return sels
示例4: load_config
# 需要导入模块: from zeroinstall.injector.driver import Driver [as 别名]
# 或者: from zeroinstall.injector.driver.Driver import solve_and_download_impls [as 别名]
site_config = os.path.join(mydir, 'site-config.xml')
if not os.path.exists(site_config):
print "Copy site-config.xml.template as site-config.xml and edit..."
sys.exit(1)
drupal = "http://repo.roscidus.com/drupal/core"
config = load_config()
import local_config
local_config.apply_local_config(config)
requirements = Requirements(site_config)
requirements.command = None
driver = Driver(config, requirements)
tasks.wait_for_blocker(driver.solve_and_download_impls(refresh = refresh))
selections = driver.solver.selections.selections
drupal_impl = selections[drupal]
drupal_root = drupal_impl.local_path or config.stores.lookup_any(drupal_impl.digests)
config_impl = selections[site_config]
site_config_settings = {}
for binding in config_impl.bindings:
site_config_settings[binding.name] = binding.value
doc_root = site_config_settings["doc_root"]
apache_user = pwd.getpwnam(site_config_settings["apache_user"])
print "Selected Drupal", drupal_impl.version, "(" + drupal_root+ ")"
示例5: get_selections
# 需要导入模块: from zeroinstall.injector.driver import Driver [as 别名]
# 或者: from zeroinstall.injector.driver.Driver import solve_and_download_impls [as 别名]
def get_selections(config, options, iface_uri, select_only, download_only, test_callback):
"""Get selections for iface_uri, according to the options passed.
Will switch to GUI mode if necessary.
@param options: options from OptionParser
@param iface_uri: canonical URI of the interface
@param select_only: return immediately even if the selected versions aren't cached
@param download_only: wait for stale feeds, and display GUI button as Download, not Run
@return: the selected versions, or None if the user cancels
@rtype: L{selections.Selections} | None
"""
if options.offline:
config.network_use = model.network_offline
iface_cache = config.iface_cache
# Try to load it as a feed. If it is a feed, it'll get cached. If not, it's a
# selections document and we return immediately.
maybe_selections = iface_cache.get_feed(iface_uri, selections_ok = True)
if isinstance(maybe_selections, selections.Selections):
if not select_only:
blocker = maybe_selections.download_missing(config)
if blocker:
logging.info(_("Waiting for selected implementations to be downloaded..."))
tasks.wait_for_blocker(blocker)
return maybe_selections
r = requirements.Requirements(iface_uri)
r.parse_options(options)
driver = Driver(config = config, requirements = r)
# Note that need_download() triggers a solve
if options.refresh or options.gui:
# We could run immediately, but the user asked us not to
can_run_immediately = False
else:
if select_only:
# --select-only: we only care that we've made a selection, not that we've cached the implementations
driver.need_download()
can_run_immediately = driver.solver.ready
else:
can_run_immediately = not driver.need_download()
stale_feeds = [feed for feed in driver.solver.feeds_used if
not feed.startswith('distribution:') and # Ignore (memory-only) PackageKit feeds
iface_cache.is_stale(feed, config.freshness)]
if download_only and stale_feeds:
can_run_immediately = False
if can_run_immediately:
if stale_feeds:
if config.network_use == model.network_offline:
logging.debug(_("No doing background update because we are in off-line mode."))
else:
# There are feeds we should update, but we can run without them.
# Do the update in the background while the program is running.
from zeroinstall.injector import background
background.spawn_background_update(driver, options.verbose > 0)
return driver.solver.selections
# If the user didn't say whether to use the GUI, choose for them.
if options.gui is None and os.environ.get('DISPLAY', None):
options.gui = True
# If we need to download anything, we might as well
# refresh all the feeds first.
options.refresh = True
logging.info(_("Switching to GUI mode... (use --console to disable)"))
if options.gui:
gui_args = driver.requirements.get_as_options()
if download_only:
# Just changes the button's label
gui_args.append('--download-only')
if options.refresh:
gui_args.append('--refresh')
if options.verbose:
gui_args.insert(0, '--verbose')
if options.verbose > 1:
gui_args.insert(0, '--verbose')
if options.with_store:
for x in options.with_store:
gui_args += ['--with-store', x]
if select_only:
gui_args.append('--select-only')
from zeroinstall import helpers
sels = helpers.get_selections_gui(iface_uri, gui_args, test_callback)
if not sels:
return None # Aborted
else:
# Note: --download-only also makes us stop and download stale feeds first.
downloaded = driver.solve_and_download_impls(refresh = options.refresh or download_only or False,
select_only = select_only)
if downloaded:
tasks.wait_for_blocker(downloaded)
sels = driver.solver.selections
return sels