Пример #1
0
	def set_items(self, items):
		self.model.clear()
		for item, unusable in items:
			new = self.model.append()
			self.model[new][ITEM] = item
			self.model[new][VERSION] = item.get_version()
			self.model[new][RELEASED] = item.released or "-"
			self.model[new][FETCH] = utils.get_fetch_info(self.policy, item)
			if item.user_stability:
				if item.user_stability == model.insecure:
					self.model[new][STABILITY] = _('INSECURE')
				elif item.user_stability == model.buggy:
					self.model[new][STABILITY] = _('BUGGY')
				elif item.user_stability == model.developer:
					self.model[new][STABILITY] = _('DEVELOPER')
				elif item.user_stability == model.testing:
					self.model[new][STABILITY] = _('TESTING')
				elif item.user_stability == model.stable:
					self.model[new][STABILITY] = _('STABLE')
				elif item.user_stability == model.packaged:
					self.model[new][STABILITY] = _('PACKAGED')
				elif item.user_stability == model.preferred:
					self.model[new][STABILITY] = _('PREFERRED')
			else:
				self.model[new][STABILITY] = _(str(item.upstream_stability) or str(model.testing))
			self.model[new][ARCH] = item.arch or _('any')
			self.model[new][UNUSABLE] = bool(unusable)
			self.model[new][NOTES] = _(unusable)
Пример #2
0
	def set_items(self, items):
		self.model.clear()
		selected = self.policy.solver.selections.get(self.interface, None)
		for item, unusable in items:
			new = self.model.append()
			self.model[new][ITEM] = item
			self.model[new][VERSION] = item.get_version()
			self.model[new][RELEASED] = item.released or "-"
			self.model[new][FETCH] = utils.get_fetch_info(self.policy, item)
			if item.user_stability:
				if item.user_stability == model.insecure:
					self.model[new][STABILITY] = _('INSECURE')
				elif item.user_stability == model.buggy:
					self.model[new][STABILITY] = _('BUGGY')
				elif item.user_stability == model.developer:
					self.model[new][STABILITY] = _('DEVELOPER')
				elif item.user_stability == model.testing:
					self.model[new][STABILITY] = _('TESTING')
				elif item.user_stability == model.stable:
					self.model[new][STABILITY] = _('STABLE')
				elif item.user_stability == model.packaged:
					self.model[new][STABILITY] = _('PACKAGED')
				elif item.user_stability == model.preferred:
					self.model[new][STABILITY] = _('PREFERRED')
			else:
				self.model[new][STABILITY] = _(str(item.upstream_stability) or str(model.testing))
			self.model[new][ARCH] = item.arch or _('any')
			if selected is item:
				self.model[new][WEIGHT] = pango.WEIGHT_BOLD
			else:
				self.model[new][WEIGHT] = pango.WEIGHT_NORMAL
			self.model[new][UNUSABLE] = bool(unusable)
			self.model[new][LANGS] = item.langs or '-'
			self.model[new][NOTES] = unusable and _(unusable) or _('None')
Пример #3
0
        def add_node(parent, iface, command, essential):
            # (command is the index into commands, if any)
            if iface in done:
                return
            done[iface] = True

            main_feed = iface_cache.get_feed(iface.uri)
            if main_feed:
                name = main_feed.get_name()
                summary = main_feed.summary
            else:
                name = iface.get_name()
                summary = None

            iter = self.model.append(parent)
            self.model[iter][InterfaceBrowser.INTERFACE] = iface
            self.model[iter][InterfaceBrowser.INTERFACE_NAME] = name
            self.model[iter][InterfaceBrowser.SUMMARY] = summary
            self.model[iter][InterfaceBrowser.
                             ICON] = self.get_icon(iface) or self.default_icon
            self.model[iter][InterfaceBrowser.PROBLEM] = False

            sel = self.policy.solver.selections.selections.get(iface.uri, None)
            if sel:
                impl = sel.impl
                old_impl = self.original_implementation.get(iface, None)
                version_str = impl.get_version()
                if old_impl is not None and old_impl.id != impl.id:
                    version_str += _(' (was %s)') % old_impl.get_version()
                self.model[iter][InterfaceBrowser.VERSION] = version_str

                self.model[iter][
                    InterfaceBrowser.DOWNLOAD_SIZE] = utils.get_fetch_info(
                        self.policy, impl)

                deps = sel.dependencies
                if command is not None:
                    deps += commands[command].requires
                for child in deps:
                    if isinstance(child, model.InterfaceDependency):
                        if child.qdom.name == 'runner':
                            child_command = command + 1
                        else:
                            child_command = None
                        add_node(
                            iter, iface_cache.get_interface(child.interface),
                            child_command,
                            child.importance == model.Dependency.Essential)
                    else:
                        child_iter = self.model.append(parent)
                        self.model[child_iter][
                            InterfaceBrowser.INTERFACE_NAME] = '?'
                        self.model[child_iter][InterfaceBrowser.SUMMARY] = \
                         _('Unknown dependency type : %s') % child
                        self.model[child_iter][
                            InterfaceBrowser.ICON] = self.default_icon
            else:
                self.model[iter][InterfaceBrowser.PROBLEM] = essential
                self.model[iter][InterfaceBrowser.VERSION] = _(
                    '(problem)') if essential else _('(none)')
