示例#1
0
 def __init__(self):
     Progress.__init__(self)
     self._lasttopic = None
     self._lastsubkey = None
     self._lastsubkeystart = 0
     self._fetchermode = False
     self._seentopics = {}
     self._addline = False
     self.setScreenWidth(getScreenWidth())
示例#2
0
 def __init__(self):
     Progress.__init__(self)
     self._lasttopic = None
     self._lastsubkey = None
     self._lastsubkeystart = 0
     self._fetchermode = False
     self._seentopics = {}
     self._addline = False
     self.setScreenWidth(getScreenWidth())
示例#3
0
 def __init__(self):
     Progress.__init__(self)
     self._lasttopic = None
     self._lastsubkey = None
     self._lastsubkeystart = 0
     self._fetchermode = False
     self._seentopics = {}
     self._addline = False
     self.setScreenWidth(getScreenWidth())
     signal.signal(signal.SIGWINCH, self.handleScreenWidth)
示例#4
0
    def test_getScreenWidth_falls_back_to_80_if_raising_IOError(self):
        input_data = struct.pack("HHHH", 0, 0, 0, 0)

        ioctl_mock = self.mocker.replace(fcntl.ioctl)
        ioctl_mock(1, termios.TIOCGWINSZ, input_data)
        self.mocker.throw(IOError)

        self.mocker.replay()

        self.assertEquals(getScreenWidth(), 80)
示例#5
0
    def test_getScreenWidth_with_zero_width_falls_back_to_80(self):
        input_data = struct.pack("HHHH", 0, 0, 0, 0)
        output_data = struct.pack("HHHH", 0, 0, 0, 0)

        ioctl_mock = self.mocker.replace(fcntl.ioctl)
        ioctl_mock(1, termios.TIOCGWINSZ, input_data)
        self.mocker.result(output_data)

        self.mocker.replay()

        self.assertEquals(getScreenWidth(), 80)
示例#6
0
    def test_getScreenWidth(self):
        input_data = struct.pack("HHHH", 0, 0, 0, 0)
        output_data = struct.pack("HHHH", 0, 100, 0, 0)

        ioctl_mock = self.mocker.replace(fcntl.ioctl)
        ioctl_mock(1, termios.TIOCGWINSZ, input_data)
        self.mocker.result(output_data)

        self.mocker.replay()

        self.assertEquals(getScreenWidth(), 100)
示例#7
0
    def showChangeSet(self, changeset, keep=None, confirm=False):
        self.hideStatus()
        report = Report(changeset)
        report.compute()

        screenwidth = getScreenWidth()

        hideversion = sysconf.get("text-hide-version", len(changeset) > 40)
        if hideversion:

            def cvt(lst):
                return [x.name for x in lst]
        else:

            def cvt(lst):
                return lst

        print
        if keep:
            keep = cvt(keep)
            keep.sort()
            print _("Kept packages (%d):") % len(keep)
            printColumns(keep, indent=2, width=screenwidth)
            print
        pkgs = report.upgrading.keys()
        if pkgs:
            pkgs = cvt(pkgs)
            pkgs.sort()
            print _("Upgrading packages (%d):") % len(pkgs)
            printColumns(pkgs, indent=2, width=screenwidth)
            print
        pkgs = report.downgrading.keys()
        if pkgs:
            pkgs = cvt(pkgs)
            pkgs.sort()
            print _("Downgrading packages (%d):") % len(pkgs)
            printColumns(pkgs, indent=2, width=screenwidth)
            print
        pkgs = report.installing.keys()
        if pkgs:
            pkgs = cvt(pkgs)
            pkgs.sort()
            print _("Installed packages (%d):") % len(pkgs)
            printColumns(pkgs, indent=2, width=screenwidth)
            print
        pkgs = report.removed.keys()
        if pkgs:
            pkgs = cvt(pkgs)
            pkgs.sort()
            print _("Removed packages (%d):") % len(pkgs)
            printColumns(pkgs, indent=2, width=screenwidth)
            print
        dsize = report.getDownloadSize()
        size = report.getInstallSize() - report.getRemoveSize()
        if dsize:
            sys.stdout.write(
                _("%s of package files are needed. ") % sizeToStr(dsize))
        if size > 0:
            sys.stdout.write(_("%s will be used.") % sizeToStr(size))
        elif size < 0:
            size *= -1
            sys.stdout.write(_("%s will be freed.") % sizeToStr(size))
        if dsize or size:
            sys.stdout.write("\n\n")
        if confirm:
            return self.askYesNo(_("Confirm changes?"), True)
        return True
