Пример #1
0
    def nameByLang(self, lang):

        for langcode in self._expand_languages(lang):
            if self.translated_name.has_key(langcode):
                return to_unicode(self.translated_name[langcode])

        return to_unicode(self.name)
Пример #2
0
    def nameByLang(self, lang):

        for langcode in self._expand_languages(lang):
            if self.translated_name.has_key(langcode):
                return to_unicode(self.translated_name[langcode])

        return to_unicode(self.name)
Пример #3
0
    def _pkgtup2pid(self, pkgtup, checksum=None):
        cur = self._get_cursor()
        executeSQL(
            cur, """SELECT pkgtupid, checksum FROM pkgtups
                           WHERE name=? AND arch=? AND
                                 epoch=? AND version=? AND release=?""",
            pkgtup)
        for sql_pkgtupid, sql_checksum in cur:
            if checksum is None and sql_checksum is None:
                return sql_pkgtupid
            if checksum is None:
                continue
            if sql_checksum is None:
                continue
            if checksum == sql_checksum:
                return sql_pkgtupid

        (n, a, e, v, r) = pkgtup
        (n, a, e, v, r) = (to_unicode(n), to_unicode(a), to_unicode(e),
                           to_unicode(v), to_unicode(r))
        if checksum is not None:
            res = executeSQL(
                cur, """INSERT INTO pkgtups
                                (name, arch, epoch, version, release, checksum)
                                VALUES (?, ?, ?, ?, ?, ?)""",
                (n, a, e, v, r, checksum))
        else:
            res = executeSQL(
                cur, """INSERT INTO pkgtups
                                (name, arch, epoch, version, release)
                                VALUES (?, ?, ?, ?, ?)""", (n, a, e, v, r))
        return cur.lastrowid
Пример #4
0
 def _pkgtup2pid(self, pkgtup, checksum=None):
     cur = self._get_cursor()
     executeSQL(cur, """SELECT pkgtupid, checksum FROM pkgtups
                        WHERE name=? AND arch=? AND
                              epoch=? AND version=? AND release=?""", pkgtup)
     for sql_pkgtupid, sql_checksum in cur:
         if checksum is None and sql_checksum is None:
             return sql_pkgtupid
         if checksum is None:
             continue
         if sql_checksum is None:
             continue
         if checksum == sql_checksum:
             return sql_pkgtupid
     
     (n,a,e,v,r) = pkgtup
     (n,a,e,v,r) = (to_unicode(n),to_unicode(a),
                    to_unicode(e),to_unicode(v),to_unicode(r))
     if checksum is not None:
         res = executeSQL(cur,
                          """INSERT INTO pkgtups
                             (name, arch, epoch, version, release, checksum)
                             VALUES (?, ?, ?, ?, ?, ?)""", (n,a,e,v,r,
                                                            checksum))
     else:
         res = executeSQL(cur,
                          """INSERT INTO pkgtups
                             (name, arch, epoch, version, release)
                             VALUES (?, ?, ?, ?, ?)""", (n,a,e,v,r))
     return cur.lastrowid
Пример #5
0
    def show_data(self, msg, pkgs, name):
        done = False
        for pkg in pkgs:
            self._pkgs += 1
            if pkg.sourcerpm in self._done_spkgs:
                continue

            self._spkgs += 1

            for line in self.changelog(pkg):
                if pkg.sourcerpm not in self._done_spkgs:
                    if not self._done_spkgs:
                        msg('')
                        if self._since_all:
                            msg('Listing all changelogs')
                        elif self._since_num is not None:
                            sn = "s"
                            if self._since_num == 1:
                                sn = ""
                            msg('Listing %d changelog%s' %
                                (self._since_num, sn))
                        else:
                            msg('Listing changelogs since ' +
                                str(self._since_dto.date()))
                    msg('')
                    if not done:
                        msg("%s %s %s" % ('=' * 20, name, '=' * 20))
                    done = True

                    self._done_spkgs[pkg.sourcerpm] = True
                    msg('%-40.40s %s' % (pkg, pkg.repoid))
                self._changelogs += 1
                msg(to_unicode(line))
                msg('')
