Пример #1
0
    def __init__(self, entropy_client, avc, updates_len, security_updates_len):
        self._entropy = entropy_client
        self._avc = avc

        msg = ngettext("There is <b>%d</b> update",
                       "There are <b>%d</b> updates", updates_len)
        msg = msg % (updates_len, )

        if security_updates_len > 0:
            sec_msg = ", " + ngettext("and <b>%d</b> security update",
                                      "and <b>%d</b> security updates",
                                      security_updates_len)
            sec_msg = sec_msg % (security_updates_len, )
            msg += sec_msg

        msg += ". " + _("What to do?")

        NotificationBox.__init__(
            self,
            prepare_markup(msg),
            tooltip=prepare_markup(
                _("Updates available, how about installing them?")),
            message_type=Gtk.MessageType.WARNING,
            context_id="UpdatesNotificationBox")
        self.add_button(_("_Update"), self._update)
        self.add_button(_("_Show"), self._show)
        self.add_destroy_button(_("_Ignore"))
        self.add_destroy_button(_("Srsly, ignore!"),
                                callback=UpdatesNotificationBox.snooze)
Пример #2
0
    def __init__(self, entropy_client, avc,
                 updates_len, security_updates_len):
        self._entropy = entropy_client
        self._avc = avc

        msg = ngettext("There is <b>%d</b> update",
                       "There are <b>%d</b> updates",
                       updates_len)
        msg = msg % (updates_len,)

        if security_updates_len > 0:
            sec_msg = ", " + ngettext("and <b>%d</b> security update",
                                      "and <b>%d</b> security updates",
                                      security_updates_len)
            sec_msg = sec_msg % (security_updates_len,)
            msg += sec_msg

        msg += ". " + _("What to do?")

        NotificationBox.__init__(self, prepare_markup(msg),
            tooltip=prepare_markup(
                _("Updates available, how about installing them?")),
            message_type=Gtk.MessageType.WARNING,
            context_id="UpdatesNotificationBox")
        self.add_button(_("_Update"), self._update)
        self.add_button(_("_Show"), self._show)
        self.add_destroy_button(_("_Ignore"))
        self.add_destroy_button(_("Srsly, ignore!"),
                                callback=UpdatesNotificationBox.snooze)
Пример #3
0
    def _fetch_phase(self):
        """
        Execute the fetch phase.
        """
        m_fetch_len = len(self._meta['multi_fetch_list']) / 2
        xterm_title = "%s: %s %s" % (
            _("Downloading"),
            m_fetch_len,
            ngettext("package", "packages", m_fetch_len),
        )
        self._entropy.set_title(xterm_title)

        m_fetch_len = len(self._meta['multi_fetch_list'])
        txt = "%s: %s %s" % (
            blue(_("Downloading")),
            darkred("%s" % (m_fetch_len, )),
            ngettext("package", "packages", m_fetch_len),
        )
        self._entropy.output(txt,
                             importance=1,
                             level="info",
                             header=red("   ## "))

        exit_st, err_list = self._download_packages(
            self._meta['multi_fetch_list'])
        if exit_st == 0:
            return 0

        txt = _("Some packages cannot be fetched")
        txt2 = _("Try to update your repositories and retry")
        for txt in (
                txt,
                txt2,
        ):
            self._entropy.output("%s." % (darkred(txt), ),
                                 importance=0,
                                 level="info",
                                 header=red("   ## "))

        self._entropy.output("%s: %s" % (
            brown(_("Error")),
            exit_st,
        ),
                             importance=0,
                             level="info",
                             header=red("   ## "))

        for _pkg_id, repo, fname, cksum, _signatures in err_list:
            self._entropy.output("[%s|%s] %s" % (
                blue(repo),
                darkgreen(cksum),
                darkred(fname),
            ),
                                 importance=1,
                                 level="error",
                                 header=darkred("    # "))

        return exit_st
Пример #4
0
    def _show_config_files_update(self, entropy_client):
        """
        Inform User about configuration file updates, if any.
        """
        entropy_client.output(
            blue(_("Scanning configuration files to update")),
            header=darkgreen(" @@ "),
            back=True)

        updates = entropy_client.ConfigurationUpdates()
        scandata = updates.get()

        if not scandata:
            entropy_client.output(
                blue(_("No configuration files to update.")),
                header=darkgreen(" @@ "))
            return

        mytxt = ngettext(
            "There is %s configuration file needing update",
            "There are %s configuration files needing update",
            len(scandata)) % (len(scandata),)
        entropy_client.output(
            darkgreen(mytxt),
            level="warning")

        mytxt = "%s: %s" % (
            purple(_("Please run")),
            bold("equo conf update"))
        entropy_client.output(
            darkgreen(mytxt),
            level="warning")
Пример #5
0
    def new_updates_signal(self, update_atoms, one_click_update=False):
        if not config.settings['APPLET_ENABLED']:
            return

        del self.package_updates[:]
        self.package_updates.extend(update_atoms)
        upd_len = len(update_atoms)

        def upgrade_cb(*args):
            self.launch_package_manager(other_args=["--upgrade"])

        if upd_len:
            self.update_tooltip(ngettext("There is %s update available",
                "There are %s updates available",
                upd_len) % (upd_len,)
            )
            self.set_state("CRITICAL")
            self.show_alert(
                _("Sabayon updates available"),
                _("Updates are available"),
                urgency = "normal",
                force = self.manual_check_triggered,
                buttons = [("upgrade", _("Upgrade now"), upgrade_cb,)]
            )
        else:
            # all fine, no updates
            self.update_tooltip(_("Your Sabayon is up-to-date"))
            self.set_state("OKAY")
            self.show_alert(_("Your Sabayon is up-to-date"),
                _("No updates available at this time, cool!"),
                force = self.manual_check_triggered
            )

        self.manual_check_triggered = False
Пример #6
0
    def _required(self, entropy_client, inst_repo):
        """
        Solo Query Required command.
        """
        quiet = self._nsargs.quiet
        verbose = self._nsargs.verbose
        libraries = self._nsargs.libraries

        if not quiet:
            entropy_client.output(darkgreen(_("Required Packages Search")), header=darkred(" @@ "))

        key_sorter = lambda x: inst_repo.retrieveAtom(x)
        for library in libraries:
            results = inst_repo.searchNeeded(library, like=True)

            for pkg_id in sorted(results, key=key_sorter):
                print_package_info(
                    pkg_id,
                    entropy_client,
                    inst_repo,
                    installed_search=True,
                    strict_output=True,
                    extended=verbose,
                    quiet=quiet,
                )

            if not quiet:
                toc = []
                entity_str = ngettext("package", "packages", len(results))
                toc.append(("%s:" % (blue(_("Library")),), purple(library)))
                toc.append(("%s:" % (blue(_("Found")),), "%s %s" % (len(results), brown(entity_str))))
                print_table(entropy_client, toc)

        return 0