示例#8
0
    def showChangeSet(self, changeset, keep=None, confirm=False):
        self.hideStatus()
        report = Report(changeset)
        report.compute()


        if not sysconf.get("explain-changesets", False):
            screenwidth = getScreenWidth()
            hideversion = sysconf.get("text-hide-version", len(changeset) > 40)
            def showPackages(pkgs, showrelations=None):
                if hideversion:
                    pkgs = [x.name for x in pkgs]
                pkgs.sort()
                printColumns(pkgs, indent=2, width=screenwidth)
        else:
            def being(pkg):
                if (pkg in report.installing or
                    pkg in report.upgrading or
                    pkg in report.downgrading):
                    return _("(installed)")
                elif pkg in report.upgraded:
                    return _("(upgraded)")
                elif pkg in report.removed:
                    return _("(removed)")
                elif pkg in report.downgraded:
                    return _("(downgraded)")
                else:
                    return "" # Shouldn't happen
            def showPackages(pkgs, showrelations=True):
                pkgs.sort()
                for pkg in pkgs:
                    channels = []
                    for loader in pkg.loaders:
                        channels.append(loader.getChannel().getAlias())
                        channels.sort()
                    print " ", pkg, ("[%s]" % ", ".join(channels))
                    if showrelations:
                        if pkg in report.upgrading:
                            print "   ", _("Upgrades:")
                            for upgpkg in report.upgrading[pkg]:
                                print "     ", upgpkg, being(upgpkg)
                        if pkg in report.downgrading:
                            print "   ", _("Downgrades:")
                            for dwnpkg in report.downgrading[pkg]:
                                print "     ", dwnpkg, being(dwnpkg)
                        if pkg in report.requires:
                            print "   ", _("Requires:")
                            for reqpkg in report.requires[pkg]:
                                print "     ", reqpkg, being(reqpkg)
                        if pkg in report.requiredby:
                            print "   ", _("Required By:")
                            for reqpkg in report.requiredby[pkg]:
                                print "     ", reqpkg, being(reqpkg)
                        if pkg in report.conflicts:
                            print "   ", _("Conflicts:")
                            for cnfpkg in report.conflicts[pkg]:
                                print "     ", cnfpkg, being(cnfpkg)

        print
        if keep:
            print _("Kept packages (%d):") % len(keep)
            showPackages(keep, False)
            print
        pkgs = report.upgrading.keys()
        if pkgs:
            print _("Upgrading packages (%d):") % len(pkgs)
            showPackages(pkgs)
            print
        pkgs = report.downgrading.keys()
        if pkgs:
            print _("Downgrading packages (%d):") % len(pkgs)
            showPackages(pkgs)
            print
        pkgs = report.installing.keys()
        if pkgs:
            print _("Installing packages (%d):") % len(pkgs)
            showPackages(pkgs)
            print
        pkgs = report.removed.keys()
        if pkgs:
            print _("Removing packages (%d):") % len(pkgs)
            showPackages(pkgs)
            print

        dsize = report.getDownloadSize() - report.getCachedSize()
        size = report.getInstallSize() - report.getRemoveSize()
        if dsize:
            sys.stdout.write(_("%s of package files are needed. ") %
                             sizeToStr(dsize))
        if size > 0:
            sys.stdout.write(_("%s will be used.") % sizeToStr(size))
        elif size < 0:
            size *= -1
            sys.stdout.write(_("%s will be freed.") % sizeToStr(size))
        if dsize or size:
            sys.stdout.write("\n\n")
        if confirm:
            return self.askYesNo(_("Confirm changes?"), True)
        return True
示例#9
0
    def showChangeSet(self, changeset, keep=None, confirm=False):
        self.hideStatus()
        report = Report(changeset)
        report.compute()

        screenwidth = getScreenWidth()

        hideversion = sysconf.get("text-hide-version", len(changeset) > 40)
        if hideversion:
            def cvt(lst):
                return [x.name for x in lst]
        else:
            def cvt(lst):
                return lst

        print
        if keep:
            keep = cvt(keep)
            keep.sort()
            print _("Kept packages (%d):") % len(keep)
            printColumns(keep, indent=2, width=screenwidth)
            print
        pkgs = report.upgrading.keys()
        if pkgs:
            pkgs = cvt(pkgs)
            pkgs.sort()
            print _("Upgrading packages (%d):") % len(pkgs)
            printColumns(pkgs, indent=2, width=screenwidth)
            print
        pkgs = report.downgrading.keys()
        if pkgs:
            pkgs = cvt(pkgs)
            pkgs.sort()
            print _("Downgrading packages (%d):") % len(pkgs)
            printColumns(pkgs, indent=2, width=screenwidth)
            print
        pkgs = report.installing.keys()
        if pkgs:
            pkgs = cvt(pkgs)
            pkgs.sort()
            print _("Installed packages (%d):") % len(pkgs)
            printColumns(pkgs, indent=2, width=screenwidth)
            print
        pkgs = report.removed.keys()
        if pkgs:
            pkgs = cvt(pkgs)
            pkgs.sort()
            print _("Removed packages (%d):") % len(pkgs)
            printColumns(pkgs, indent=2, width=screenwidth)
            print
        dsize = report.getDownloadSize()
        size = report.getInstallSize() - report.getRemoveSize()
        if dsize:
            sys.stdout.write(_("%s of package files are needed. ") %
                             sizeToStr(dsize))
        if size > 0:
            sys.stdout.write(_("%s will be used.") % sizeToStr(size))
        elif size < 0:
            size *= -1
            sys.stdout.write(_("%s will be freed.") % sizeToStr(size))
        if dsize or size:
            sys.stdout.write("\n\n")
        if confirm:
            return self.askYesNo(_("Confirm changes?"), True)
        return True
