Esempio n. 1
0
def handle(config, options, args):
	if len(args) != 1:
		raise UsageError()

	assert not options.offline

	iface_uri = model.canonical_iface_uri(args[0])

	old_gui = options.gui

	# Select once in offline console mode to get the old values
	options.offline = True
	options.gui = False
	options.refresh = False

	try:
		old_sels = select.get_selections(config, options, iface_uri,
					select_only = True, download_only = False, test_callback = None)
	except SafeException:
		old_selections = {}
	else:
		if old_sels is None:
			old_selections = {}
		else:
			old_selections = old_sels.selections

	# Download in online mode to get the new values
	config.network_use = model.network_full
	options.offline = False
	options.gui = old_gui
	options.refresh = True

	sels = select.get_selections(config, options, iface_uri,
				select_only = False, download_only = True, test_callback = None)
	if not sels:
		sys.exit(1)	# Aborted by user

	changes = False

	for iface, old_sel in old_selections.iteritems():
		new_sel = sels.selections.get(iface, None)
		if new_sel is None:
			print _("No longer used: %s") % iface
			changes = True
		elif old_sel.version != new_sel.version:
			print _("%s: %s -> %s") % (iface, old_sel.version, new_sel.version)
			changes = True

	for iface, new_sel in sels.selections.iteritems():
		if iface not in old_selections:
			print _("%s: new -> %s") % (iface, new_sel.version)
			changes = True

	if not changes:
		print _("No updates found.")
Esempio n. 2
0
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)"))
Esempio n. 3
0
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)
Esempio n. 4
0
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) 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 = False,
					test_callback = test_callback,
					requirements = r)
		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)
Esempio n. 5
0
def handle(config, options, args):
	if len(args) != 1:
		raise UsageError()
	iface_uri = model.canonical_iface_uri(args[0])

	sels = select.get_selections(config, options, iface_uri,
				select_only = False, download_only = True, test_callback = None)
	if not sels:
		sys.exit(1)	# Aborted by user

	if options.xml:
		select.show_xml(sels)
	if options.show:
		select.show_human(sels, config.stores)
Esempio n. 6
0
def handle(config, options, args):
    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)
        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
    else:
        dl = app.download_selections(sels)
        if dl:
            tasks.wait_for_blocker(dl)
            tasks.check(dl)

    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)
Esempio n. 7
0
def handle(config, options, args):
	if len(args) != 2:
		raise UsageError()

	pet_name = args[0]
	iface_uri = model.canonical_iface_uri(args[1])

	sels = select.get_selections(config, options, iface_uri, select_only = False, download_only = True, test_callback = None)
	if not sels:
		sys.exit(1)	# Aborted by user

	r = requirements.Requirements(iface_uri)
	r.parse_options(options)

	app = config.app_mgr.create_app(pet_name, r)
	app.set_selections(sels)
	app.integrate_shell(pet_name)
Esempio n. 8
0
def handle(config, options, args):
    if len(args) != 1:
        raise UsageError()
    iface_uri = model.canonical_iface_uri(args[0])

    sels = select.get_selections(config,
                                 options,
                                 iface_uri,
                                 select_only=False,
                                 download_only=True,
                                 test_callback=None)
    if not sels:
        sys.exit(1)  # Aborted by user

    if options.xml:
        select.show_xml(sels)
    if options.show:
        select.show_human(sels, config.stores)
Esempio n. 9
0
def handle(config, options, args):
	if len(args) < 1:
		raise UsageError()
	iface_uri = model.canonical_iface_uri(args[0])
	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)

	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)
Esempio n. 10
0
def handle(config, options, args):
	"""@type args: [str]"""
	if len(args) != 2:
		raise UsageError()

	pet_name = args[0]
	iface_uri = model.canonical_iface_uri(args[1])

	sels = select.get_selections(config, options, iface_uri, select_only = False, download_only = True, test_callback = None)
	if not sels:
		sys.exit(1)	# Aborted by user

	root_feed = config.iface_cache.get_feed(iface_uri)
	if root_feed:
		target = root_feed.get_replaced_by()
		if target is not None:
			print(_("Warning: interface {old} has been replaced by {new}".format(old = iface_uri, new = target)))

	r = requirements.Requirements(iface_uri)
	r.parse_options(options)

	app = config.app_mgr.create_app(pet_name, r)
	app.set_selections(sels)
	app.integrate_shell(pet_name)