Пример #7
0
    def _search_descriptions(self, descriptions, entropy_client, entropy_repository, quiet, verbose):

        key_sorter = lambda x: entropy_repository.retrieveAtom(x)
        found = 0
        for desc in descriptions:

            pkg_ids = entropy_repository.searchDescription(desc, just_id=True)
            if not pkg_ids:
                continue

            found += len(pkg_ids)
            for pkg_id in sorted(pkg_ids, key=key_sorter):
                if quiet:
                    entropy_client.output(entropy_repository.retrieveAtom(pkg_id))
                else:
                    print_package_info(
                        pkg_id, entropy_client, entropy_repository, extended=verbose, strict_output=False, quiet=False
                    )

            if not quiet:
                toc = []
                toc.append(("%s:" % (blue(_("Keyword")),), purple(desc)))
                toc.append(
                    (
                        "%s:" % (blue(_("Found")),),
                        "%s %s" % (len(pkg_ids), brown(ngettext("entry", "entries", len(pkg_ids)))),
                    )
                )
                print_table(entropy_client, toc)

        return found
Пример #8
0
    def _show_preserved_libraries(self, entropy_client):
        """
        Inform User about preserved libraries living on the filesystem.
        This method is process and thread safe.
        """
        inst_repo = entropy_client.installed_repository()
        with inst_repo.shared():
            preserved_mgr = PreservedLibraries(
                inst_repo, None, frozenset(), root=etpConst['systemroot'])

            preserved = preserved_mgr.list()

        if preserved:
            mytxt = ngettext(
                "There is %s preserved library on the system",
                "There are %s preserved libraries on the system",
                len(preserved)) % (len(preserved),)
            entropy_client.output(
                darkgreen(mytxt),
                level="warning")

        for library, elfclass, path, atom in preserved:
            entropy_client.output(
                "%s [%s:%s -> %s]" % (
                    darkred(path),
                    purple(library),
                    teal(const_convert_to_unicode(elfclass)),
                    enlightenatom(atom),
                ))
Пример #9
0
    def new_updates_signal(self, update_atoms, one_click_update=False):
        if not config.settings['APPLET_ENABLED']:
            return

        del self.package_updates[:]
        self.package_updates.extend(update_atoms)
        upd_len = len(update_atoms)

        def upgrade_cb(*args):
            self.launch_package_manager(other_args=["--upgrade"])

        if upd_len:
            self.update_tooltip(ngettext("There is %s update available",
                "There are %s updates available",
                upd_len) % (upd_len,)
            )
            self.set_state("CRITICAL")
            self.show_alert(
                _("Sabayon updates available"),
                _("Updates are available"),
                urgency = "normal",
                force = self.manual_check_triggered,
                buttons = [("upgrade", _("Upgrade now"), upgrade_cb,)]
            )
        else:
            # all fine, no updates
            self.update_tooltip(_("Your Sabayon is up-to-date"))
            self.set_state("OKAY")
            self.show_alert(_("Your Sabayon is up-to-date"),
                _("No updates available at this time, cool!"),
                force = self.manual_check_triggered
            )

        self.manual_check_triggered = False
Пример #10
0
    def update_queue_information(self, queue_len):
        """
        Update Action Queue related info.
        """
        daemon_action = self._last_daemon_action
        msg = None
        if daemon_action == DaemonAppActions.INSTALL:
            msg = _("Installing")
        elif daemon_action == DaemonAppActions.REMOVE:
            msg = _("Removing")

        if msg is not None:
            more_msg = ""
            queue_len -= 1
            queue_len = max(0, queue_len)
            if queue_len:
                more_msg = ngettext(", and <b>%d</b> <i>more in queue</i>",
                                    ", and <b>%d</b> <i>more in queue</i>",
                                    queue_len)
                more_msg = prepare_markup(more_msg % (queue_len, ))

            self._action_label.set_markup("<big><b>%s</b>%s</big>" % (
                escape_markup(msg),
                more_msg,
            ))
Пример #11
0
 def __show_download_files_info(self):
     count = 0
     pl = self._url_path_list[:]
     TextInterface.output(
         "%s: %s %s" % (
             darkblue(_("Aggregated download")),
             darkred(str(len(pl))),
             darkblue(ngettext("item", "items", len(pl))),
         ),
         importance = 0,
         level = "info",
         header = purple("  ## ")
     )
     for url, save_path in pl:
         count += 1
         fname = os.path.basename(url)
         uri = spliturl(url)[1]
         TextInterface.output(
             "[%s] %s => %s" % (
                 darkblue(str(count)),
                 darkgreen(uri),
                 blue(fname),
             ),
             importance = 0,
             level = "info",
             header = brown("   # ")
         )
Пример #12
0
    def update_queue_information(self, queue_len):
        """
        Update Action Queue related info.
        """
        daemon_action = self._last_daemon_action
        msg = None
        if daemon_action == DaemonAppActions.INSTALL:
            msg = _("Installing")
        elif daemon_action == DaemonAppActions.REMOVE:
            msg = _("Removing")

        if msg is not None:
            more_msg = ""
            queue_len -= 1
            queue_len = max(0, queue_len)
            if queue_len:
                more_msg = ngettext(
                    ", and <b>%d</b> <i>more in queue</i>",
                    ", and <b>%d</b> <i>more in queue</i>",
                    queue_len)
                more_msg = prepare_markup(more_msg % (queue_len,))

            self._action_label.set_markup(
                "<big><b>%s</b>%s</big>" % (
                    escape_markup(msg),
                    more_msg,))
Пример #13
0
    def _show_preserved_libraries(self, entropy_client):
        """
        Inform User about preserved libraries living on the filesystem.
        This method is process and thread safe.
        """
        inst_repo = entropy_client.installed_repository()
        with inst_repo.shared():
            preserved_mgr = PreservedLibraries(inst_repo,
                                               None,
                                               frozenset(),
                                               root=etpConst['systemroot'])

            preserved = preserved_mgr.list()

        if preserved:
            mytxt = ngettext("There is %s preserved library on the system",
                             "There are %s preserved libraries on the system",
                             len(preserved)) % (len(preserved), )
            entropy_client.output(darkgreen(mytxt), level="warning")

        for library, elfclass, path, atom in preserved:
            entropy_client.output("%s [%s:%s -> %s]" % (
                darkred(path),
                purple(library),
                teal(const_convert_to_unicode(elfclass)),
                enlightenatom(atom),
            ))
Пример #14
0
 def __show_download_files_info(self):
     count = 0
     pl = self._url_path_list[:]
     TextInterface.output(
         "%s: %s %s" % (
             darkblue(_("Aggregated download")),
             darkred(str(len(pl))),
             darkblue(ngettext("item", "items", len(pl))),
         ),
         importance = 0,
         level = "info",
         header = purple("  ## ")
     )
     for url, save_path in pl:
         count += 1
         fname = os.path.basename(url)
         uri = spliturl(url)[1]
         TextInterface.output(
             "[%s] %s => %s" % (
                 darkblue(str(count)),
                 darkgreen(uri),
                 blue(fname),
             ),
             importance = 0,
             level = "info",
             header = brown("   # ")
         )