示例#10
0
 def handleScreenWidth(self, signum, frame):
     self.setScreenWidth(getScreenWidth())
示例#11
0
    def showChangeSet(self, changeset, keep=None, confirm=False):
        self.hideStatus()
        report = Report(changeset)
        report.compute()

        if not sysconf.get("explain-changesets", False):
            screenwidth = getScreenWidth()
            hideversion = sysconf.get("text-hide-version", len(changeset) > 40)

            def showPackages(pkgs, showrelations=None):
                if hideversion:
                    pkgs = [x.name for x in pkgs]
                pkgs.sort()
                printColumns(pkgs, indent=2, width=screenwidth)
        else:

            def being(pkg):
                if (pkg in report.installing or pkg in report.upgrading
                        or pkg in report.downgrading):
                    return _("(installed)")
                elif pkg in report.upgraded:
                    return _("(upgraded)")
                elif pkg in report.removed:
                    return _("(removed)")
                elif pkg in report.downgraded:
                    return _("(downgraded)")
                else:
                    return ""  # Shouldn't happen

            def showPackages(pkgs, showrelations=True):
                pkgs.sort()
                for pkg in pkgs:
                    channels = []
                    for loader in pkg.loaders:
                        channels.append(loader.getChannel().getAlias())
                        channels.sort()
                    print " ", pkg, ("[%s]" % ", ".join(channels))
                    if showrelations:
                        if pkg in report.upgrading:
                            print "   ", _("Upgrades:")
                            for upgpkg in report.upgrading[pkg]:
                                print "     ", upgpkg, being(upgpkg)
                        if pkg in report.downgrading:
                            print "   ", _("Downgrades:")
                            for dwnpkg in report.downgrading[pkg]:
                                print "     ", dwnpkg, being(dwnpkg)
                        if pkg in report.requires:
                            print "   ", _("Requires:")
                            for reqpkg in report.requires[pkg]:
                                print "     ", reqpkg, being(reqpkg)
                        if pkg in report.requiredby:
                            print "   ", _("Required By:")
                            for reqpkg in report.requiredby[pkg]:
                                print "     ", reqpkg, being(reqpkg)
                        if pkg in report.conflicts:
                            print "   ", _("Conflicts:")
                            for cnfpkg in report.conflicts[pkg]:
                                print "     ", cnfpkg, being(cnfpkg)

        print
        if keep:
            print _("Kept packages (%d):") % len(keep)
            showPackages(keep, False)
            print
        pkgs = report.upgrading.keys()
        if pkgs:
            print _("Upgrading packages (%d):") % len(pkgs)
            showPackages(pkgs)
            print
        pkgs = report.downgrading.keys()
        if pkgs:
            print _("Downgrading packages (%d):") % len(pkgs)
            showPackages(pkgs)
            print
        pkgs = report.installing.keys()
        if pkgs:
            print _("Installing packages (%d):") % len(pkgs)
            showPackages(pkgs)
            print
        pkgs = report.removed.keys()
        if pkgs:
            print _("Removing packages (%d):") % len(pkgs)
            showPackages(pkgs)
            print

        dsize = report.getDownloadSize() - report.getCachedSize()
        size = report.getInstallSize() - report.getRemoveSize()
        if dsize:
            sys.stdout.write(
                _("%s of package files are needed. ") % sizeToStr(dsize))
        if size > 0:
            sys.stdout.write(_("%s will be used.") % sizeToStr(size))
        elif size < 0:
            size *= -1
            sys.stdout.write(_("%s will be freed.") % sizeToStr(size))
        if dsize or size:
            sys.stdout.write("\n\n")
        if confirm:
            return self.askYesNo(_("Confirm changes?"), True)
        return True