Пример #6
0
    def show_data(self, msg, pkgs, name):
        done = False
        for pkg in pkgs:
            self._pkgs += 1
            if pkg.sourcerpm in self._done_spkgs:
                continue

            self._spkgs += 1

            for line in self.changelog(pkg):
                if pkg.sourcerpm not in self._done_spkgs:                    
                    if not self._done_spkgs:
                        msg('')
                        if self._since_all:
                            msg('Listing all changelogs')
                        elif self._since_num is not None:
                            sn = "s"
                            if self._since_num == 1:
                                sn = ""
                            msg('Listing %d changelog%s' % (self._since_num,sn))
                        else:
                            msg('Listing changelogs since ' +
                                str(self._since_dto.date()))
                    msg('')
                    if not done:
                        msg("%s %s %s" % ('=' * 20, name, '=' * 20))
                    done = True

                    self._done_spkgs[pkg.sourcerpm] = True
                    msg('%-40.40s %s' % (pkg, pkg.repoid))
                self._changelogs += 1
                msg(to_unicode(line))
                msg('')
Пример #7
0
 def _find_search_fields(fields, searchstrings, hdr):
     count = 0
     for s in searchstrings:
         for field in fields:
             value = to_unicode(hdr[field])
             if value and value.lower().find(s) != -1:
                 count += 1
                 break
     return count
Пример #8
0
def _out_mod(opts, oldpkg, pkg, sizechange):
    if opts.simple:
        if opts.compare_arch:
            msg = "%s: %s ->  %s" % (pkg.name, oldpkg, pkg)
        else:
            msg = "%s: %s-%s-%s ->  %s-%s-%s" % (
                pkg.name,
                oldpkg.name,
                oldpkg.ver,
                oldpkg.rel,
                pkg.name,
                pkg.ver,
                pkg.rel,
            )
    else:
        if opts.compare_arch:
            msg = "%s" % pkg
        else:
            msg = "%s-%s-%s" % (pkg.name, pkg.ver, pkg.rel)
        dashes = "-" * len(msg)
        msg += "\n%s\n" % dashes
        # get newest clog time from the oldpkg
        # for any newer clog in pkg
        # print it
        oldlogs = oldpkg.changelog
        if len(oldlogs):
            #  Don't sort as that can screw the order up when time is the
            # same.
            oldtime = oldlogs[0][0]
            oldauth = oldlogs[0][1]
            oldcontent = oldlogs[0][2]
            for (t, author, content) in pkg.changelog:
                if t < oldtime:
                    break
                if (t == oldtime) and (author == oldauth) and (content == oldcontent):
                    break
                tm = datetime.date.fromtimestamp(int(t))
                tm = tm.strftime("%a %b %d %Y")
                msg += "* %s %s\n%s\n\n" % (tm, to_unicode(author), to_unicode(content))
            if opts.size:
                msg += "\nSize change: %s bytes\n" % sizechange

    print msg
Пример #9
0
 def _log_errors(self, errors):
     cur = self._get_cursor()
     if cur is None:
         return
     for error in errors:
         error = to_unicode(error)
         executeSQL(
             cur, """INSERT INTO trans_error
                       (tid, msg) VALUES (?, ?)""", (self._tid, error))
     self._commit()
Пример #10
0
 def _log_errors(self, errors):
     cur = self._get_cursor()
     if cur is None:
         return
     for error in errors:
         error = to_unicode(error)
         executeSQL(cur,
                    """INSERT INTO trans_error
                       (tid, msg) VALUES (?, ?)""", (self._tid, error))
     self._commit()