Пример #15
0
    def search(self, entropy_client, inst_repo):
        """
        Solo Search command.
        """
        if not self._quiet:
            entropy_client.output("%s..." % (darkgreen(_("Searching")), ),
                                  header=darkred(" @@ "))

        matches_found = 0
        for string in self._packages:
            results = self._search(entropy_client, inst_repo, string)
            matches_found += len(results)

        if not self._quiet:
            toc = []
            toc.append(("%s:" % (blue(_("Keywords")), ),
                        purple(', '.join(self._packages))))
            toc.append(("%s:" % (blue(_("Found")), ), "%s %s" % (
                matches_found,
                brown(ngettext("entry", "entries", matches_found)),
            )))
            print_table(entropy_client, toc)

        if not matches_found:
            return 1
        return 0
Пример #16
0
    def _notify_vote_submit(self, app, username, vote):
        """
        Notify User about Comment submission with current credentials.
        """
        msg = ngettext("Rate <b>%s</b> as <b>%s</b>, with <b>%d</b> star?",
                       "Rate <b>%s</b> as <b>%s</b>, with <b>%d</b> stars?",
                       vote)
        msg = msg % (
            app.name,
            escape_markup(username),
            vote,
        )
        box = NotificationBox(msg,
                              message_type=Gtk.MessageType.INFO,
                              context_id=self.VOTE_NOTIFICATION_CONTEXT_ID)

        def _vote_submit(widget):
            self._vote_submit(app, username, vote)

        box.add_button(_("_Ok, cool!"), _vote_submit)

        def _send_vote():
            self._on_stars_clicked(self._stars, app=app)

        def _logout_webservice(widget):
            self._logout_webservice(app, _send_vote)

        box.add_button(_("_No, logout!"), _logout_webservice)

        box.add_destroy_button(_("_Later"))
        self._nc.append(box)
Пример #17
0
    def _notify_vote_submit(self, app, username, vote):
        """
        Notify User about Comment submission with current credentials.
        """
        msg = ngettext(
            "Rate <b>%s</b> as <b>%s</b>, with <b>%d</b> star?",
            "Rate <b>%s</b> as <b>%s</b>, with <b>%d</b> stars?",
            vote,
        )
        msg = msg % (app.name, escape_markup(username), vote)
        box = NotificationBox(msg, message_type=Gtk.MessageType.INFO, context_id=self.VOTE_NOTIFICATION_CONTEXT_ID)

        def _vote_submit(widget):
            self._vote_submit(app, username, vote)

        box.add_button(_("_Ok, cool!"), _vote_submit)

        def _send_vote():
            self._on_stars_clicked(self._stars, app=app)

        def _logout_webservice(widget):
            self._logout_webservice(app, _send_vote)

        box.add_button(_("_No, logout!"), _logout_webservice)

        box.add_destroy_button(_("_Later"))
        self._nc.append(box)
Пример #18
0
    def match(self, entropy_client):
        """
        Solo Match command.
        """
        if not self._quiet:
            entropy_client.output(
                "%s..." % (darkgreen(_("Matching")),),
                header=darkred(" @@ "))

        matches_found = 0
        for string in self._packages:
            results = self._match(
                entropy_client, string)
            matches_found += len(results)

        if not self._quiet:
            toc = []
            toc.append(("%s:" % (blue(_("Keywords")),),
                purple(', '.join(self._packages))))
            toc.append(("%s:" % (blue(_("Found")),), "%s %s" % (
                matches_found,
                brown(ngettext("entry", "entries", matches_found)),)))
            print_table(entropy_client, toc)

        if not matches_found:
            return 1
        return 0
Пример #19
0
    def _search_mimetype(self, entropy_client, inst_repo, associate=False):
        """
        Solo Query Mimetype command.
        """
        installed = self._nsargs.installed
        quiet = self._nsargs.quiet
        verbose = self._nsargs.verbose
        settings = entropy_client.Settings()
        inst_repo_id = inst_repo.repository_id()
        if associate:
            mimetypes = self._nsargs.files
        else:
            mimetypes = self._nsargs.mimes

        if not quiet:
            entropy_client.output(darkgreen(_("Searching Mimetype")), header=darkred(" @@ "))

        found = False
        for mimetype in mimetypes:

            if associate:
                # consider mimetype a file path
                mimetype = get_file_mime(mimetype)
                if mimetype is None:
                    continue

            if not quiet:
                entropy_client.output(bold(mimetype), header=blue("  # "))

            if installed:

                matches = [(x, inst_repo_id) for x in entropy_client.search_installed_mimetype(mimetype)]
            else:
                matches = entropy_client.search_available_mimetype(mimetype)

            if matches:
                found = True

            key_sorter = lambda x: entropy_client.open_repository(x[1]).retrieveAtom(x[0])
            for pkg_id, pkg_repo in sorted(matches, key=key_sorter):
                repo = entropy_client.open_repository(pkg_repo)
                print_package_info(pkg_id, entropy_client, repo, extended=verbose, quiet=quiet)

            if not quiet:
                entry_str = ngettext("entry", "entries", len(matches))
                toc = []
                toc.append(("%s:" % (blue(_("Keyword")),), purple(mimetype)))
                toc.append(("%s:" % (blue(_("Found")),), "%s %s" % (len(matches), brown(entry_str))))
                print_table(entropy_client, toc)

        if not quiet and not found:
            entropy_client.output(darkgreen("%s." % (_("No matches"),)), header=darkred(" @@ "))

        return 0
Пример #20
0
 def _update_countdown(self, seconds):
     """
     Update Countdown message.
     """
     msg = prepare_markup(
         ngettext("<b>%s</b> Application Action will start "
           "in <big><b>%d</b></big> second",
           "<b>%s</b> Application Action will start "
           "in <big><b>%d</b></big> seconds",
           seconds))
     msg = msg % (self._app.name, seconds,)
     self._action_label.set_markup(prepare_markup(msg))
Пример #21
0
    def _license(self, entropy_client):
        """
        Solo Query License command.
        """
        quiet = self._nsargs.quiet
        verbose = self._nsargs.verbose
        licenses = self._nsargs.licenses
        settings = entropy_client.Settings()

        if not quiet:
            entropy_client.output(darkgreen(_("License Search")), header=darkred(" @@ "))

        found = False
        repo_number = 0
        for repo_id in entropy_client.repositories():
            repo_number += 1
            repo_data = settings["repositories"]["available"][repo_id]

            if not quiet:
                header = (
                    const_convert_to_unicode("  #")
                    + const_convert_to_unicode(repo_number)
                    + const_convert_to_unicode(" ")
                )
                entropy_client.output("%s" % (bold(repo_data["description"]),), header=blue(header))

            repo = entropy_client.open_repository(repo_id)
            key_sorter = lambda x: repo.retrieveAtom(x)
            for mylicense in licenses:

                results = repo.searchLicense(mylicense, just_id=True)
                if not results:
                    continue

                found = True
                for pkg_id in sorted(results, key=key_sorter):
                    print_package_info(pkg_id, entropy_client, repo, extended=verbose, strict_output=quiet, quiet=quiet)

                if not quiet:
                    res_txt = ngettext("entry", "entries", len(results))
                    toc = []
                    toc.append(("%s:" % (blue(_("Keyword")),), purple(mylicense)))
                    toc.append(("%s:" % (blue(_("Found")),), "%s %s" % (len(results), brown(res_txt))))

                    print_table(entropy_client, toc)

        if not quiet and not found:
            entropy_client.output(darkgreen("%s." % (_("No matches"),)), header=darkred(" @@ "))

        return 0