Пример #4
0
	def update_download_status(self):
		"""Called at regular intervals while there are downloads in progress,
		and once at the end. Also called when things are added to the store.
		Update the TreeView with the interfaces."""

		# A download may be for a feed, an interface or an implementation.
		# Create the reverse mapping (item -> download)
		hints = {}
		for dl in self.policy.handler.monitored_downloads.values():
			if dl.hint:
				if dl.hint not in hints:
					hints[dl.hint] = []
				hints[dl.hint].append(dl)

		selections = self.policy.solver.selections

		# Only update currently visible rows
		if self.tree_view.get_visible_range() != None:
			firstVisiblePath, lastVisiblePath = self.tree_view.get_visible_range()
			firstVisibleIter = self.model.get_iter(firstVisiblePath)
			lastVisibleIter = self.model.get_iter(lastVisiblePath)
		else:
			firstVisibleIter = self.model.get_iter_root()
			lastVisibleIter = None

		for row in walk(self.model, firstVisibleIter, lastVisibleIter):
			iface = row[InterfaceBrowser.INTERFACE]

			# Is this interface the download's hint?
			downloads = hints.get(iface, [])	# The interface itself
		     	downloads += hints.get(iface.uri, [])	# The main feed
			for feed in self.policy.usable_feeds(iface):
				downloads += hints.get(feed.uri, []) # Other feeds
			impl = selections.get(iface, None)
			if impl:
				downloads += hints.get(impl, []) # The chosen implementation

			if downloads:
				so_far = 0
				expected = None
				for dl in downloads:
					if dl.expected_size:
						expected = (expected or 0) + dl.expected_size
					so_far += dl.get_bytes_downloaded_so_far()
				if expected:
					summary = ngettext("(downloading %(downloaded)s/%(expected)s [%(percentage).2f%%])",
							   "(downloading %(downloaded)s/%(expected)s [%(percentage).2f%%] in %(number)d downloads)",
							   downloads)
					values_dict = {'downloaded': pretty_size(so_far), 'expected': pretty_size(expected), 'percentage': 100 * so_far / float(expected), 'number': len(downloads)}
				else:
					summary = ngettext("(downloading %(downloaded)s/unknown)",
							   "(downloading %(downloaded)s/unknown in %(number)d downloads)",
							   downloads)
					values_dict = {'downloaded': pretty_size(so_far), 'number': len(downloads)}
				row[InterfaceBrowser.SUMMARY] = summary % values_dict
			else:
				row[InterfaceBrowser.DOWNLOAD_SIZE] = utils.get_fetch_info(self.policy, impl)
				row[InterfaceBrowser.SUMMARY] = iface.summary
