Exemplo n.º 1
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:
        old_sels = app.get_selections()

        requirements = app.get_requirements()
        changes = requirements.parse_update_options(options)
        iface_uri = old_sels.interface

        if requirements.extra_restrictions and not options.xml:
            print("User-provided restrictions in force:")
            for uri, expr in requirements.extra_restrictions.items():
                print("  {uri}: {expr}".format(uri=uri, expr=expr))
            print()
    else:
        iface_uri = model.canonical_iface_uri(args[0])
        requirements = None
        changes = False

    sels = get_selections(config,
                          options,
                          iface_uri,
                          select_only=True,
                          download_only=False,
                          test_callback=None,
                          requirements=requirements)
    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:
            from zeroinstall.cmd import whatchanged
            changes = whatchanged.show_changes(old_sels.selections,
                                               sels.selections) or changes
            if changes:
                print(
                    _("(note: use '0install update' instead to save the changes)"
                      ))
Exemplo 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:
		old_sels = app.get_selections()

		requirements = app.get_requirements()
		changes = requirements.parse_update_options(options)
		iface_uri = old_sels.interface

		if requirements.extra_restrictions and not options.xml:
			print("User-provided restrictions in force:")
			for uri, expr in requirements.extra_restrictions.items():
				print("  {uri}: {expr}".format(uri = uri, expr = expr))
			print()
	else:
		iface_uri = model.canonical_iface_uri(args[0])
		requirements = None
		changes = False

	sels = get_selections(config, options, iface_uri,
				select_only = True, download_only = False, test_callback = None, requirements = requirements)
	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:
			from zeroinstall.cmd import whatchanged
			changes = whatchanged.show_changes(old_sels.selections, sels.selections) or changes
			if changes:
				print(_("(note: use '0install update' instead to save the changes)"))
Exemplo n.º 3
0
def handle(config, options, args):
    if len(args) != 1:
        raise UsageError()

    assert not options.offline

    old_gui = options.gui

    app = config.app_mgr.lookup_app(args[0], missing_ok=True)
    if app is not None:
        old_sels = app.get_selections()
        old_selections = old_sels.selections
        iface_uri = old_sels.interface
        r = app.get_requirements()
        r.parse_update_options(options)
    else:
        iface_uri = model.canonical_iface_uri(args[0])

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

        # 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_for(r,
                                                 config,
                                                 options,
                                                 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_for(r,
                                     config,
                                     options,
                                     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)))

    from zeroinstall.cmd import whatchanged
    changes = whatchanged.show_changes(old_selections, sels.selections)
    root_sel = sels[iface_uri]

    if not changes:
        from zeroinstall.support import xmltools
        # No obvious changes, but check for more subtle updates.
        if not xmltools.nodes_equal(sels.toDOM(), old_sels.toDOM()):
            changes = True
            print(
                _("Updates to metadata found, but no change to version ({version})."
                  ).format(version=root_sel.version))

    root_iface = config.iface_cache.get_interface(iface_uri)
    # Force a reload, since we may have used the GUI to update it
    for feed in config.iface_cache.get_feeds(root_iface):
        config.iface_cache.get_feed(feed, force=True)

    root_impls = config.iface_cache.get_implementations(root_iface)

    latest = max((impl.version, impl) for impl in root_impls)[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'
                  ))
    elif not changes:
        print(
            _("No updates found. Continuing with version {version}.").format(
                version=root_sel.version))

    if app is not None:
        if changes:
            app.set_selections(sels)
        app.set_requirements(r)
Exemplo n.º 4
0
def handle(config, options, args):
	if len(args) != 1:
		raise UsageError()

	assert not options.offline

	old_gui = options.gui

	app = config.app_mgr.lookup_app(args[0], missing_ok = True)
	if app is not None:
		old_sels = app.get_selections()
		old_selections = old_sels.selections
		iface_uri = old_sels.interface
		r = app.get_requirements()
		r.parse_update_options(options)
	else:
		iface_uri = model.canonical_iface_uri(args[0])

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

		# 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_for(r, config, options,
						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_for(r, config, options,
				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)))

	from zeroinstall.cmd import whatchanged
	changes = whatchanged.show_changes(old_selections, sels.selections)
	root_sel = sels[iface_uri]

	if not changes:
		from zeroinstall.support import xmltools
		# No obvious changes, but check for more subtle updates.
		if not xmltools.nodes_equal(sels.toDOM(), old_sels.toDOM()):
			changes = True
			print(_("Updates to metadata found, but no change to version ({version}).").format(version = root_sel.version))

	root_iface = config.iface_cache.get_interface(iface_uri)
	# Force a reload, since we may have used the GUI to update it
	for feed in config.iface_cache.get_feeds(root_iface):
		config.iface_cache.get_feed(feed, force = True)
	
	root_impls = config.iface_cache.get_implementations(root_iface)

	latest = max((impl.version, impl) for impl in root_impls)[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'))
	elif not changes:
		print(_("No updates found. Continuing with version {version}.").format(version = root_sel.version))

	if app is not None:
		if changes:
			app.set_selections(sels)
		app.set_requirements(r)