Пример #11
0
 def _trans_cmdline(self, cmdline):
     if not hasattr(self, '_tid'):
         return # Not configured to run
     cur = self._get_cursor()
     if cur is None or not self._update_db_file_2():
         return None
     res = executeSQL(cur,
                      """INSERT INTO trans_cmdline
                      (tid, cmdline)
                      VALUES (?, ?)""", (self._tid, to_unicode(cmdline)))
     return cur.lastrowid
Пример #12
0
def trans_data(yb, inp):
    data = inp.split(':', 2)
    if len(data) != 2:
        yb.logger.error("Error: Incorrect translated data, should be: 'lang:text'")
        sys.exit(50)
    lang, text = data
    alnum = string.ascii_letters + string.digits
    lang = re.sub('[^-' + alnum + '_.@]', '', lang)
    if not lang:
        yb.logger.error("Error: Incorrect/empty language for translated data")
        sys.exit(50)
    return lang, to_unicode(text)
Пример #13
0
def trans_data(yb, inp):
    data = inp.split(':', 2)
    if len(data) != 2:
        yb.logger.error(
            "Error: Incorrect translated data, should be: 'lang:text'")
        sys.exit(50)
    lang, text = data
    alnum = string.ascii_letters + string.digits
    lang = re.sub('[^-' + alnum + '_.@]', '', lang)
    if not lang:
        yb.logger.error("Error: Incorrect/empty language for translated data")
        sys.exit(50)
    return lang, to_unicode(text)
Пример #14
0
def _out_mod(opts, oldpkg, pkg, sizechange):
    if opts.simple:
        if opts.compare_arch:
            msg = "%s: %s ->  %s" % (pkg.name, oldpkg, pkg)
        else:
            msg = "%s: %s-%s-%s ->  %s-%s-%s" % (pkg.name, oldpkg.name,
                                                 oldpkg.ver, oldpkg.rel,
                                                 pkg.name, pkg.ver, pkg.rel)
    else:
        if opts.compare_arch:
            msg = "%s" % pkg
        else:
            msg = "%s-%s-%s" % (pkg.name, pkg.ver, pkg.rel)
        dashes = "-" * len(msg)
        msg += "\n%s\n" % dashes
        # get newest clog time from the oldpkg
        # for any newer clog in pkg
        # print it
        oldlogs = oldpkg.changelog
        if len(oldlogs):
            #  Don't sort as that can screw the order up when time is the
            # same.
            oldtime = oldlogs[0][0]
            oldauth = oldlogs[0][1]
            oldcontent = oldlogs[0][2]
            for (t, author, content) in pkg.changelog:
                if t < oldtime:
                    break
                if ((t == oldtime) and (author == oldauth)
                        and (content == oldcontent)):
                    break
                tm = datetime.date.fromtimestamp(int(t))
                tm = tm.strftime("%a %b %d %Y")
                msg += "* %s %s\n%s\n\n" % (tm, to_unicode(author),
                                            to_unicode(content))
            if opts.size:
                msg += "\nSize change: %s bytes\n" % sizechange

    print msg
Пример #15
0
    def log_scriptlet_output(self, data, msg):
        """ Note that data can be either a real pkg. ... or not. """
        if msg is None or not hasattr(self, '_tid'):
            return # Not configured to run

        cur = self._get_cursor()
        if cur is None:
            return # Should never happen, due to above
        for error in msg.splitlines():
            error = to_unicode(error)
            executeSQL(cur,
                       """INSERT INTO trans_script_stdout
                          (tid, line) VALUES (?, ?)""", (self._tid, error))
        self._commit()
Пример #16
0
    def log_scriptlet_output(self, data, msg):
        """ Note that data can be either a real pkg. ... or not. """
        if msg is None or not hasattr(self, '_tid'):
            return  # Not configured to run

        cur = self._get_cursor()
        if cur is None:
            return  # Should never happen, due to above
        for error in msg.splitlines():
            error = to_unicode(error)
            executeSQL(
                cur, """INSERT INTO trans_script_stdout
                          (tid, line) VALUES (?, ?)""", (self._tid, error))
        self._commit()