Пример #22
0
 def _update_countdown(self, seconds):
     """
     Update Countdown message.
     """
     msg = prepare_markup(
         ngettext(
             "<b>%s</b> Application Action will start "
             "in <big><b>%d</b></big> second",
             "<b>%s</b> Application Action will start "
             "in <big><b>%d</b></big> seconds", seconds))
     msg = msg % (
         self._app.name,
         seconds,
     )
     self._action_label.set_markup(prepare_markup(msg))
Пример #23
0
    def _tags(self, entropy_client):
        """
        Solo Query Tags command.
        """
        quiet = self._nsargs.quiet
        verbose = self._nsargs.verbose
        tags = self._nsargs.tags
        settings = entropy_client.Settings()

        if not quiet:
            entropy_client.output(darkgreen(_("Tag Search")), header=darkred(" @@ "))

        found = False
        # search inside each available database
        repo_number = 0

        for repo_id in entropy_client.repositories():
            repo_number += 1
            repo_data = settings["repositories"]["available"][repo_id]

            if not quiet:
                header = (
                    const_convert_to_unicode("  #")
                    + const_convert_to_unicode(repo_number)
                    + const_convert_to_unicode(" ")
                )
                entropy_client.output("%s" % (bold(repo_data["description"]),), header=blue(header))

            repo = entropy_client.open_repository(repo_id)
            for tag in tags:

                results = repo.searchTaggedPackages(tag)
                key_sorter = lambda x: repo.retrieveAtom(x)
                for pkg_id in sorted(results, key=key_sorter):
                    found = True
                    print_package_info(pkg_id, entropy_client, repo, extended=verbose, strict_output=quiet, quiet=quiet)

                if not quiet:
                    toc = []
                    entity_str = ngettext("entry", "entries", len(results))
                    toc.append(("%s:" % (blue(_("Keyword")),), purple(tag)))
                    toc.append(("%s:" % (blue(_("Found")),), "%s %s" % (len(results), brown(entity_str))))
                    print_table(entropy_client, toc)

        if not quiet and not found:
            entropy_client.output(darkgreen("%s." % (_("No matches"),)), header=darkred(" @@ "))
        return 0
Пример #24
0
    def _sets(self, entropy_client):
        """
        Solo Query Sets command.
        """
        quiet = self._nsargs.quiet
        verbose = self._nsargs.verbose
        items = self._nsargs.sets
        if not items:
            items.append("*")

        if not quiet:
            entropy_client.output(darkgreen(_("Package Set Search")), header=darkred(" @@ "))

        sets = entropy_client.Sets()

        count = 0
        found = False
        for item in items:
            results = sets.search(item)
            key_sorter = lambda x: x[1]
            for repo, set_name, set_data in sorted(results, key=key_sorter):
                count += 1
                found = True

                if not quiet:
                    entropy_client.output(bold(set_name), header=blue("  #%d " % (count,)))

                    elements = sorted(set_data)
                    for element in elements:
                        entropy_client.output(brown(element), header="    ")
                else:
                    for element in sorted(set_data):
                        entropy_client.output(element, level="generic")

            if not quiet:
                toc = []
                entity_str = ngettext("entry", "entries", count)
                toc.append(("%s:" % (blue(_("Keyword")),), purple(item)))
                toc.append(("%s:" % (blue(_("Found")),), "%s %s" % (count, brown(entity_str))))
                print_table(entropy_client, toc)

        if not quiet and not found:
            entropy_client.output(darkgreen("%s." % (_("No matches"),)), header=darkred(" @@ "))

        return 0
Пример #25
0
    def __init__(self, preserved):

        preserved_len = len(preserved)
        msg = ngettext("There is <b>%d</b> preserved library on the system",
                       "There are <b>%d</b> preserved libraries on the system",
                       preserved_len)
        msg = msg % (preserved_len,)

        msg += ". " + _("What to do?")

        NotificationBox.__init__(
            self, prepare_markup(msg),
            tooltip=prepare_markup(
                _("Preserved libraries detected on the system.")),
            message_type=Gtk.MessageType.WARNING,
            context_id="PreservedLibsNotificationBox")

        self.add_button(_("_Update system now"), self._update)
        self.add_destroy_button(_("_Ignore"))
Пример #26
0
    def __init__(self, avc, notices_len):

        msg = ngettext("There is <b>%d</b> notice from a repository",
                       "There are <b>%d</b> notices from repositories",
                       notices_len)
        msg = msg % (notices_len, )

        msg += ".\n\n<small>"
        msg += _("It is <b>extremely</b> important to" " always read them.")
        msg += "</small>"

        context_id = "NoticeBoardNotificationContextId"
        NotificationBox.__init__(self,
                                 prepare_markup(msg),
                                 message_type=Gtk.MessageType.INFO,
                                 context_id=context_id)

        self.add_button(_("Let me see"), self._on_let_me_see)
        self.add_button(_("Stop annoying me"), self._on_stop_annoying)
        self.add_destroy_button(_("Close"))
Пример #27
0
    def __init__(self, preserved):

        preserved_len = len(preserved)
        msg = ngettext(
            "There is <b>%d</b> preserved library on the system",
            "There are <b>%d</b> preserved libraries on the system",
            preserved_len)
        msg = msg % (preserved_len, )

        msg += ". " + _("What to do?")

        NotificationBox.__init__(
            self,
            prepare_markup(msg),
            tooltip=prepare_markup(
                _("Preserved libraries detected on the system.")),
            message_type=Gtk.MessageType.WARNING,
            context_id="PreservedLibsNotificationBox")

        self.add_button(_("_Update system now"), self._update)
        self.add_destroy_button(_("_Ignore"))
Пример #28
0
    def __init__(self, avc, notices_len):

        msg = ngettext("There is <b>%d</b> notice from a repository",
                       "There are <b>%d</b> notices from repositories",
                       notices_len)
        msg = msg % (notices_len,)

        msg += ".\n\n<small>"
        msg += _("It is <b>extremely</b> important to"
                 " always read them.")
        msg += "</small>"

        context_id = "NoticeBoardNotificationContextId"
        NotificationBox.__init__(
            self, prepare_markup(msg),
            message_type=Gtk.MessageType.INFO,
            context_id=context_id)

        self.add_button(_("Let me see"), self._on_let_me_see)
        self.add_button(_("Stop annoying me"), self._on_stop_annoying)
        self.add_destroy_button(_("Close"))