Пример #5
0
		def add_node(parent, iface, command, essential):
			# (command is the index into commands, if any)
			if iface in done:
				return
			done[iface] = True

			main_feed = iface_cache.get_feed(iface.uri)
			if main_feed:
				name = main_feed.get_name()
				summary = main_feed.summary
			else:
				name = iface.get_name()
				summary = None

			iter = self.model.append(parent)
			self.model[iter][InterfaceBrowser.INTERFACE] = iface
			self.model[iter][InterfaceBrowser.INTERFACE_NAME] = name
			self.model[iter][InterfaceBrowser.SUMMARY] = summary
			self.model[iter][InterfaceBrowser.ICON] = self.get_icon(iface) or self.default_icon
			self.model[iter][InterfaceBrowser.PROBLEM] = False

			sel = self.policy.solver.selections.selections.get(iface.uri, None)
			if sel:
				impl = sel.impl
				old_impl = self.original_implementation.get(iface, None)
				version_str = impl.get_version()
				if old_impl is not None and old_impl.id != impl.id:
					version_str += _(' (was %s)') % old_impl.get_version()
				self.model[iter][InterfaceBrowser.VERSION] = version_str

				self.model[iter][InterfaceBrowser.DOWNLOAD_SIZE] = utils.get_fetch_info(self.policy, impl)

				deps = sel.dependencies
				if command is not None:
					deps += commands[command].requires
				for child in deps:
					if isinstance(child, model.InterfaceDependency):
						if child.qdom.name == 'runner':
							child_command = command + 1
						else:
							child_command = None
						add_node(iter, iface_cache.get_interface(child.interface), child_command, child.importance == model.Dependency.Essential)
					else:
						child_iter = self.model.append(parent)
						self.model[child_iter][InterfaceBrowser.INTERFACE_NAME] = '?'
						self.model[child_iter][InterfaceBrowser.SUMMARY] = \
							_('Unknown dependency type : %s') % child
						self.model[child_iter][InterfaceBrowser.ICON] = self.default_icon
			else:
				self.model[iter][InterfaceBrowser.PROBLEM] = essential
				self.model[iter][InterfaceBrowser.VERSION] = _('(problem)') if essential else _('(none)')
        def add_node(parent, iface):
            if iface in done:
                return
            done[iface] = True

            iter = self.model.append(parent)
            self.model[iter][InterfaceBrowser.INTERFACE] = iface
            self.model[iter][
                InterfaceBrowser.INTERFACE_NAME] = iface.get_name()
            self.model[iter][InterfaceBrowser.SUMMARY] = iface.summary
            self.model[iter][InterfaceBrowser.
                             ICON] = self.get_icon(iface) or self.default_icon

            impl = self.policy.implementation.get(iface, None)
            if impl:
                old_impl = self.original_implementation.get(iface, None)
                version_str = impl.get_version()
                if old_impl is not None and old_impl is not impl:
                    version_str += _(' (was %s)') % old_impl.get_version()
                self.model[iter][InterfaceBrowser.VERSION] = version_str

                self.model[iter][
                    InterfaceBrowser.DOWNLOAD_SIZE] = utils.get_fetch_info(
                        self.policy, impl)
                children = self.policy.solver.requires[iface]

                for child in children:
                    if isinstance(child, model.InterfaceDependency):
                        add_node(iter,
                                 iface_cache.get_interface(child.interface))
                    else:
                        child_iter = self.model.append(parent)
                        self.model[child_iter][
                            InterfaceBrowser.INTERFACE_NAME] = '?'
                        self.model[child_iter][InterfaceBrowser.SUMMARY] = \
                         _('Unknown dependency type : %s') % child
                        self.model[child_iter][
                            InterfaceBrowser.ICON] = self.default_icon
            else:
                self.model[iter][InterfaceBrowser.VERSION] = _('(choose)')
Пример #7
0
 def set_items(self, items):
     self.model.clear()
     selected = self.driver.solver.selections.get(self.interface, None)
     for item, unusable in items:
         new = self.model.append()
         self.model[new][ITEM] = item
         self.model[new][VERSION] = item.get_version()
         self.model[new][RELEASED] = item.released or "-"
         self.model[new][FETCH] = utils.get_fetch_info(
             self.driver.config, item)
         if item.user_stability:
             if item.user_stability == model.insecure:
                 self.model[new][STABILITY] = _('INSECURE')
             elif item.user_stability == model.buggy:
                 self.model[new][STABILITY] = _('BUGGY')
             elif item.user_stability == model.developer:
                 self.model[new][STABILITY] = _('DEVELOPER')
             elif item.user_stability == model.testing:
                 self.model[new][STABILITY] = _('TESTING')
             elif item.user_stability == model.stable:
                 self.model[new][STABILITY] = _('STABLE')
             elif item.user_stability == model.packaged:
                 self.model[new][STABILITY] = _('PACKAGED')
             elif item.user_stability == model.preferred:
                 self.model[new][STABILITY] = _('PREFERRED')
         else:
             self.model[new][STABILITY] = _(
                 str(item.upstream_stability) or str(model.testing))
         self.model[new][ARCH] = item.arch or _('any')
         if selected is item:
             self.model[new][WEIGHT] = pango.WEIGHT_BOLD
         else:
             self.model[new][WEIGHT] = pango.WEIGHT_NORMAL
         self.model[new][UNUSABLE] = bool(unusable)
         self.model[new][LANGS] = item.langs or '-'
         self.model[new][NOTES] = unusable and _(unusable) or _('None')