Esempio n. 11
0
def handle(config, options, args):
	if len(args) != 1:
		raise UsageError()

	assert not options.offline

	iface_uri = model.canonical_iface_uri(args[0])

	old_gui = options.gui

	# Select once in offline console mode to get the old values
	options.offline = True
	options.gui = False
	options.refresh = False

	try:
		old_sels = select.get_selections(config, options, iface_uri,
					select_only = True, download_only = False, test_callback = None)
	except SafeException:
		old_selections = {}
	else:
		if old_sels is None:
			old_selections = {}
		else:
			old_selections = old_sels.selections

	# Download in online mode to get the new values
	config.network_use = model.network_full
	options.offline = False
	options.gui = old_gui
	options.refresh = True

	sels = select.get_selections(config, options, iface_uri,
				select_only = False, download_only = True, test_callback = None)
	if not sels:
		sys.exit(1)	# Aborted by user

	changes = False

	for iface, old_sel in old_selections.iteritems():
		new_sel = sels.selections.get(iface, None)
		if new_sel is None:
			print(_("No longer used: %s") % iface)
			changes = True
		elif old_sel.version != new_sel.version:
			print(_("%s: %s -> %s") % (iface, old_sel.version, new_sel.version))
			changes = True

	for iface, new_sel in sels.selections.iteritems():
		if iface not in old_selections:
			print(_("%s: new -> %s") % (iface, new_sel.version))
			changes = True

	root_sel = sels[iface_uri]
	root_iface = config.iface_cache.get_interface(iface_uri)
	latest = max((impl.version, impl) for impl in root_iface.implementations.values())[1]
	if latest.version > model.parse_version(sels[iface_uri].version):
		print(_("A later version ({name} {latest}) exists but was not selected. Using {version} instead.").format(
				latest = latest.get_version(),
				name = root_iface.get_name(),
				version = root_sel.version))
		if not config.help_with_testing and latest.get_stability() < model.stable:
			print(_('To select "testing" versions, use:\n0install config help_with_testing True'))
	else:
		if not changes:
			print(_("No updates found. Continuing with version {version}.").format(version = root_sel.version))

	root_feed = config.iface_cache.get_feed(iface_uri)
	if root_feed:
		target = root_feed.get_replaced_by()
		if target is not None:
			print(_("Warning: interface {old} has been replaced by {new}".format(old = iface_uri, new = target)))
Esempio n. 12
0
def handle(config, options, args):
    if len(args) != 1:
        raise UsageError()

    assert not options.offline

    iface_uri = model.canonical_iface_uri(args[0])

    old_gui = options.gui

    # Select once in offline console mode to get the old values
    options.offline = True
    options.gui = False
    options.refresh = False

    try:
        old_sels = select.get_selections(config,
                                         options,
                                         iface_uri,
                                         select_only=True,
                                         download_only=False,
                                         test_callback=None)
    except SafeException:
        old_selections = {}
    else:
        if old_sels is None:
            old_selections = {}
        else:
            old_selections = old_sels.selections

    # Download in online mode to get the new values
    config.network_use = model.network_full
    options.offline = False
    options.gui = old_gui
    options.refresh = True

    sels = select.get_selections(config,
                                 options,
                                 iface_uri,
                                 select_only=False,
                                 download_only=True,
                                 test_callback=None)
    if not sels:
        sys.exit(1)  # Aborted by user

    changes = False

    for iface, old_sel in old_selections.iteritems():
        new_sel = sels.selections.get(iface, None)
        if new_sel is None:
            print(_("No longer used: %s") % iface)
            changes = True
        elif old_sel.version != new_sel.version:
            print(
                _("%s: %s -> %s") % (iface, old_sel.version, new_sel.version))
            changes = True

    for iface, new_sel in sels.selections.iteritems():
        if iface not in old_selections:
            print(_("%s: new -> %s") % (iface, new_sel.version))
            changes = True

    root_sel = sels[iface_uri]
    root_iface = config.iface_cache.get_interface(iface_uri)
    latest = max((impl.version, impl)
                 for impl in root_iface.implementations.values())[1]
    if latest.version > model.parse_version(sels[iface_uri].version):
        print(
            _("A later version ({name} {latest}) exists but was not selected. Using {version} instead."
              ).format(latest=latest.get_version(),
                       name=root_iface.get_name(),
                       version=root_sel.version))
        if not config.help_with_testing and latest.get_stability(
        ) < model.stable:
            print(
                _('To select "testing" versions, use:\n0install config help_with_testing True'
                  ))
    else:
        if not changes:
            print(
                _("No updates found. Continuing with version {version}.").
                format(version=root_sel.version))