Пример #29
0
    def _revisions(self, entropy_client, inst_repo):
        """
        Solo Query Revisions command.
        """
        quiet = self._nsargs.quiet
        verbose = self._nsargs.verbose
        revisions = self._nsargs.revisions
        settings = entropy_client.Settings()

        if not quiet:
            entropy_client.output(darkgreen(_("Revision Search")), header=darkred(" @@ "))

        found = False
        key_sorter = lambda x: inst_repo.retrieveAtom(x)

        for revision in revisions:
            results = inst_repo.searchRevisionedPackages(revision)

            found = True
            for pkg_id in sorted(results, key=key_sorter):
                print_package_info(
                    pkg_id,
                    entropy_client,
                    inst_repo,
                    extended=verbose,
                    strict_output=quiet,
                    installed_search=True,
                    quiet=quiet,
                )

            if not quiet:
                toc = []
                entity_str = ngettext("entry", "entries", len(results))
                toc.append(("%s:" % (blue(_("Keyword")),), purple(revision)))
                toc.append(("%s:" % (blue(_("Found")),), "%s %s" % (len(results), brown(entity_str))))
                print_table(entropy_client, toc)

        if not quiet and not found:
            entropy_client.output(darkgreen("%s." % (_("No matches"),)), header=darkred(" @@ "))
        return 0
Пример #30
0
    def __init__(self, entropy_client, avc, updates_len):
        self._entropy = entropy_client
        self._avc = avc

        msg = ngettext("There is <b>%d</b> configuration file update",
                       "There are <b>%d</b> configuration file updates",
                       updates_len)
        msg = msg % (updates_len, )

        msg += ".\n\n<small>"
        msg += _("It is <b>extremely</b> important to"
                 " update these configuration files before"
                 " <b>rebooting</b> the System.")
        msg += "</small>"

        context_id = "ConfigUpdatesNotificationContextId"
        NotificationBox.__init__(self,
                                 prepare_markup(msg),
                                 message_type=Gtk.MessageType.WARNING,
                                 context_id=context_id)

        self.add_button(_("Let me see"), self._on_show_me)
        self.add_destroy_button(_("Happily ignore"))
Пример #31
0
    def __init__(self, entropy_client, avc, updates_len):
        self._entropy = entropy_client
        self._avc = avc

        msg = ngettext("There is <b>%d</b> configuration file update",
                       "There are <b>%d</b> configuration file updates",
                       updates_len)
        msg = msg % (updates_len,)

        msg += ".\n\n<small>"
        msg += _("It is <b>extremely</b> important to"
                 " update these configuration files before"
                 " <b>rebooting</b> the System.")
        msg += "</small>"

        context_id = "ConfigUpdatesNotificationContextId"
        NotificationBox.__init__(
            self, prepare_markup(msg),
            message_type=Gtk.MessageType.WARNING,
            context_id=context_id)

        self.add_button(_("Let me see"), self._on_show_me)
        self.add_destroy_button(_("Happily ignore"))
Пример #32
0
    def _show_config_files_update(self, entropy_client):
        """
        Inform User about configuration file updates, if any.
        """
        entropy_client.output(blue(
            _("Scanning configuration files to update")),
                              header=darkgreen(" @@ "),
                              back=True)

        updates = entropy_client.ConfigurationUpdates()
        scandata = updates.get()

        if not scandata:
            entropy_client.output(blue(_("No configuration files to update.")),
                                  header=darkgreen(" @@ "))
            return

        mytxt = ngettext("There is %s configuration file needing update",
                         "There are %s configuration files needing update",
                         len(scandata)) % (len(scandata), )
        entropy_client.output(darkgreen(mytxt), level="warning")

        mytxt = "%s: %s" % (purple(_("Please run")), bold("equo conf update"))
        entropy_client.output(darkgreen(mytxt), level="warning")
Пример #33
0
    def _run_sync(self):

        self.updated = False
        sts = EntropyRepositoryBase

        for repo in self.repo_ids:

            try:
                status = self._entropy.get_repository(repo).update(
                    self._entropy, repo, self.force, self._gpg_feature)
            except PermissionDenied:
                status = sts.REPOSITORY_PERMISSION_DENIED_ERROR

            if status == sts.REPOSITORY_ALREADY_UPTODATE:
                self.already_updated = True
            elif status == sts.REPOSITORY_NOT_AVAILABLE:
                self.not_available += 1
            elif status == sts.REPOSITORY_UPDATED_OK:
                self.updated = True
                self.updated_repos.add(repo)
            elif status == sts.REPOSITORY_PERMISSION_DENIED_ERROR:
                self.not_available += 1
                self.sync_errors = True
            else: # fallback
                self.not_available += 1

            if status == sts.REPOSITORY_UPDATED_OK:
                # execute post update repo hook
                self._run_post_update_repository_hook(repo)

        # keep them closed, but trigger schema updates
        self._entropy.close_repositories()
        self._entropy._validate_repositories()
        self._entropy.reopen_installed_repository()
        self._entropy.close_repositories()

        # clean caches, fetch security
        if self.updated:
            self._entropy.clear_cache()
            if self.fetch_security:
                self._update_security_advisories()

            for repo in self.repo_ids:
                try:
                    dbc = self._entropy.open_repository(repo)
                except RepositoryError:
                    # download failed and repo is not available, skip!
                    continue
                try:
                    self._entropy.repository_packages_spm_sync(repo, dbc)
                except Error:
                    # EntropyRepository error, missing table?
                    continue
            self._entropy.close_repositories()

        if self.sync_errors:
            self._entropy.output(
                red(_("Something bad happened. Please have a look.")),
                importance = 1,
                level = "warning",
                header = darkred(" @@ ")
            )
            self.sync_errors = True
            return 128

        if self.updated:
            pkgs = self._entropy.clean_downloaded_packages(dry_run = True)
            number_of_pkgs = len(pkgs)
            if number_of_pkgs > 0:
                pkgs_size = entropy.tools.sum_file_sizes(pkgs)
                if pkgs_size > self._pkg_size_warning_th:
                    self.need_packages_cleanup = True
                    pkg_dirs = set((os.path.dirname(x) for x in pkgs))
                    human_size = entropy.tools.bytes_into_human(pkgs_size)
                    mytxt = "%s: %s %s %s." % (
                        teal("Packages"),
                        purple(ngettext("there is", "there are", number_of_pkgs)),
                        brown(str(number_of_pkgs)),
                        purple(ngettext("package file that could be removed",
                            "package files that could be removed",
                            number_of_pkgs)),
                    )
                    self._entropy.output(
                        mytxt,
                        importance = 1,
                        level = "info",
                        header = bold(" !!! ")
                    )
                    mytxt = "%s %s. %s:" % (
                        teal("They are taking up to"),
                        brown(human_size),
                        purple(_("Packages are stored in")),
                    )
                    self._entropy.output(
                        mytxt,
                        importance = 1,
                        level = "info",
                        header = bold(" !!! ")
                    )
                    for pkg_dir in pkg_dirs:
                        self._entropy.output(
                            brown(pkg_dir),
                            importance = 1,
                            level = "info",
                            header = bold("     ")
                        )

        return 0