Пример #8
0
	def update_download_status(self, only_update_visible = False):
		"""Called at regular intervals while there are downloads in progress,
		and once at the end. Also called when things are added to the store.
		Update the TreeView with the interfaces."""

		# A download may be for a feed, an interface or an implementation.
		# Create the reverse mapping (item -> download)
		hints = {}
		for dl in self.config.handler.monitored_downloads:
			if dl.hint:
				if dl.hint not in hints:
					hints[dl.hint] = []
				hints[dl.hint].append(dl)

		selections = self.driver.solver.selections

		# Only update currently visible rows
		if only_update_visible and self.tree_view.get_visible_range() != None:
			firstVisiblePath, lastVisiblePath = self.tree_view.get_visible_range()
			firstVisibleIter = self.model.get_iter(firstVisiblePath)
		else:
			# (or should we just wait until the TreeView has settled enough to tell
			# us what is visible?)
			firstVisibleIter = self.model.get_iter_root()
			lastVisiblePath = None

		solver = self.driver.solver
		requirements = self.driver.requirements
		iface_cache = self.config.iface_cache

		for it in walk(self.model, firstVisibleIter):
			row = self.model[it]
			iface = row[InterfaceBrowser.INTERFACE]

			# Is this interface the download's hint?
			downloads = hints.get(iface, [])	# The interface itself
			downloads += hints.get(iface.uri, [])	# The main feed

			arch = solver.get_arch_for(requirements, iface)
			for feed in iface_cache.usable_feeds(iface, arch):
				downloads += hints.get(feed.uri, []) # Other feeds
			impl = selections.get(iface, None)
			if impl:
				downloads += hints.get(impl, []) # The chosen implementation

			if downloads:
				so_far = 0
				expected = None
				for dl in downloads:
					if dl.expected_size:
						expected = (expected or 0) + dl.expected_size
					so_far += dl.get_bytes_downloaded_so_far()
				if expected:
					summary = ngettext("(downloading %(downloaded)s/%(expected)s [%(percentage).2f%%])",
							   "(downloading %(downloaded)s/%(expected)s [%(percentage).2f%%] in %(number)d downloads)",
							   downloads)
					values_dict = {'downloaded': pretty_size(so_far), 'expected': pretty_size(expected), 'percentage': 100 * so_far / float(expected), 'number': len(downloads)}
				else:
					summary = ngettext("(downloading %(downloaded)s/unknown)",
							   "(downloading %(downloaded)s/unknown in %(number)d downloads)",
							   downloads)
					values_dict = {'downloaded': pretty_size(so_far), 'number': len(downloads)}
				row[InterfaceBrowser.SUMMARY] = summary % values_dict
			else:
				feed = iface_cache.get_feed(iface.uri)
				row[InterfaceBrowser.DOWNLOAD_SIZE] = utils.get_fetch_info(self.config, impl)
				row[InterfaceBrowser.SUMMARY] = feed.summary if feed else "-"

			if self.model.get_path(it) == lastVisiblePath:
				break