Пример #17
0
def _show_changes_changelog(conduit, srpms):
    for name in sorted(srpms.keys()):
        rpms = []
        if name in origpkgs:
            for rpm in srpms[name]:
                rpms.append("%s" % rpm)
            done = False
            kvf = conduit._base.fmtKeyValFill
            rpm_names = ", ".join(sorted(rpms))
            for line in changelog_delta(srpms[name][0], origpkgs[name]):
                if not done:
                    conduit.info(2,kvf("ChangeLog for: ", rpm_names))
                done = True
                conduit.info(2, "%s\n" % to_unicode(line))
            if not done:
                conduit.info(2, "%s\n" % kvf("** No ChangeLog for: ",rpm_names))
Пример #18
0
def _show_changes_changelog(conduit, srpms):
    for name in sorted(srpms.keys()):
        rpms = []
        if name in origpkgs:
            for rpm in srpms[name]:
                rpms.append("%s" % rpm)
            done = False
            kvf = conduit._base.fmtKeyValFill
            rpm_names = ", ".join(sorted(rpms))
            for line in changelog_delta(srpms[name][0], origpkgs[name]):
                if not done:
                    conduit.info(2, kvf("ChangeLog for: ", rpm_names))
                done = True
                conduit.info(2, "%s\n" % to_unicode(line))
            if not done:
                conduit.info(2,
                             "%s\n" % kvf("** No ChangeLog for: ", rpm_names))
Пример #19
0
    def _trans_rpmdb_problem(self, problem):
        if not hasattr(self, '_tid'):
            return # Not configured to run
        cur = self._get_cursor()
        if cur is None or not self._update_db_file_2():
            return None
        # str(problem) doesn't work if problem contains unicode(),
        # unicode(problem) doesn't work in python 2.4.x ... *sigh*.
        uproblem = to_unicode(problem.__str__())
        res = executeSQL(cur,
                         """INSERT INTO trans_rpmdb_problems
                         (tid, problem, msg)
                         VALUES (?, ?, ?)""", (self._tid,
                                               problem.problem,
                                               uproblem))
        rpid = cur.lastrowid

        if not rpid:
            return rpid

        pkgs = {}
        pkg = problem.pkg
        pkgs[pkg.pkgtup] = pkg
        if problem.problem == 'conflicts':
            for pkg in problem.conflicts:
                pkgs[pkg.pkgtup] = pkg
        if problem.problem == 'duplicates':
            pkgs[problem.duplicate.pkgtup] = problem.duplicate

        for pkg in pkgs.values():
            pid = self.pkg2pid(pkg)
            if pkg.pkgtup == problem.pkg.pkgtup:
                main = 'TRUE'
            else:
                main = 'FALSE'
            res = executeSQL(cur,
                             """INSERT INTO trans_prob_pkgs
                             (rpid, pkgtupid, main)
                             VALUES (?, ?, ?)""", (rpid, pid, main))

        return rpid
Пример #20
0
    def _trans_rpmdb_problem(self, problem):
        if not hasattr(self, '_tid'):
            return  # Not configured to run
        cur = self._get_cursor()
        if cur is None or not self._update_db_file_2():
            return None
        res = executeSQL(
            cur, """INSERT INTO trans_rpmdb_problems
                         (tid, problem, msg)
                         VALUES (?, ?, ?)""",
            (self._tid, problem.problem, to_unicode(str(problem))))
        rpid = cur.lastrowid

        if not rpid:
            return rpid

        pkgs = {}
        pkg = problem.pkg
        pkgs[pkg.pkgtup] = pkg
        if problem.problem == 'conflicts':
            for pkg in problem.conflicts:
                pkgs[pkg.pkgtup] = pkg
        if problem.problem == 'duplicates':
            pkgs[problem.duplicate.pkgtup] = problem.duplicate

        for pkg in pkgs.values():
            pid = self.pkg2pid(pkg)
            if pkg.pkgtup == problem.pkg.pkgtup:
                main = 'TRUE'
            else:
                main = 'FALSE'
            res = executeSQL(
                cur, """INSERT INTO trans_prob_pkgs
                             (rpid, pkgtupid, main)
                             VALUES (?, ?, ?)""", (rpid, pid, main))

        return rpid