Пример #34
0
    def _belongs(self, entropy_client, inst_repo):
        """
        Solo Query Belongs command.
        """
        quiet = self._nsargs.quiet
        verbose = self._nsargs.verbose
        files = self._nsargs.files

        if not quiet:
            entropy_client.output(darkgreen(_("Belong Search")), header=darkred(" @@ "))

        results = {}
        reverse_symlink_map = entropy_client.Settings()["system_rev_symlinks"]

        for xfile in files:
            outcome = results.setdefault(xfile, set())

            pkg_ids = inst_repo.searchBelongs(xfile)
            if not pkg_ids:
                # try real path if possible
                pkg_ids = inst_repo.searchBelongs(os.path.realpath(xfile))

            if not pkg_ids:
                # try using reverse symlink mapping
                for sym_dir in reverse_symlink_map:
                    if not xfile.startswith(sym_dir):
                        continue

                    for sym_child in reverse_symlink_map[sym_dir]:
                        my_file = sym_child + xfile[len(sym_dir) :]
                        pkg_ids = inst_repo.searchBelongs(my_file)
                        if pkg_ids:
                            break

            outcome.update(pkg_ids)

        key_sorter = lambda x: inst_repo.retrieveAtom(x)

        matches_found = 0

        for xfile, pkg_ids in results.items():

            matches_found += len(pkg_ids)  # can be incorrect

            for pkg_id in sorted(pkg_ids, key=key_sorter):
                if quiet:
                    atom = inst_repo.retrieveAtom(pkg_id)
                    if atom is not None:
                        entropy_client.output(atom, level="generic")
                else:
                    print_package_info(
                        pkg_id, entropy_client, inst_repo, installed_search=True, extended=verbose, quiet=quiet
                    )

            if not quiet:
                entries_txt = ngettext("entry", "entries", len(pkg_ids))
                toc = []
                toc.append(("%s:" % (blue(_("Keyword")),), purple(xfile)))
                toc.append(("%s:" % (blue(_("Found")),), "%s %s" % (len(pkg_ids), brown(entries_txt))))
                print_table(entropy_client, toc)

        return 0
Пример #35
0
    def _revdeps(self, entropy_client, inst_repo):
        """
        Solo Query Revdeps command.
        """
        quiet = self._nsargs.quiet
        verbose = self._nsargs.verbose
        packages = self._nsargs.packages
        settings = entropy_client.Settings()

        if not quiet:
            entropy_client.output(darkgreen(_("Reverse Dependencies Search")), header=darkred(" @@ "))

        include_build_deps = False
        excluded_dep_types = None
        if include_build_deps:
            excluded_dep_types.append(etpConst["dependency_type_ids"]["bdepend_id"])

        for package in packages:

            repository_id = inst_repo.repository_id()
            package_id, _inst_rc = inst_repo.atomMatch(package)

            match_in_repo = False
            repo_masked = False

            if package_id == -1:
                match_in_repo = True
                package_id, repository_id = entropy_client.atom_match(package)

            if package_id == -1:
                package_id, repository_id = entropy_client.atom_match(package, mask_filter=False)
                if package_id != -1:
                    repo_masked = True

            if package_id == -1:
                continue

            repo = inst_repo
            if match_in_repo:
                repo = entropy_client.open_repository(repository_id)

            found_atom = repo.retrieveAtom(package_id)
            if repo_masked:
                package_id_masked, idmasking_reason = repo.maskFilter(package_id)

            search_results = repo.retrieveReverseDependencies(package_id, exclude_deptypes=excluded_dep_types)

            key_sorter = lambda x: repo.retrieveAtom(x)
            for pkg_id in sorted(search_results, key=key_sorter):
                print_package_info(
                    pkg_id,
                    entropy_client,
                    repo,
                    installed_search=True,
                    strict_output=quiet,
                    extended=verbose,
                    quiet=quiet,
                )

            if quiet:
                continue

            masking_reason = ""
            if repo_masked:
                masking_reason = ", %s" % (settings["pkg_masking_reasons"].get(idmasking_reason),)
            repo_masked_str = const_convert_to_unicode(repo_masked)
            mask_str = bold(repo_masked_str) + masking_reason

            toc = []
            toc.append(("%s:" % (blue(_("Keyword")),), purple(package)))
            toc.append(("%s:" % (blue(_("Matched")),), teal(found_atom)))
            toc.append(("%s:" % (blue(_("Masked")),), mask_str))

            if match_in_repo:
                where = "%s %s" % (_("from repository"), repository_id)
            else:
                where = _("from the installed packages repository")

            entry_str = ngettext("entry", "entries", len(search_results))
            toc.append(("%s:" % (blue(_("Found")),), "%s %s %s" % (len(search_results), brown(entry_str), where)))
            print_table(entropy_client, toc)

        return 0
Пример #36
0
    def _download_packages(self, entropy_client, package_matches,
                           downdata, multifetch=1):
        """
        Download packages from mirrors, essentially.
        """
        # read multifetch parameter from config if needed.
        client_settings = entropy_client.ClientSettings()
        misc_settings = client_settings['misc']
        if multifetch <= 1:
            multifetch = misc_settings.get('multifetch', 1)

        action_factory = entropy_client.PackageActionFactory()

        mymultifetch = multifetch
        if multifetch > 1:
            myqueue = []
            mystart = 0
            while True:
                mylist = package_matches[mystart:mymultifetch]
                if not mylist:
                    break
                myqueue.append(mylist)
                mystart += multifetch
                mymultifetch += multifetch

            count = 0
            total = len(myqueue)
            for matches in myqueue:
                count += 1

                for pkg_id, pkg_repo in matches:
                    obj = downdata.setdefault(pkg_repo, set())
                    repo = entropy_client.open_repository(pkg_repo)
                    pkg_atom = repo.retrieveAtom(pkg_id)
                    if pkg_atom:
                        obj.add(entropy.dep.dep_getkey(pkg_atom))

                pkg = None
                try:
                    pkg = action_factory.get(
                        action_factory.MULTI_FETCH_ACTION,
                        matches)

                    xterm_header = "equo (%s) :: %d of %d ::" % (
                        _("download"), count, total)
                    pkg.set_xterm_header(xterm_header)

                    entropy_client.output(
                        "%s %s" % (
                            darkgreen(
                                const_convert_to_unicode(len(matches))),
                            ngettext("package", "packages", len(matches))
                            ),
                        count=(count, total),
                        header=darkred(" ::: ") + ">>> ")

                    exit_st = pkg.start()
                    if exit_st != 0:
                        return 1

                finally:
                    if pkg is not None:
                        pkg.finalize()

            return 0

        total = len(package_matches)
        count = 0
        # normal fetch
        for match in package_matches:
            count += 1

            pkg = None
            try:
                package_id, repository_id = match

                atom = entropy_client.open_repository(
                    repository_id).retrieveAtom(package_id)
                if atom:
                    obj = downdata.setdefault(repository_id, set())
                    obj.add(entropy.dep.dep_getkey(atom))

                pkg = action_factory.get(
                    action_factory.FETCH_ACTION,
                    match)

                xterm_header = "equo (%s) :: %d of %d ::" % (
                    _("download"), count, total)
                pkg.set_xterm_header(xterm_header)

                entropy_client.output(
                    darkgreen(atom),
                    count=(count, total),
                    header=darkred(" ::: ") + ">>> ")

                exit_st = pkg.start()
                if exit_st != 0:
                    return 1

            finally:
                if pkg is not None:
                    pkg.finalize()

        return 0
