Esempio n. 1
0
    def ok(feed):
        from zeroinstall.injector import reader
        try:
            feed_targets = config.iface_cache.get_feed_targets(feed)
            if interface not in feed_targets:
                raise Exception(
                    _("Not a valid feed for '%(uri)s'; this is a feed for:\n%(feed_for)s"
                      ) % {
                          'uri': interface.uri,
                          'feed_for': '\n'.join([f.uri for f in feed_targets])
                      })
            if feed in [f.uri for f in interface.extra_feeds]:
                dialog.alert(None, _('This feed is already registered.'))
            else:
                interface.extra_feeds.append(
                    Feed(feed, user_override=True, arch=None))

            writer.save_interface(interface)
            chooser.destroy()
            reader.update_from_cache(interface)
            import main
            main.recalculate()
        except Exception as ex:
            dialog.alert(
                None,
                _("Error in feed file '%(feed)s':\n\n%(exception)s") % {
                    'feed': feed,
                    'exception': str(ex)
                })
Esempio n. 2
0
		def on_success():
			# A new local feed may have been registered, so reload it from the disk cache
			info(_("0compile command completed successfully. Reloading interface details."))
			reader.update_from_cache(interface)
			for feed in interface.extra_feeds:
				 self.policy.config.iface_cache.get_feed(feed.uri, force = True)
			import main
			main.recalculate()
Esempio n. 3
0
		def on_success():
			# A new local feed may have been registered, so reload it from the disk cache
			info(_("0compile command completed successfully. Reloading interface details."))
			reader.update_from_cache(interface)
			for feed in interface.extra_feeds:
				self.config.iface_cache.get_feed(feed.uri, force = True)
			import main
			main.recalculate()
Esempio n. 4
0
	def set(new):
		if isinstance(new, model.Stability):
			impl.user_stability = new
		else:
			impl.user_stability = None
		writer.save_feed(impl.feed)
		import main
		main.recalculate()
Esempio n. 5
0
 def set(new):
     if isinstance(new, model.Stability):
         impl.user_stability = new
     else:
         impl.user_stability = None
     writer.save_feed(impl.feed)
     import main
     main.recalculate()
Esempio n. 6
0
 def set_stability_policy(combo, stability=stability):  # (pygtk bug?)
     i = stability.get_active()
     if i == 0:
         new_stability = None
     else:
         name = ['stable', 'testing', 'developer'][i - 1]
         new_stability = stability_levels[name]
     interface.set_stability_policy(new_stability)
     writer.save_interface(interface)
     import main
     main.recalculate()
Esempio n. 7
0
		def set_stability_policy(combo, stability = stability):	# (pygtk bug?)
			i = stability.get_active()
			if i == 0:
				new_stability = None
			else:
				name = ['stable', 'testing', 'developer'][i-1]
				new_stability = stability_levels[name]
			interface.set_stability_policy(new_stability)
			writer.save_interface(interface)
			import main
			main.recalculate()
		def remove_feed(button):
			model, iter = self.tv.get_selection().get_selected()
			feed_uri = model[iter][Feeds.URI]
			for x in interface.extra_feeds:
				if x.uri == feed_uri:
					if x.user_override:
						interface.extra_feeds.remove(x)
						writer.save_interface(interface)
						import main
						main.recalculate()
						return
					else:
						dialog.alert(self.get_toplevel(),
							_("Can't remove '%s' as you didn't add it.") % feed_uri)
						return
			raise Exception(_("Missing feed '%s'!") % feed_uri)
Esempio n. 9
0
	def ok(feed):
		from zeroinstall.injector import reader
		try:
			feed_targets = policy.get_feed_targets(feed)
			if interface not in feed_targets:
				raise Exception(_("Not a valid feed for '%(uri)s'; this is a feed for:\n%(feed_for)s") %
						{'uri': interface.uri,
						'feed_for': '\n'.join([f.uri for f in feed_targets])})
			if feed in [f.uri for f in interface.extra_feeds]:
				dialog.alert(None, _('This feed is already registered.'))
			else:
				interface.extra_feeds.append(Feed(feed, user_override = True, arch = None))

			writer.save_interface(interface)
			chooser.destroy()
			reader.update_from_cache(interface)
			import main
			main.recalculate()
		except Exception as ex:
			dialog.alert(None, _("Error in feed file '%(feed)s':\n\n%(exception)s") % {'feed': feed, 'exception': str(ex)})
