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)
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
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
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('')
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('')
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
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
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()
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()
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
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)
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)
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
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()
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()
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))
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))
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
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
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)
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()
def exFatal(e): logger.critical('\n\n%s', to_unicode(e.value)) if unlock(): return 200 return 1
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()
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):
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):
def __unicode__(self): return '%s' % to_unicode(self.value)
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())
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):