Пример #37
0
    def _run_sync(self, _unlocked = False):

        self.updated = False
        for repo in self.repo_ids:

            # handle
            try:
                status = self._entropy.get_repository(repo).update(self._entropy,
                    repo, self.force, self._gpg_feature)
            except PermissionDenied:
                status = EntropyRepositoryBase.REPOSITORY_PERMISSION_DENIED_ERROR

            if status == EntropyRepositoryBase.REPOSITORY_ALREADY_UPTODATE:
                self.already_updated = True
            elif status == EntropyRepositoryBase.REPOSITORY_NOT_AVAILABLE:
                self.not_available += 1
            elif status == EntropyRepositoryBase.REPOSITORY_UPDATED_OK:
                self.updated = True
                self.updated_repos.add(repo)
            elif status == EntropyRepositoryBase.REPOSITORY_PERMISSION_DENIED_ERROR:
                self.not_available += 1
                self.sync_errors = True
            else: # fallback
                self.not_available += 1

            if status == EntropyRepositoryBase.REPOSITORY_UPDATED_OK:
                # execute post update repo hook
                self._run_post_update_repository_hook(repo)

        # keep them closed
        self._entropy.close_repositories()
        self._entropy._validate_repositories()
        self._entropy.close_repositories()

        # clean caches, fetch security
        if self.updated:
            self._entropy.clear_cache()
            if self.fetch_security:
                self._update_security_advisories(_unlocked = _unlocked)

            # do treeupdates
            if isinstance(self._entropy.installed_repository(),
                EntropyRepositoryBase):

                for repo in self.repo_ids:
                    try:
                        dbc = self._entropy.open_repository(repo)
                    except RepositoryError:
                        # download failed and repo is not available, skip!
                        continue
                    try:
                        self._entropy.repository_packages_spm_sync(repo, dbc)
                    except Error:
                        # EntropyRepository error, missing table?
                        continue
                self._entropy.close_repositories()

        if self.sync_errors:
            self._entropy.output(
                red(_("Something bad happened. Please have a look.")),
                importance = 1,
                level = "warning",
                header = darkred(" @@ ")
            )
            self.sync_errors = True
            return 128

        if self.entropy_updates_alert:
            self._check_entropy_updates()

        if self.updated:
            pkgs = self._entropy.clean_downloaded_packages(dry_run = True)
            number_of_pkgs = len(pkgs)
            if number_of_pkgs > 0:
                pkgs_size = entropy.tools.sum_file_sizes(pkgs)
                if pkgs_size > self._pkg_size_warning_th:
                    self.need_packages_cleanup = True
                    pkg_dirs = set((os.path.dirname(x) for x in pkgs))
                    human_size = entropy.tools.bytes_into_human(pkgs_size)
                    mytxt = "%s: %s %s %s." % (
                        teal("Packages"),
                        purple(ngettext("there is", "there are", number_of_pkgs)),
                        brown(str(number_of_pkgs)),
                        purple(ngettext("package file that could be removed",
                            "package files that could be removed",
                            number_of_pkgs)),
                    )
                    self._entropy.output(
                        mytxt,
                        importance = 1,
                        level = "info",
                        header = bold(" !!! ")
                    )
                    mytxt = "%s %s. %s:" % (
                        teal("They are taking up to"),
                        brown(human_size),
                        purple(_("Packages are stored in")),
                    )
                    self._entropy.output(
                        mytxt,
                        importance = 1,
                        level = "info",
                        header = bold(" !!! ")
                    )
                    for pkg_dir in pkg_dirs:
                        self._entropy.output(
                            brown(pkg_dir),
                            importance = 1,
                            level = "info",
                            header = bold("     ")
                        )

        return 0
Пример #38
0
    def _fetch_phase(self):
        """
        Execute the fetch phase.
        """
        m_fetch_len = len(self._meta['multi_fetch_list']) / 2
        xterm_title = "%s: %s %s" % (
            _("Downloading"),
            m_fetch_len,
            ngettext("package", "packages", m_fetch_len),
        )
        self._entropy.set_title(xterm_title)

        m_fetch_len = len(self._meta['multi_fetch_list'])
        txt = "%s: %s %s" % (
            blue(_("Downloading")),
            darkred("%s" % (m_fetch_len,)),
            ngettext("package", "packages", m_fetch_len),
        )
        self._entropy.output(
            txt,
            importance = 1,
            level = "info",
            header = red("   ## ")
        )

        exit_st, err_list = self._download_packages(
            self._meta['multi_fetch_list'])
        if exit_st == 0:
            return 0

        txt = _("Some packages cannot be fetched")
        txt2 = _("Try to update your repositories and retry")
        for txt in (txt, txt2,):
            self._entropy.output(
                "%s." % (
                    darkred(txt),
                ),
                importance = 0,
                level = "info",
                header = red("   ## ")
            )

        self._entropy.output(
            "%s: %s" % (
                brown(_("Error")),
                exit_st,
            ),
            importance = 0,
            level = "info",
            header = red("   ## ")
        )

        for _pkg_id, repo, fname, cksum, _signatures in err_list:
            self._entropy.output(
                "[%s|%s] %s" % (
                    blue(repo),
                    darkgreen(cksum),
                    darkred(fname),
                ),
                importance = 1,
                level = "error",
                header = darkred("    # ")
            )

        return exit_st