Пример #21
0
 def descriptionByLang(self, lang):
     for langcode in self._expand_languages(lang):
         if self.translated_description.has_key(langcode):
             return to_unicode(self.translated_description[langcode])
     return to_unicode(self.description)
Пример #22
0
                pkgnames.update([pkg.name for pkg in req2pkgs(yb, rname)])

    for pkgname in pkgnames:
        if opts.remove:
            group.mandatory_packages.pop(pkgname, 0)
            group.optional_packages.pop(pkgname, 0)
            group.default_packages.pop(pkgname, 0)
        elif opts.mandatory:
            group.mandatory_packages[pkgname] = 1
        elif opts.optional:
            group.optional_packages[pkgname]  = 1
        else:
            group.default_packages[pkgname]   = 1

    for fname in opts.save:
        try:
            fo = open(fname, "wb")
            fo.write(comps.xml())
            del fo
        except IOError, e:
            yb.logger.error(e)
            sys.exit(50)

    if (opts.print2stdout or (opts.print2stdout is None and not opts.save)):
        # Why the to_unicode()? Why is it converting at all?
        # Why doesn't setup_locale() fix this? ... all good questions
        print to_unicode(comps.xml())

if __name__ == "__main__":
    main()
Пример #23
0
 def exFatal(e):
     logger.critical('\n\n%s', to_unicode(e.value))
     if unlock(): return 200
     return 1
Пример #24
0
    for pkgname in pkgnames:
        if opts.remove:
            group.mandatory_packages.pop(pkgname, 0)
            group.optional_packages.pop(pkgname, 0)
            group.default_packages.pop(pkgname, 0)
        elif opts.mandatory:
            group.mandatory_packages[pkgname] = 1
        elif opts.optional:
            group.optional_packages[pkgname] = 1
        else:
            group.default_packages[pkgname] = 1

    for fname in opts.save:
        try:
            fo = open(fname, "wb")
            fo.write(comps.xml())
            del fo
        except IOError, e:
            yb.logger.error(e)
            sys.exit(50)

    if (opts.print2stdout or (opts.print2stdout is None and not opts.save)):
        # Why the to_unicode()? Why is it converting at all?
        # Why doesn't setup_locale() fix this? ... all good questions
        print to_unicode(comps.xml())


if __name__ == "__main__":
    main()
Пример #25
0
    total_sizechange = 0
    add_sizechange = 0
    remove_sizechange = 0
    mod_sizechange = 0
    up_sizechange = 0
    down_sizechange = 0
    upgraded_pkgs = 0
    downgraded_pkgs = 0
    if ygh.add:
        for pkg in sorted(ygh.add):
            if opts.compare_arch:
                print 'New package: %s' % pkg
            else:
                print 'New package: %s-%s-%s' % (pkg.name, pkg.ver, pkg.rel)
            print '             %s\n' % to_unicode(pkg.summary)
            add_sizechange += int(pkg.size)
                
    if ygh.remove:
        for pkg in sorted(ygh.remove):
            if opts.compare_arch:
                print 'Removed package: %s' % pkg
            else:
                print 'Removed package:  %s-%s-%s' % (pkg.name, pkg.ver,pkg.rel)
            if pkg in ygh.obsoleted:
                print 'Obsoleted by   :  %s' % ygh.obsoleted[pkg]
            remove_sizechange += (int(pkg.size))
                
    if ygh.modified:
        print '\nUpdated Packages:\n'
        for (pkg, oldpkg) in sorted(ygh.modified):
