本文整理汇总了Python中zeroinstall.injector.model.canonical_iface_uri函数的典型用法代码示例。如果您正苦于以下问题:Python canonical_iface_uri函数的具体用法?Python canonical_iface_uri怎么用?Python canonical_iface_uri使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了canonical_iface_uri函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testMan
def testMan(self):
out, err = self.run_0install(['man', '--help'])
assert out.lower().startswith("usage:")
# Wrong number of args: pass-through
self.check_man(['git', 'config'], ('man', 'git', 'config'))
self.check_man([], ('man',))
alias_path = os.path.join(mydir, '..', '0alias')
local_feed = os.path.join(mydir, 'Local.xml')
launcher_script = os.path.join(apps.find_bin_dir(), 'my-test-alias')
with open(launcher_script, 'w') as stream:
alias.write_script(stream, model.canonical_iface_uri(local_feed), None)
self.check_man(['my-test-alias'], 'tests/test-echo.1')
self.check_man(['__i_dont_exist'], '__i_dont_exist')
self.check_man(['ls'], 'ls')
# No man-page
binary_feed = os.path.join(mydir, 'Command.xml')
launcher_script = os.path.join(apps.find_bin_dir(), 'my-binary-alias')
with open(launcher_script, 'w') as stream:
alias.write_script(stream, model.canonical_iface_uri(binary_feed), None)
out, err = self.run_0install(['man', 'my-binary-alias'])
assert not err, err
assert "No matching manpage was found for 'my-binary-alias'" in out, out
with open(os.path.join(self.config_home, 'bad-unicode'), 'wb') as stream:
stream.write(bytes([198, 65]))
self.check_man(['bad-unicode'], 'bad-unicode')
示例2: testCanonical
def testCanonical(self):
try:
model.canonical_iface_uri('http://foo')
assert False
except model.SafeException as ex:
assert 'Missing /' in str(ex)
self.assertEquals('http://foo/',
model.canonical_iface_uri('http://foo/'))
try:
model.canonical_iface_uri('bad-name')
assert False
except model.SafeException as ex:
assert 'Bad interface name' in str(ex)
示例3: testSelect
def testSelect(self):
out, err = self.run_0install(['select'])
assert out.lower().startswith("usage:")
assert '--xml' in out
out, err = self.run_0install(['select', 'Local.xml'])
assert not err, err
assert 'Version: 0.1' in out
out, err = self.run_0install(['select', 'Local.xml', '--command='])
assert not err, err
assert 'Version: 0.1' in out
local_uri = model.canonical_iface_uri('Local.xml')
out, err = self.run_0install(['select', 'Local.xml'])
assert not err, err
assert 'Version: 0.1' in out
out, err = self.run_0install(['select', 'Local.xml', '--xml'])
sels = selections.Selections(qdom.parse(BytesIO(str(out).encode('utf-8'))))
assert sels.selections[local_uri].version == '0.1'
out, err = self.run_0install(['select', 'selections.xml'])
assert not err, err
assert 'Version: 1\n' in out
assert '(not cached)' in out
out, err = self.run_0install(['select', 'runnable/RunExec.xml'])
assert not err, err
assert 'Runner' in out, out
示例4: testDownload
def testDownload(self):
out, err = self.run_0install(['download'])
assert out.lower().startswith("usage:")
assert '--show' in out
out, err = self.run_0install(['download', 'Local.xml', '--show'])
assert not err, err
assert 'Version: 0.1' in out
local_uri = model.canonical_iface_uri('Local.xml')
out, err = self.run_0install(['download', 'Local.xml', '--xml'])
assert not err, err
sels = selections.Selections(qdom.parse(BytesIO(str(out).encode('utf-8'))))
assert sels.selections[local_uri].version == '0.1'
out, err = self.run_0install(['download', 'Local.xml', '--show', '--with-store=/foo'])
assert not err, err
assert self.config.stores.stores[-1].dir == '/foo'
out, err = self.run_0install(['download', '--offline', 'selections.xml'])
assert 'Would download' in err
self.config.network_use = model.network_full
self.config.stores = TestStores()
digest = 'sha1=3ce644dc725f1d21cfcf02562c76f375944b266a'
self.config.fetcher.allow_download(digest)
out, err = self.run_0install(['download', 'Hello.xml', '--show'])
assert not err, err
assert self.config.stores.lookup_any([digest]).startswith('/fake')
assert 'Version: 1\n' in out
out, err = self.run_0install(['download', '--offline', 'selections.xml', '--show'])
assert '/fake_store' in out
self.config.network_use = model.network_full
示例5: handle
def handle(config, options, args):
if len(args) == 2:
iface = config.iface_cache.get_interface(model.canonical_iface_uri(args[0]))
feed_url = model.canonical_iface_uri(args[1])
feed_import = add_feed.find_feed_import(iface, feed_url)
if not feed_import:
raise SafeException(
_("Interface %(interface)s has no feed %(feed)s") % {"interface": iface.uri, "feed": feed_url}
)
iface.extra_feeds.remove(feed_import)
writer.save_interface(iface)
elif len(args) == 1:
add_feed.handle(config, options, args, add_ok=False, remove_ok=True)
else:
raise UsageError()
示例6: testAlias
def testAlias(self):
local_feed = model.canonical_iface_uri(os.path.join(mydir, 'Local.xml'))
alias_path = os.path.join(mydir, '..', '0alias')
child = subprocess.Popen([alias_path, 'local-app', local_feed], stdout = subprocess.PIPE, stderr = subprocess.PIPE, universal_newlines = True)
out, err = child.communicate()
assert 'ERROR: "0alias" has been removed; use "0install add" instead' in err, err
assert not out, out
示例7: testDownload
def testDownload(self):
out, err = self.run_0install(["download"])
assert out.lower().startswith("usage:")
assert "--show" in out
out, err = self.run_0install(["download", "Local.xml", "--show"])
assert not err, err
assert "Version: 0.1" in out
local_uri = model.canonical_iface_uri("Local.xml")
out, err = self.run_0install(["download", "Local.xml", "--xml"])
assert not err, err
sels = selections.Selections(qdom.parse(StringIO(str(out))))
assert sels.selections[local_uri].version == "0.1"
out, err = self.run_0install(["download", "Local.xml", "--show", "--with-store=/foo"])
assert not err, err
assert self.config.stores.stores[-1].dir == "/foo"
out, err = self.run_0install(["download", "--offline", "selections.xml"])
assert "Would download" in err
self.config.network_use = model.network_full
self.config.stores = TestStores()
digest = "sha1=3ce644dc725f1d21cfcf02562c76f375944b266a"
self.config.fetcher.allow_download(digest)
out, err = self.run_0install(["download", "Hello.xml", "--show"])
assert not err, err
assert self.config.stores.lookup_any([digest]).startswith("/fake")
assert "Version: 1\n" in out
out, err = self.run_0install(["download", "--offline", "selections.xml", "--show"])
assert "/fake_store" in out
self.config.network_use = model.network_full
示例8: testSelect
def testSelect(self):
out, err = self.run_0install(["select"])
assert out.lower().startswith("usage:")
assert "--xml" in out
out, err = self.run_0install(["select", "Local.xml"])
assert not err, err
assert "Version: 0.1" in out
out, err = self.run_0install(["select", "Local.xml", "--command="])
assert not err, err
assert "Version: 0.1" in out
local_uri = model.canonical_iface_uri("Local.xml")
out, err = self.run_0install(["select", "Local.xml"])
assert not err, err
assert "Version: 0.1" in out
out, err = self.run_0install(["select", "Local.xml", "--xml"])
sels = selections.Selections(qdom.parse(StringIO(str(out))))
assert sels.selections[local_uri].version == "0.1"
out, err = self.run_0install(["select", "selections.xml"])
assert not err, err
assert "Version: 1\n" in out
assert "(not cached)" in out
out, err = self.run_0install(["select", "runnable/RunExec.xml"])
assert not err, err
assert "Runner" in out, out
示例9: do_autocompile
def do_autocompile(args):
"""autocompile [--gui] URI"""
parser = OptionParser(usage="usage: %prog autocompile [options]")
parser.add_option('', "--gui", help="graphical interface", action='store_true')
(options, args2) = parser.parse_args(args)
if len(args2) != 1:
raise __main__.UsageError()
if options.gui:
h = GUIHandler()
elif os.isatty(1):
h = handler.ConsoleHandler()
else:
h = handler.Handler()
config = load_config(handler = h)
config._iface_cache = AutocompileCache()
iface_uri = model.canonical_iface_uri(args2[0])
if options.gui:
compiler = GTKAutoCompiler(config, iface_uri, options)
else:
compiler = AutoCompiler(config, iface_uri, options)
compiler.build()
示例10: handle
def handle(config, options, args):
"""@type config: L{zeroinstall.injector.config.Config}
@type args: [str]"""
if len(args) != 1:
raise UsageError()
app = config.app_mgr.lookup_app(args[0], missing_ok = True)
if app is not None:
sels = app.get_selections()
r = app.get_requirements()
do_select = r.parse_update_options(options) or options.refresh
iface_uri = sels.interface
else:
iface_uri = model.canonical_iface_uri(args[0])
r = None
do_select = True
if do_select or options.gui:
sels = select.get_selections(config, options, iface_uri,
select_only = False, download_only = True, test_callback = None, requirements = r)
if not sels:
sys.exit(1) # Aborted by user
else:
dl = app.download_selections(sels)
if dl:
tasks.wait_for_blocker(dl)
tasks.check(dl)
if options.xml:
select.show_xml(sels)
if options.show:
select.show_human(sels, config.stores)
if app is not None and do_select:
print(_("(use '0install update' to save the new parameters)"))
示例11: handle
def handle(config, options, args):
if len(args) != 1:
raise UsageError()
app = config.app_mgr.lookup_app(args[0], missing_ok = True)
if app is not None:
sels = app.get_selections()
r = app.get_requirements()
do_select = r.parse_update_options(options)
iface_uri = sels.interface
else:
iface_uri = model.canonical_iface_uri(args[0])
do_select = True
if do_select or options.gui:
sels = get_selections(config, options, iface_uri,
select_only = True, download_only = False, test_callback = None)
if not sels:
sys.exit(1) # Aborted by user
if options.xml:
show_xml(sels)
else:
show_human(sels, config.stores)
if app is not None and do_select:
print(_("(use '0install update' to save the new parameters)"))
示例12: handle
def handle(config, options, args):
"""@type config: L{zeroinstall.injector.config.Config}
@type args: [str]"""
if len(args) < 1:
raise UsageError()
prog_args = args[1:]
def test_callback(sels):
from zeroinstall.injector import run
return run.test_selections(sels, prog_args,
False, # dry-run
options.main)
app = config.app_mgr.lookup_app(args[0], missing_ok = True)
if app is not None:
sels = app.get_selections(may_update = True, use_gui = options.gui)
r = app.get_requirements()
do_select = r.parse_update_options(options)
iface_uri = sels.interface
else:
iface_uri = model.canonical_iface_uri(args[0])
do_select = True
if do_select or options.gui:
sels = select.get_selections(config, options, iface_uri,
select_only = False, download_only = False,
test_callback = test_callback)
if not sels:
sys.exit(1) # Aborted by user
from zeroinstall.injector import run
run.execute_selections(sels, prog_args, dry_run = options.dry_run, main = options.main, wrapper = options.wrapper, stores = config.stores)
示例13: handle
def handle(config, options, args):
if len(args) == 2:
iface = config.iface_cache.get_interface(model.canonical_iface_uri(args[0]))
try:
feed_url = model.canonical_iface_uri(args[1])
except SafeException:
feed_url = args[1] # File might not exist any longer
feed_import = add_feed.find_feed_import(iface, feed_url)
if not feed_import:
raise SafeException(_('Interface %(interface)s has no feed %(feed)s') %
{'interface': iface.uri, 'feed': feed_url})
iface.extra_feeds.remove(feed_import)
writer.save_interface(iface)
elif len(args) == 1:
add_feed.handle(config, options, args, add_ok = False, remove_ok = True)
else:
raise UsageError()
示例14: testDownloadIconFails
def testDownloadIconFails(self):
path = model.canonical_iface_uri(os.path.join(mydir, 'Binary.xml'))
iface = self.config.iface_cache.get_interface(path)
blocker = self.config.fetcher.download_icon(iface)
try:
tasks.wait_for_blocker(blocker)
assert False
except download.DownloadError as ex:
assert "Error downloading http://localhost/missing.png" in str(ex), ex
示例15: testAlias
def testAlias(self):
local_feed = model.canonical_iface_uri(os.path.join(mydir, 'Local.xml'))
alias_path = os.path.join(mydir, '..', '0alias')
child = subprocess.Popen([alias_path, 'local-app', local_feed], stdout = subprocess.PIPE, stderr = subprocess.STDOUT, universal_newlines = True)
out, err = child.communicate()
assert '("0alias" is deprecated; using "0install add" instead)' in out, out
assert not err, err
app = self.config.app_mgr.lookup_app('local-app')
assert app.get_requirements().interface_uri == local_feed