Esempio n. 10
0
def add_remote_feed(config, parent, interface):
    try:
        iface_cache = config.iface_cache

        d = gtk.MessageDialog(
            parent, 0, gtk.MESSAGE_QUESTION, gtk.BUTTONS_CANCEL,
            _('Enter the URL of the new source of implementations of this interface:'
              ))
        d.add_button(gtk.STOCK_ADD, gtk.RESPONSE_OK)
        d.set_default_response(gtk.RESPONSE_OK)
        entry = gtk.Entry()

        align = gtk.VBox(False, 0)
        align.set_border_width(4)
        align.add(entry)
        d.vbox.pack_start(align)
        entry.set_activates_default(True)

        entry.set_text('')

        d.vbox.show_all()

        error_label = gtk.Label('')
        error_label.set_padding(4, 4)
        align.pack_start(error_label)

        d.show()

        def error(message):
            if message:
                error_label.set_text(message)
                error_label.show()
            else:
                error_label.hide()

        while True:
            got_response = DialogResponse(d)
            yield got_response
            tasks.check(got_response)
            resp = got_response.response

            error(None)
            if resp == gtk.RESPONSE_OK:
                try:
                    url = entry.get_text()
                    if not url:
                        raise zeroinstall.SafeException(_('Enter a URL'))
                    fetch = config.fetcher.download_and_import_feed(
                        url, iface_cache)
                    if fetch:
                        d.set_sensitive(False)
                        yield fetch
                        d.set_sensitive(True)
                        tasks.check(fetch)

                        iface = iface_cache.get_interface(url)

                        d.set_sensitive(True)
                        if not iface.name:
                            error(_('Failed to read interface'))
                            return
                        if not iface.feed_for:
                            error(
                                _("Feed '%(feed)s' is not a feed for '%(feed_for)s'."
                                  ) % {
                                      'feed': iface.get_name(),
                                      'feed_for': interface.get_name()
                                  })
                        elif interface.uri not in iface.feed_for:
                            error(
                                _("This is not a feed for '%(uri)s'.\nOnly for:\n%(feed_for)s"
                                  ) % {
                                      'uri': interface.uri,
                                      'feed_for': '\n'.join(iface.feed_for)
                                  })
                        elif iface.uri in [
                                f.uri for f in interface.extra_feeds
                        ]:
                            error(
                                _("Feed from '%s' has already been added!") %
                                iface.uri)
                        else:
                            interface.extra_feeds.append(
                                Feed(iface.uri, arch=None, user_override=True))
                            writer.save_interface(interface)
                            d.destroy()
                            import main
                            main.recalculate()
                except zeroinstall.SafeException as ex:
                    error(str(ex))
            else:
                d.destroy()
                return
    except Exception as ex:
        import traceback
        traceback.print_exc()
        config.handler.report_error(ex)
Esempio n. 11
0
def add_remote_feed(policy, parent, interface):
	try:
		iface_cache = policy.config.iface_cache

		d = gtk.MessageDialog(parent, 0, gtk.MESSAGE_QUESTION, gtk.BUTTONS_CANCEL,
			_('Enter the URL of the new source of implementations of this interface:'))
		d.add_button(gtk.STOCK_ADD, gtk.RESPONSE_OK)
		d.set_default_response(gtk.RESPONSE_OK)
		entry = gtk.Entry()

		align = gtk.VBox(False, 0)
		align.set_border_width(4)
		align.add(entry)
		d.vbox.pack_start(align)
		entry.set_activates_default(True)

		entry.set_text('')

		d.vbox.show_all()

		error_label = gtk.Label('')
		error_label.set_padding(4, 4)
		align.pack_start(error_label)

		d.show()

		def error(message):
			if message:
				error_label.set_text(message)
				error_label.show()
			else:
				error_label.hide()

		while True:
			got_response = DialogResponse(d)
			yield got_response
			tasks.check(got_response)
			resp = got_response.response

			error(None)
			if resp == gtk.RESPONSE_OK:
				try:
					url = entry.get_text()
					if not url:
						raise zeroinstall.SafeException(_('Enter a URL'))
					fetch = policy.fetcher.download_and_import_feed(url, iface_cache)
					if fetch:
						d.set_sensitive(False)
						yield fetch
						d.set_sensitive(True)
						tasks.check(fetch)

						iface = iface_cache.get_interface(url)

						d.set_sensitive(True)
						if not iface.name:
							error(_('Failed to read interface'))
							return
						if not iface.feed_for:
							error(_("Feed '%(feed)s' is not a feed for '%(feed_for)s'.") % {'feed': iface.get_name(), 'feed_for': interface.get_name()})
						elif interface.uri not in iface.feed_for:
							error(_("This is not a feed for '%(uri)s'.\nOnly for:\n%(feed_for)s") %
								{'uri': interface.uri, 'feed_for': '\n'.join(iface.feed_for)})
						elif iface.uri in [f.uri for f in interface.extra_feeds]:
							error(_("Feed from '%s' has already been added!") % iface.uri)
						else:
							interface.extra_feeds.append(Feed(iface.uri, arch = None, user_override = True))
							writer.save_interface(interface)
							d.destroy()
							import main
							main.recalculate()
				except zeroinstall.SafeException as ex:
					error(str(ex))
			else:
				d.destroy()
				return
	except Exception as ex:
		import traceback
		traceback.print_exc()
		policy.handler.report_error(ex)