Пример #39
0
    def _branch(self, entropy_server):
        """
        Eit branch code.
        """
        if self._to_branch is None:
            # show status then
            return self._status(entropy_server)

        repository_id = entropy_server.repository()
        from_branch = self._from_branch
        if from_branch is None:
            from_branch = self._settings()['repositories']['branch']
        else:
            if not entropy.tools.validate_branch_name(from_branch):
                entropy_server.output(
                    "%s: %s" % (
                        purple(_("Invalid branch")),
                        from_branch),
                    importance=1, level="error")
                return 1

        # validate to_branch
        if not entropy.tools.validate_branch_name(self._to_branch):
            entropy_server.output(
                "%s: %s" % (
                    purple(_("Invalid branch")),
                    self._to_branch),
                importance=1, level="error")
            return 1

        dbconn_old = entropy_server.open_server_repository(repository_id,
            read_only = True, no_upload = True, use_branch = from_branch,
            do_treeupdates = False)
        pkglist = dbconn_old.listAllPackageIds()

        if not pkglist:
            if self._copy:
                entropy_server.output(
                    purple(_("No packages to copy")),
                    importance=1, level="error")
        else:
            if self._copy:
                entropy_server.output(
                    "%s %s %s: %s" % (
                        len(pkglist),
                        darkgreen(ngettext("package", "packages", len(pkglist))),
                        blue(_("would be copied to branch")),
                        bold(self._to_branch),
                        ),
                    header=darkgreen(" @@ "))

        if self._ask and pkglist and self._copy:
            resp = entropy_server.ask_question(
                _("Would you like to continue ?"))
            if resp == _("No"):
                return 1

        # set branch to new branch first
        entropy_server.set_branch(self._to_branch)
        if (not pkglist) or (not self._copy):
            entropy_server.output(
                "[%s] %s: %s" % (
                    blue(entropy_server.repository()),
                    teal(_("switched to branch")),
                    purple(self._to_branch),
                    ),
                header=darkgreen(" @@ "))
            return 0

        status = None
        try:
            status = entropy_server._switch_packages_branch(
                repository_id, from_branch, self._to_branch)
            if status is None:
                return 1
        finally:
            if status is None:
                entropy_server.set_branch(from_branch)

        switched, already_switched, ignored, \
            not_found, no_checksum = status
        if not_found or no_checksum:
            return 1
        return 0
Пример #40
0
    def _download_packages(self,
                           entropy_client,
                           package_matches,
                           downdata,
                           multifetch=1):
        """
        Download packages from mirrors, essentially.
        """
        # read multifetch parameter from config if needed.
        client_settings = entropy_client.ClientSettings()
        misc_settings = client_settings['misc']
        if multifetch <= 1:
            multifetch = misc_settings.get('multifetch', 1)

        action_factory = entropy_client.PackageActionFactory()

        mymultifetch = multifetch
        if multifetch > 1:
            myqueue = []
            mystart = 0
            while True:
                mylist = package_matches[mystart:mymultifetch]
                if not mylist:
                    break
                myqueue.append(mylist)
                mystart += multifetch
                mymultifetch += multifetch

            count = 0
            total = len(myqueue)
            for matches in myqueue:
                count += 1

                for pkg_id, pkg_repo in matches:
                    obj = downdata.setdefault(pkg_repo, set())
                    repo = entropy_client.open_repository(pkg_repo)
                    pkg_atom = repo.retrieveAtom(pkg_id)
                    if pkg_atom:
                        obj.add(entropy.dep.dep_getkey(pkg_atom))

                pkg = None
                try:
                    pkg = action_factory.get(action_factory.MULTI_FETCH_ACTION,
                                             matches)

                    xterm_header = "equo (%s) :: %d of %d ::" % (_("download"),
                                                                 count, total)
                    pkg.set_xterm_header(xterm_header)

                    entropy_client.output(
                        "%s %s" %
                        (darkgreen(const_convert_to_unicode(len(matches))),
                         ngettext("package", "packages", len(matches))),
                        count=(count, total),
                        header=darkred(" ::: ") + ">>> ")

                    exit_st = pkg.start()
                    if exit_st != 0:
                        return 1

                finally:
                    if pkg is not None:
                        pkg.finalize()

            return 0

        total = len(package_matches)
        count = 0
        # normal fetch
        for match in package_matches:
            count += 1

            pkg = None
            try:
                package_id, repository_id = match

                atom = entropy_client.open_repository(
                    repository_id).retrieveAtom(package_id)
                if atom:
                    obj = downdata.setdefault(repository_id, set())
                    obj.add(entropy.dep.dep_getkey(atom))

                pkg = action_factory.get(action_factory.FETCH_ACTION, match)

                xterm_header = "equo (%s) :: %d of %d ::" % (_("download"),
                                                             count, total)
                pkg.set_xterm_header(xterm_header)

                entropy_client.output(darkgreen(atom),
                                      count=(count, total),
                                      header=darkred(" ::: ") + ">>> ")

                exit_st = pkg.start()
                if exit_st != 0:
                    return 1

            finally:
                if pkg is not None:
                    pkg.finalize()

        return 0
Пример #41
0
    def _branch(self, entropy_server):
        """
        Eit branch code.
        """
        if self._to_branch is None:
            # show status then
            return self._status(entropy_server)

        repository_id = entropy_server.repository()
        from_branch = self._from_branch
        if from_branch is None:
            from_branch = self._settings()['repositories']['branch']
        else:
            if not entropy.tools.validate_branch_name(from_branch):
                entropy_server.output(
                    "%s: %s" % (purple(_("Invalid branch")), from_branch),
                    importance=1,
                    level="error")
                return 1

        # validate to_branch
        if not entropy.tools.validate_branch_name(self._to_branch):
            entropy_server.output(
                "%s: %s" % (purple(_("Invalid branch")), self._to_branch),
                importance=1,
                level="error")
            return 1

        dbconn_old = entropy_server.open_server_repository(
            repository_id,
            read_only=True,
            no_upload=True,
            use_branch=from_branch,
            do_treeupdates=False)
        pkglist = dbconn_old.listAllPackageIds()

        if not pkglist:
            if self._copy:
                entropy_server.output(purple(_("No packages to copy")),
                                      importance=1,
                                      level="error")
        else:
            if self._copy:
                entropy_server.output("%s %s %s: %s" % (
                    len(pkglist),
                    darkgreen(ngettext("package", "packages", len(pkglist))),
                    blue(_("would be copied to branch")),
                    bold(self._to_branch),
                ),
                                      header=darkgreen(" @@ "))

        if self._ask and pkglist and self._copy:
            resp = entropy_server.ask_question(
                _("Would you like to continue ?"))
            if resp == _("No"):
                return 1

        # set branch to new branch first
        entropy_server.set_branch(self._to_branch)
        if (not pkglist) or (not self._copy):
            entropy_server.output("[%s] %s: %s" % (
                blue(entropy_server.repository()),
                teal(_("switched to branch")),
                purple(self._to_branch),
            ),
                                  header=darkgreen(" @@ "))
            return 0

        status = None
        try:
            status = entropy_server._switch_packages_branch(
                repository_id, from_branch, self._to_branch)
            if status is None:
                return 1
        finally:
            if status is None:
                entropy_server.set_branch(from_branch)

        switched, already_switched, ignored, \
            not_found, no_checksum = status
        if not_found or no_checksum:
            return 1
        return 0