Пример #26
0
    total_sizechange = 0
    add_sizechange = 0
    remove_sizechange = 0
    mod_sizechange = 0
    up_sizechange = 0
    down_sizechange = 0
    upgraded_pkgs = 0
    downgraded_pkgs = 0
    if ygh.add:
        for pkg in sorted(ygh.add):
            if opts.compare_arch:
                print "New package: %s" % pkg
            else:
                print "New package: %s-%s-%s" % (pkg.name, pkg.ver, pkg.rel)
            print "             %s\n" % to_unicode(pkg.summary)
            add_sizechange += int(pkg.size)

    if ygh.remove:
        for pkg in sorted(ygh.remove):
            if opts.compare_arch:
                print "Removed package: %s" % pkg
            else:
                print "Removed package:  %s-%s-%s" % (pkg.name, pkg.ver, pkg.rel)
            if pkg in ygh.obsoleted:
                print "Obsoleted by   :  %s" % ygh.obsoleted[pkg]
            remove_sizechange += int(pkg.size)

    if ygh.modified:
        print "\nUpdated Packages:\n"
        for (pkg, oldpkg) in sorted(ygh.modified):
Пример #27
0
 def __unicode__(self):
     return '%s' % to_unicode(self.value)
Пример #28
0
 def descriptionByLang(self, lang):
     for langcode in self._expand_languages(lang):
         if self.translated_description.has_key(langcode):
             return to_unicode(self.translated_description[langcode])
     return to_unicode(self.description)
Пример #29
0
    total_sizechange = 0
    add_sizechange = 0
    remove_sizechange = 0
    mod_sizechange = 0
    up_sizechange = 0
    down_sizechange = 0
    upgraded_pkgs = 0
    downgraded_pkgs = 0
    if ygh.add:
        for pkg in sorted(ygh.add):
            if opts.compare_arch:
                print 'New package: %s' % pkg
            else:
                print 'New package: %s-%s-%s' % (pkg.name, pkg.ver, pkg.rel)
            print '             %s\n' % to_unicode(pkg.summary)
            add_sizechange += int(pkg.size)

    if ygh.remove:
        for pkg in sorted(ygh.remove):
            if opts.compare_arch:
                print 'Removed package: %s' % pkg
            else:
                print 'Removed package:  %s-%s-%s' % (pkg.name, pkg.ver,
                                                      pkg.rel)
            if pkg in ygh.obsoleted:
                print 'Obsoleted by   :  %s' % ygh.obsoleted[pkg]
            remove_sizechange += (int(pkg.size))

    if ygh.modified:
        print '\nUpdated Packages:\n'
 def __unicode__(self):
     return to_unicode(self.text())
Пример #31
0
            sys.exit(1)
    if not opts.quiet: print 'performing the diff'
    ygh = my.dy_diff(opts.compare_arch)
    


    total_sizechange = 0
    add_sizechange = 0
    remove_sizechange = 0
    if ygh.add:
        for pkg in sorted(ygh.add):
            if opts.compare_arch:
                print 'New package: %s' % pkg
            else:
                print 'New package: %s-%s-%s' % (pkg.name, pkg.ver, pkg.rel)
            print '             %s\n' % to_unicode(pkg.summary)
            add_sizechange += int(pkg.size)
                
    if ygh.remove:
        for pkg in sorted(ygh.remove):
            if opts.compare_arch:
                print 'Removed package: %s' % pkg
            else:
                print 'Removed package:  %s-%s-%s' % (pkg.name, pkg.ver,pkg.rel)
            if pkg in ygh.obsoleted:
                print 'Obsoleted by   :  %s' % ygh.obsoleted[pkg]
            remove_sizechange += (int(pkg.size))
                
    if ygh.modified:
        print '\nUpdated Packages:\n'
        for (pkg, oldpkg) in sorted(ygh.modified):