Пример #9
0
    def update_download_status(self):
        """Called at regular intervals while there are downloads in progress,
		and once at the end. Also called when things are added to the store.
		Update the TreeView with the interfaces."""

        # A download may be for a feed, an interface or an implementation.
        # Create the reverse mapping (item -> download)
        hints = {}
        for dl in self.policy.handler.monitored_downloads.values():
            if dl.hint:
                if dl.hint not in hints:
                    hints[dl.hint] = []
                hints[dl.hint].append(dl)

        selections = self.policy.solver.selections

        # Only update currently visible rows
        if self.tree_view.get_visible_range() != None:
            firstVisiblePath, lastVisiblePath = self.tree_view.get_visible_range(
            )
            firstVisibleIter = self.model.get_iter(firstVisiblePath)
            lastVisibleIter = self.model.get_iter(lastVisiblePath)
        else:
            firstVisibleIter = self.model.get_iter_root()
            lastVisibleIter = None

        for row in walk(self.model, firstVisibleIter, lastVisibleIter):
            iface = row[InterfaceBrowser.INTERFACE]

            # Is this interface the download's hint?
            downloads = hints.get(iface, [])  # The interface itself
            downloads += hints.get(iface.uri, [])  # The main feed
            for feed in self.policy.usable_feeds(iface):
                downloads += hints.get(feed.uri, [])  # Other feeds
            impl = selections.get(iface, None)
            if impl:
                downloads += hints.get(impl, [])  # The chosen implementation

            if downloads:
                so_far = 0
                expected = None
                for dl in downloads:
                    if dl.expected_size:
                        expected = (expected or 0) + dl.expected_size
                    so_far += dl.get_bytes_downloaded_so_far()
                if expected:
                    summary = ngettext(
                        "(downloading %(downloaded)s/%(expected)s [%(percentage).2f%%])",
                        "(downloading %(downloaded)s/%(expected)s [%(percentage).2f%%] in %(number)d downloads)",
                        downloads)
                    values_dict = {
                        'downloaded': pretty_size(so_far),
                        'expected': pretty_size(expected),
                        'percentage': 100 * so_far / float(expected),
                        'number': len(downloads)
                    }
                else:
                    summary = ngettext(
                        "(downloading %(downloaded)s/unknown)",
                        "(downloading %(downloaded)s/unknown in %(number)d downloads)",
                        downloads)
                    values_dict = {
                        'downloaded': pretty_size(so_far),
                        'number': len(downloads)
                    }
                row[InterfaceBrowser.SUMMARY] = summary % values_dict
            else:
                row[InterfaceBrowser.DOWNLOAD_SIZE] = utils.get_fetch_info(
                    self.policy, impl)
                row[InterfaceBrowser.SUMMARY] = iface.summary
    def update_download_status(self):
        """Called at regular intervals while there are downloads in progress,
		and once at the end. Also called when things are added to the store.
		Update the TreeView with the interfaces."""
        hints = {}
        for dl in self.policy.handler.monitored_downloads.values():
            if dl.hint:
                if dl.hint not in hints:
                    hints[dl.hint] = []
                hints[dl.hint].append(dl)

        selections = self.policy.solver.selections

        def walk(it):
            while it:
                yield self.model[it]
                for x in walk(self.model.iter_children(it)):
                    yield x
                it = self.model.iter_next(it)

        for row in walk(self.model.get_iter_root()):
            iface = row[InterfaceBrowser.INTERFACE]

            # Is this interface the download's hint?
            downloads = hints.get(iface, [])  # The interface itself
            downloads += hints.get(iface.uri, [])  # The main feed
            for feed in iface.feeds:
                downloads += hints.get(feed.uri, [])  # Other feeds
            impl = selections.get(iface, None)
            if impl:
                downloads += hints.get(impl, [])  # The chosen implementation

            if downloads:
                so_far = 0
                expected = None
                for dl in downloads:
                    if dl.expected_size:
                        expected = (expected or 0) + dl.expected_size
                    so_far += dl.get_bytes_downloaded_so_far()
                if expected:
                    summary = ngettext(
                        "(downloading %(downloaded)s/%(expected)s [%(percentage).2f%%])",
                        "(downloading %(downloaded)s/%(expected)s [%(percentage).2f%%] in %(number)d downloads)",
                        downloads)
                    values_dict = {
                        'downloaded': pretty_size(so_far),
                        'expected': pretty_size(expected),
                        'percentage': 100 * so_far / float(expected),
                        'number': len(downloads)
                    }
                else:
                    summary = ngettext(
                        "(downloading %(downloaded)s/unknown)",
                        "(downloading %(downloaded)s/unknown in %(number)d downloads)",
                        downloads)
                    values_dict = {
                        'downloaded': pretty_size(so_far),
                        'number': len(downloads)
                    }
                row[InterfaceBrowser.SUMMARY] = summary % values_dict
            else:
                row[InterfaceBrowser.DOWNLOAD_SIZE] = utils.get_fetch_info(
                    self.policy, impl)
                row[InterfaceBrowser.SUMMARY] = iface.summary