rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
self.step_vectors[ chrom ][ 0 : self.chrom_lengths[chrom] ] = set()
self.step_vectors[ chrom ][ 0 : chrom_lengths[chrom] ] = set()
def __init__( self, dict chrom_lengths, bool stranded=True ): GenomicArray.__init__( self, chrom_lengths, stranded, 'O' ) for chrom in self.step_vectors: if self.stranded: self.step_vectors[ chrom ][ strand ][ 0 : self.chrom_lengths[chrom] ] = set() else: self.step_vectors[ chrom ][ 0 : self.chrom_lengths[chrom] ] = set()
newset = set.copy()
newset = oldset.copy()
def _f( oldset ): newset = set.copy() newset.add( value ) return newset
sys.stderr.write( "Error: %s\n" % "; ".join( sys.exc_info()[1] ) )
sys.stderr.write( "Error: %s\n" % str( sys.exc_info()[1] ) )
def main(): optParser = optparse.OptionParser( usage = "%prog [options] sam_file gff_file", description= "This script takes an alignment file in SAM format and a " + "feature file in GFF format and calculates for each feature " + "the number of reads mapping to it. See " + "http://www-huber.embl.de/users/anders/HTSeq/doc/count.html for details.", epilog = "Written by Simon Anders ([email protected]), European Molecular Biology " + "Laboratory (EMBL). (c) 2010. Released under the terms of the GNU General " + "Public License v3. Part of the 'HTSeq' framework, version %s." % HTSeq.__version__ ) optParser.add_option( "-m", "--mode", type="choice", dest="mode", choices = ( "union", "intersection-strict", "intersection-nonempty" ), default = "union", help = "mode to handle reads overlapping more than one feature" + "(choices: union, intersection-strict, intersection-nonempty; default: union)" ) optParser.add_option( "-t", "--type", type="string", dest="featuretype", default = "exon", help = "feature type (3rd column in GFF file) to be used, " + "all features of other type are ignored (default, suitable for Ensembl " + "GTF files: exon)" ) optParser.add_option( "-i", "--idattr", type="string", dest="idattr", default = "gene_id", help = "GFF attribute to be used as feature ID (default, " + "suitable for Ensembl GTF files: gene_id)" ) optParser.add_option( "-s", "--stranded", type="choice", dest="stranded", choices = ( "yes", "no" ), default = "yes", help = "whether the data is from a strand-specific assay (default: yes)" ) optParser.add_option( "-q", "--quiet", action="store_true", dest="quiet", help = "suppress progress report and warnings" ) if len( sys.argv ) == 1: optParser.print_help() sys.exit(1) (opts, args) = optParser.parse_args() if len( args ) != 2: sys.stderr.write( sys.argv[0] + ": Error: Please provide two arguments.\n" ) sys.stderr.write( " Call with '-h' to get usage information.\n" ) sys.exit( 1 ) warnings.showwarning = my_showwarning try: count_reads_in_features( args[0], args[1], opts.stranded == "yes", opts.mode, opts.featuretype, opts.idattr, opts.quiet ) except: sys.stderr.write( "Error: %s\n" % "; ".join( sys.exc_info()[1] ) ) sys.stderr.write( "[Exception type: %s, raised in %s:%d]\n" % ( sys.exc_info()[1].__class__.__name__, os.path.basename(traceback.extract_tb( sys.exc_info()[2] )[-1][0]), traceback.extract_tb( sys.exc_info()[2] )[-1][1] ) ) sys.exit( 1 )
fd = open(lockfile, 'r')
try: fd = open(lockfile, 'r') except (IOError, OSError), e: msg = _("Could not open lock %s: %s") % (lockfile, e) raise Errors.LockError(1, msg)
def doLock(self, lockfile = YUM_PID_FILE): """perform the yum locking, raise yum-based exceptions, not OSErrors""" # if we're not root then we don't lock - just return nicely if self.conf.uid != 0: return root = self.conf.installroot lockfile = root + '/' + lockfile # lock in the chroot lockfile = os.path.normpath(lockfile) # get rid of silly preceding extra / mypid=str(os.getpid()) while not self._lock(lockfile, mypid, 0644): fd = open(lockfile, 'r') try: oldpid = int(fd.readline()) except ValueError: # bogus data in the pid file. Throw away. self._unlock(lockfile) else: if oldpid == os.getpid(): # if we own the lock, we're fine break try: os.kill(oldpid, 0) except OSError, e: if e[0] == errno.ESRCH: # The pid doesn't exist self._unlock(lockfile) else: # Whoa. What the heck happened? msg = _('Unable to check if PID %s is active') % oldpid raise Errors.LockError(1, msg, oldpid) else: # Another copy seems to be running. msg = _('Existing lock %s: another copy is running as pid %s.') % (lockfile, oldpid) raise Errors.LockError(0, msg, oldpid) # We've got the lock, store it so we can auto-unlock on __del__... self._lockfile = lockfile
my_csum = misc.checksum(csum_type, fp) my_st_size = fp.read_size
if fp.read_size: my_csum = misc.checksum(csum_type, fp) my_st_size = fp.read_size
def _ftype(mode): """ Given a "mode" return the name of the type of file. """ if stat.S_ISREG(mode): return "file" if stat.S_ISDIR(mode): return "directory" if stat.S_ISLNK(mode): return "symlink" if stat.S_ISFIFO(mode): return "fifo" if stat.S_ISCHR(mode): return "character device" if stat.S_ISBLK(mode): return "block device" return "<unknown>"
prob.disk_value = my_st.st_size
prob.disk_value = my_st_size
def _ftype(mode): """ Given a "mode" return the name of the type of file. """ if stat.S_ISREG(mode): return "file" if stat.S_ISDIR(mode): return "directory" if stat.S_ISLNK(mode): return "symlink" if stat.S_ISFIFO(mode): return "fifo" if stat.S_ISCHR(mode): return "character device" if stat.S_ISBLK(mode): return "block device" return "<unknown>"
self.logger.warning(_("Removing %s from the transaction") % txmbr)
self.logger.info(_("Removing %s from the transaction") % txmbr)
def remove(self, po=None, **kwargs): """try to find and mark for remove the specified package(s) - if po is specified then that package object (if it is installed) will be marked for removal. if no po then look at kwargs, if neither then raise an exception"""
omtime = os.path.getmtime(rpmdbfname)
omtime = os.path.getctime(rpmdbfname)
def _get_cached_simpleVersion_main(self): """ Return the cached string of the main rpmdbv. """ if self._have_cached_rpmdbv_data is not None: return self._have_cached_rpmdbv_data
('-c', '-d', '-e', '--installroot',
('-c', '--config', '-d', '--debuglevel', '-e', '--errorlevel', '--installroot',
def firstParse(self,args): # Parse only command line options that affect basic yum setup try: args = _filtercmdline( ('--noplugins','--version','-q', '-v', "--quiet", "--verbose"), ('-c', '-d', '-e', '--installroot', '--disableplugin', '--enableplugin', '--releasever', '--setopt'), args) except ValueError, arg: self.base.usage() print >> sys.stderr, (_("\n\n%s: %s option requires an argument") % ('Command line error', arg)) sys.exit(1) return self.parse_args(args=args)[0]
return 1, ['Failed history info']
return 1, ['Failed history list']
def historyListCmd(self, extcmds): """ Shows the user a list of data about the history. """
try: int(tid) except ValueError: self.logger.critical(_('No transaction ID given')) return 1, ['Failed history addon-info'] except TypeError: pass
if tid == 'last': tid = None if tid is not None: try: int(tid) except ValueError: self.logger.critical(_('Bad transaction ID given')) return 1, ['Failed history addon-info']
def historyAddonInfoCmd(self, extcmds): tid = None if len(extcmds) > 1: tid = extcmds[1] try: int(tid) except ValueError: self.logger.critical(_('No transaction ID given')) return 1, ['Failed history addon-info'] except TypeError: pass # No tid arg. passed, use last...
def _try_read_cpuinfo(): """ Try to read /proc/cpuinfo ... if we can't ignore errors (ie. proc not mounted). """ try: lines = open("/proc/cpuinfo", "r").readlines() return lines except: return []
def getArchList(thisarch=None): # this returns a list of archs that are compatible with arch given if not thisarch: thisarch = canonArch archlist = [thisarch] while thisarch in arches: thisarch = arches[thisarch] archlist.append(thisarch) # hack hack hack # sparc64v is also sparc64 compat if archlist[0] == "sparc64v": archlist.insert(1,"sparc64") # if we're a weirdo arch - add noarch on there. if len(archlist) == 1 and archlist[0] == thisarch: archlist.append('noarch') return archlist
f = open("/proc/cpuinfo", "r") lines = f.readlines() f.close() for line in lines:
for line in _try_read_cpuinfo():
def getCanonX86Arch(arch): # if arch == "i586": f = open("/proc/cpuinfo", "r") lines = f.readlines() f.close() for line in lines: if line.startswith("model name") and line.find("Geode(TM)") != -1: return "geode" return arch # only athlon vs i686 isn't handled with uname currently if arch != "i686": return arch # if we're i686 and AuthenticAMD, then we should be an athlon f = open("/proc/cpuinfo", "r") lines = f.readlines() f.close() for line in lines: if line.startswith("vendor") and line.find("AuthenticAMD") != -1: return "athlon" # i686 doesn't guarantee cmov, but we depend on it elif line.startswith("flags") and line.find("cmov") == -1: return "i586" return arch
f = open("/proc/cpuinfo", "r") lines = f.readlines() f.close() for line in lines:
for line in _try_read_cpuinfo():
def getCanonPPCArch(arch): # FIXME: should I do better handling for mac, etc? if arch != "ppc64": return arch machine = None f = open("/proc/cpuinfo", "r") lines = f.readlines() f.close() for line in lines: if line.find("machine") != -1: machine = line.split(':')[1] break if machine is None: return arch if machine.find("CHRP IBM") != -1: return "ppc64pseries" if machine.find("iSeries") != -1: return "ppc64iseries" return arch
f = open("/proc/cpuinfo", "r") lines = f.readlines() f.close() for line in lines:
for line in _try_read_cpuinfo():
def getCanonSPARCArch(arch): # Deal with sun4v, sun4u, sun4m cases SPARCtype = None f = open("/proc/cpuinfo", "r") lines = f.readlines() f.close() for line in lines: if line.startswith("type"): SPARCtype = line.split(':')[1] break if SPARCtype is None: return arch if SPARCtype.find("sun4v") != -1: if arch.startswith("sparc64"): return "sparc64v" else: return "sparcv9v" if SPARCtype.find("sun4u") != -1: if arch.startswith("sparc64"): return "sparc64" else: return "sparcv9" if SPARCtype.find("sun4m") != -1: return "sparcv8" return arch
f = open("/proc/cpuinfo", "r") lines = f.readlines() f.close() for line in lines:
for line in _try_read_cpuinfo():
def getCanonX86_64Arch(arch): if arch != "x86_64": return arch vendor = None f = open("/proc/cpuinfo", "r") lines = f.readlines() f.close() for line in lines: if line.startswith("vendor_id"): vendor = line.split(':')[1] break if vendor is None: return arch if vendor.find("Authentic AMD") != -1 or vendor.find("AuthenticAMD") != -1: return "amd64" if vendor.find("GenuineIntel") != -1: return "ia32e" return arch
fo.write(data)
fo.write(to_unicode(data))
def write_addon_data(self, dataname, data): """append data to an arbitrary-named file in the history addon_path/transaction id location, returns True if write succeeded, False if not""" if not hasattr(self, '_tid'): # maybe we should raise an exception or a warning here? return False if not dataname: return False if not data: return False # make sure the tid dir exists tid_dir = self.conf.addon_path + '/' + str(self._tid)
raise Errors.YumBaseError, errors
self.logger.critical(_("Transaction couldn't start:")) for e in errors: self.logger.critical(e[0]) raise Errors.YumBaseError, _("Could not run transaction.")
def runTransaction(self, cb): """takes an rpm callback object, performs the transaction"""
if os.path.link(dir_fsvars + fsvar):
if os.path.islink(dir_fsvars + fsvar):
def _apply_installroot(yumconf, option): path = getattr(yumconf, option) ir_path = yumconf.installroot + path ir_path = ir_path.replace('//', '/') # os.path.normpath won't fix this and # it annoys me ir_path = varReplace(ir_path, yumvars) setattr(yumconf, option, ir_path)
txmbr = self.tsInfo.addErase(toremove)
txmbr = self.tsInfo.addErase(po)
def _sort_and_filter_installonly(pkgs): """ Allow the admin to specify some overrides fo installonly pkgs. using the yumdb. """ ret_beg = [] ret_mid = [] ret_end = [] for pkg in sorted(pkgs): if 'installonly' not in pkg.yumdb_info: ret_mid.append(pkg) continue
if hasattr(self, 'repo_setopts') and thisrepo.id in self.repo_setopts:
if thisrepo.id in self.repo_setopts:
def getReposFromConfigFile(self, repofn, repo_age=None, validate=None): """read in repositories from a config .repo file"""
if len(obsoleting) > 1: first = obsoleting[0] obsoleting = [pkgtup for pkgtup in obsoleting if first[0] == pkgtup[0]] if len(obsoleting) > 1: def _sort_ver(x, y): n1,a1,e1,v1,r1 = x n2,a2,e2,v2,r2 = y return compareEVR((e1,v1,r1), (e2,v2,r2)) obsoleting.sort(_sort_ver) first = obsoleting[0] obsoleting = [pkgtup for pkgtup in obsoleting if not _sort_ver(first, pkgtup)] if len(obsoleting) > 1: def _sort_arch_i(carch, a1, a2): res1 = archDifference(carch, a1) if not res1: return 0 res2 = archDifference(carch, a2) if not res2: return 0 return res1 - res2 def _sort_arch(x, y): n1,a1,e1,v1,r1 = x n2,a2,e2,v2,r2 = y ret = _sort_arch_i(po.arch, a1, a2) if ret: return ret ret = _sort_arch_i(self.arch.bestarch, a1, a2) return ret obsoleting.sort(_sort_arch)
def _pkg2obspkg(self, po): """ Given a package return the package it's obsoleted by and so we should install instead. Or None if there isn't one. """ thispkgobsdict = self.up.checkForObsolete([po.pkgtup]) if po.pkgtup in thispkgobsdict: obsoleting = thispkgobsdict[po.pkgtup] oobsoleting = [] # We want to keep the arch. of the obsoleted pkg. if possible. for opkgtup in obsoleting: if not canCoinstall(po.arch, opkgtup[1]): oobsoleting.append(opkgtup) if oobsoleting: obsoleting = oobsoleting # NOTE: if we move from noarch => multilib. then the ordering # here seems to always prefer i386 over x86_64 which is wrong. # Need to sort by arch? obsoleting = obsoleting[0] obsoleting_pkg = self.getPackageObject(obsoleting) return obsoleting_pkg return None
foo-1.i386 & foo-1.xf86_64 is updated by foo-2.i386 & foo-2.xf86_64 foo-2.xf86_64 has a missing req, and get skipped, foo-2.i386 has to be skipped to or it will fail in the rpm test transaction
foo-1.i386 & foo-1.x86_64 is updated by foo-2.i386 & foo-2.x86_64 foo-2.x86_64 has a missing req, and gets skipped, foo-2.i386 has to be skipped too or it will fail in the rpm test transaction
def testMultiLibUpdate(self): ''' foo-1.i386 & foo-1.xf86_64 is updated by foo-2.i386 & foo-2.xf86_64 foo-2.xf86_64 has a missing req, and get skipped, foo-2.i386 has to be skipped to or it will fail in the rpm test transaction ''' ipo1 = self.instPackage('foo', '1',arch='i386') ipo2 = self.instPackage('foo', '1',arch='x86_64') po1 = self.repoPackage('foo', '2',arch='i386') po2 = self.repoPackage('foo', '2',arch='x86_64') po2.addRequires('notfound', 'EQ', ('0', '1', '0')) self.tsInfo.addUpdate(po1, oldpo=ipo1) self.tsInfo.addUpdate(po2, oldpo=ipo2) self.assertEquals('empty', *self.resolveCode(skip=True)) self.assertResult([ipo1,ipo2])
for txmbr in self.tsInfo:
for txmbr in sorted(self.tsInfo):
def _printTransaction(self): #transaction set states state = { TS_UPDATE : "update", TS_INSTALL : "install", TS_TRUEINSTALL: "trueinstall", TS_ERASE : "erase", TS_OBSOLETED : "obsoleted", TS_OBSOLETING : "obsoleting", TS_AVAILABLE : "available", TS_UPDATED : "updated"}
for po,rel in txmbr.relatedto:
for po,rel in sorted(txmbr.relatedto):
def _printTransaction(self): #transaction set states state = { TS_UPDATE : "update", TS_INSTALL : "install", TS_TRUEINSTALL: "trueinstall", TS_ERASE : "erase", TS_OBSOLETED : "obsoleted", TS_OBSOLETING : "obsoleting", TS_AVAILABLE : "available", TS_UPDATED : "updated"}
self.assertResult((all['arp3'], all['aoop1'], all['aoop2']))
self.assertResult((all['arp3'], all['arp4']))
def testRLDaplMessWeirdInst3(self): rps, aps, ret, all = self._helperRLDaplMess() res, msg = self.runOperation(['install', 'dapl-2.0.15'], rps, aps)
self.assertResult((all['arp3'], all['aoop1'], all['aoop2']))
self.assertResult((all['arp3'], all['arp4']))
def testRLDaplMessWeirdUp3(self): rps, aps, ret, all = self._helperRLDaplMess() res, msg = self.runOperation(['update', 'dapl-2.0.15'], rps, aps)
msg += """\n </format>"""
if msg[-1] != '\n': msg += """\n""" msg += """ </format>"""
def _dump_format_items(self): msg = " <format>\n" if self.license: msg += """ <rpm:license>%s</rpm:license>\n""" % misc.to_xml(self.license) else: msg += """ <rpm:license/>\n""" if self.vendor: msg += """ <rpm:vendor>%s</rpm:vendor>\n""" % misc.to_xml(self.vendor) else: msg += """ <rpm:vendor/>\n""" if self.group: msg += """ <rpm:group>%s</rpm:group>\n""" % misc.to_xml(self.group) else: msg += """ <rpm:group/>\n""" if self.buildhost: msg += """ <rpm:buildhost>%s</rpm:buildhost>\n""" % misc.to_xml(self.buildhost) else: msg += """ <rpm:buildhost/>\n""" if self.sourcerpm: msg += """ <rpm:sourcerpm>%s</rpm:sourcerpm>\n""" % misc.to_xml(self.sourcerpm) msg +=""" <rpm:header-range start="%s" end="%s"/>""" % (self.hdrstart, self.hdrend) msg += self._dump_pco('provides') msg += self._dump_requires() msg += self._dump_pco('conflicts') msg += self._dump_pco('obsoletes') msg += self._dump_files(True) msg += """\n </format>""" return msg
msg =""
msg ="\n"
def _dump_files(self, primary=False): msg ="" if not primary: files = self.returnFileEntries('file') dirs = self.returnFileEntries('dir') ghosts = self.returnFileEntries('ghost') else: files = self.returnFileEntries('file', primary_only=True) dirs = self.returnFileEntries('dir', primary_only=True) ghosts = self.returnFileEntries('ghost', primary_only=True) for fn in files: msg += """ <file>%s</file>\n""" % misc.to_xml(fn) for fn in dirs: msg += """ <file type="dir">%s</file>\n""" % misc.to_xml(fn) for fn in ghosts: msg += """ <file type="ghost">%s</file>\n""" % misc.to_xml(fn) return msg
SELECT tid,rpid,name,epoch,version,release,arch,pkgtupid,
SELECT tid,rpid,name,epoch,version,release,arch,pkgtups.pkgtupid,
def search(self, patterns, ignore_case=True): """ Search for history transactions which contain specified packages al. la. "yum list". Returns transaction ids. """ # Search packages ... kind of sucks that it's search not list, pkglist?
def exUserCancel(self): self.logger.critical(_('\n\nExiting on user cancel')) if self.unlock(): return 200 return 1 def exIOError(self, e): if e.errno == 32: self.logger.critical(_('\n\nExiting on Broken Pipe')) else: self.logger.critical(_('\n\n%s') % str(e)) if self.unlock(): return 200 return 1 def exPluginExit(self, e): '''Called when a plugin raises PluginYumExit. Log the plugin's exit message if one was supplied. ''' exitmsg = str(e) if exitmsg: self.logger.warn('\n\n%s', exitmsg) if self.unlock(): return 200 return 1 def exFatal(self, e): self.logger.critical('\n\n%s', to_unicode(e.value)) if self.unlock(): return 200 return 1 def unlock(self): try: self.closeRpmDB() self.doUnlock() except Errors.LockError, e: return 200 return 0
def __init__(self,name,ver,usage): YumBaseCli.__init__(self) self._parser = YumOptionParser(base=self,utils=True,usage=usage) self._usage = usage self._utilName = name self._utilVer = ver self._option_group = OptionGroup(self._parser, "%s options" % self._utilName,"") self._parser.add_option_group(self._option_group) suppress_keyboard_interrupt_message() logger = logging.getLogger("yum.util") verbose_logger = logging.getLogger("yum.verbose.util") # Add yum-utils version to history records. if hasattr(self, 'run_with_package_names'): self.run_with_package_names.add("yum-utils")
def doUtilBuildTransaction(self): try: (result, resultmsgs) = self.buildTransaction() except plugins.PluginYumExit, e: return self.exPluginExit(e) except Errors.YumBaseError, e: result = 1 resultmsgs = [unicode(e)] except KeyboardInterrupt: return self.exUserCancel() except IOError, e: return self.exIOError(e) if result == 0: if self.unlock(): return 200 return 0 elif result == 1: for msg in resultmsgs: prefix = _('Error: %s') prefix2nd = (' ' * (utf8_width(prefix) - 2)) self.logger.critical(prefix, msg.replace('\n', '\n' + prefix2nd)) if not self.conf.skip_broken: self.verbose_logger.info(_(" You could try using --skip-broken to work around the problem")) if not self._rpmdb_warn_checks(out=self.verbose_logger.info, warn=False): self.verbose_logger.info(_(" You could try running: rpm -Va --nofiles --nodigest")) if self.unlock(): return 200 return 1 elif result == 2: pass else: self.logger.critical(_('Unknown Error(s): Exit Code: %d:'), result) for msg in resultmsgs: self.logger.critical(msg) if self.unlock(): return 200 return 3 self.verbose_logger.log(logginglevels.INFO_2, _('\nDependencies Resolved'))
def doUtilYumSetup(self): """do a default setup for all the normal/necessary yum components, really just a shorthand for testing""" # FIXME - we need another way to do this, I think. try: self.waitForLock() self._getTs() self._getRpmDB() self._getRepos(doSetup = True) self._getSacks() except Errors.YumBaseError, msg: self.logger.critical(str(msg)) sys.exit(1)
def exUserCancel(): self.logger.critical(_('\n\nExiting on user cancel')) if unlock(): return 200 return 1 def exIOError(e): if e.errno == 32: self.logger.critical(_('\n\nExiting on Broken Pipe')) else: self.logger.critical(_('\n\n%s') % str(e)) if unlock(): return 200 return 1 def exPluginExit(e): '''Called when a plugin raises PluginYumExit. Log the plugin's exit message if one was supplied. ''' exitmsg = str(e) if exitmsg: self.logger.warn('\n\n%s', exitmsg) if unlock(): return 200 return 1 def exFatal(e): self.logger.critical('\n\n%s', to_unicode(e.value)) if unlock(): return 200 return 1 def unlock(): try: self.closeRpmDB() self.doUnlock() except Errors.LockError, e: return 200 return 0
def exUserCancel(): self.logger.critical(_('\n\nExiting on user cancel')) if unlock(): return 200 return 1
return exPluginExit(e)
return self.exPluginExit(e)
def unlock(): try: self.closeRpmDB() self.doUnlock() except Errors.LockError, e: return 200 return 0
return exFatal(e)
return self.exFatal(e)
def unlock(): try: self.closeRpmDB() self.doUnlock() except Errors.LockError, e: return 200 return 0
return exUserCancel()
return self.exUserCancel()
def unlock(): try: self.closeRpmDB() self.doUnlock() except Errors.LockError, e: return 200 return 0
return exIOError(e)
return self.exIOError(e,)
def unlock(): try: self.closeRpmDB() self.doUnlock() except Errors.LockError, e: return 200 return 0
if unlock(): return 200
if self.unlock(): return 200
def unlock(): try: self.closeRpmDB() self.doUnlock() except Errors.LockError, e: return 200 return 0
self.verbose_logger.log(logginglevels.DEBUG_2, _('Not Updating Package that is already obsoleted: %s.%s %s:%s-%s'),
self.verbose_logger.log(logginglevels.DEBUG_2, _('Not Updating Package that is already obsoleted: %s.%s %s:%s-%s') %
def update(self, po=None, requiringPo=None, **kwargs): """try to mark for update the item(s) specified. po is a package object - if that is there, mark it for update, if possible else use **kwargs to match the package needing update if nothing is specified at all then attempt to update everything returns the list of txmbr of the items it marked for update""" # check for args - if no po nor kwargs, do them all # if po, do it, ignore all else # if no po do kwargs # uninstalled pkgs called for update get returned with errors in a list, maybe?
self.verbose_logger.log(logginglevels.DEBUG_2, _('Package is already obsoleted: %s.%s %s:%s-%s'), obsoleted)
self.verbose_logger.log(logginglevels.DEBUG_2, _('Package is already obsoleted: %s.%s %s:%s-%s') % obsoleted)
def update(self, po=None, requiringPo=None, **kwargs): """try to mark for update the item(s) specified. po is a package object - if that is there, mark it for update, if possible else use **kwargs to match the package needing update if nothing is specified at all then attempt to update everything returns the list of txmbr of the items it marked for update""" # check for args - if no po nor kwargs, do them all # if po, do it, ignore all else # if no po do kwargs # uninstalled pkgs called for update get returned with errors in a list, maybe?
self.verbose_logger.log(logginglevels.DEBUG_2, _('Not Updating Package that is already updated: %s.%s %s:%s-%s'),
self.verbose_logger.log(logginglevels.DEBUG_2, _('Not Updating Package that is already updated: %s.%s %s:%s-%s') %
def update(self, po=None, requiringPo=None, **kwargs): """try to mark for update the item(s) specified. po is a package object - if that is there, mark it for update, if possible else use **kwargs to match the package needing update if nothing is specified at all then attempt to update everything returns the list of txmbr of the items it marked for update""" # check for args - if no po nor kwargs, do them all # if po, do it, ignore all else # if no po do kwargs # uninstalled pkgs called for update get returned with errors in a list, maybe?
def _iter_two_pkgs(self, ignore):
def _iter_two_pkgs(self, ignore_provides):
def _iter_two_pkgs(self, ignore): last = None for pkg in sorted(self.returnPackages()): if pkg.name in ignore: continue if last is None: last = pkg continue yield last, pkg last = pkg
if pkg.name in ignore: continue
if pkg.name in ignore_provides: continue if ignore_provides.intersection(set(pkg.provides_names)): continue
def _iter_two_pkgs(self, ignore): last = None for pkg in sorted(self.returnPackages()): if pkg.name in ignore: continue if last is None: last = pkg continue yield last, pkg last = pkg
def check_duplicates(self, ignore=[]): """ Checks for any missing dependencies. """
def check_duplicates(self, ignore_provides=[]): """ Checks for any "duplicate packages" (those with multiple versions installed), we ignore any packages with a provide in the passed provide list (this is how installonlyworks, so we do the same). """ ignore_provides = set(ignore_provides)
def check_duplicates(self, ignore=[]): """ Checks for any missing dependencies. """
for last, pkg in self._iter_two_pkgs(ignore):
for last, pkg in self._iter_two_pkgs(ignore_provides):
def check_duplicates(self, ignore=[]): """ Checks for any missing dependencies. """
def decompress(filename, dest=None, fn_only=False):
def decompress(filename, dest=None, fn_only=False, check_timestamps=False):
def decompress(filename, dest=None, fn_only=False): """take a filename and decompress it into the same relative location. if the file is not compressed just return the file""" out = dest if not dest: out = filename if filename.endswith('.gz'): ztype='gz' if not dest: out = filename.replace('.gz', '') elif filename.endswith('.bz') or filename.endswith('.bz2'): ztype='bz2' if not dest: if filename.endswith('.bz'): out = filename.replace('.bz','') else: out = filename.replace('.bz2', '') elif filename.endswith('.xz'): ztype='xz' if not dest: out = filename.replace('.xz', '') else: out = filename # returning the same file since it is not compressed ztype = None if ztype and not fn_only: _decompress_chunked(filename, out, ztype) return out
''' Helper function to call _pkgRKNEVRAExcluded.
''' Helper function to call _pkgExcludedRKNEVRA.
def _pkgExcludedRKT(self, repo,pkgKey, pkgtup): ''' Helper function to call _pkgRKNEVRAExcluded. Takes a repo, pkgKey and a package tuple''' (n,a,e,v,r) = pkgtup return self._pkgExcludedRKNEVRA(repo, pkgKey, n,e,v,r,a)
''' Helper function to call _pkgRKNEVRAExcluded.
''' Helper function to call _pkgExcludedRKNEVRA.
def _pkgExcludedRKD(self, repo,pkgKey, data): ''' Helper function to call _pkgRKNEVRAExcluded. Takes a repo, pkgKey and a dict of package data''' (n,a,e,v,r) = (data['name'], data['arch'], data['epoch'], data['version'], data['release']) return self._pkgExcludedRKNEVRA(repo, pkgKey, n,e,v,r,a)
''' Helper function to call _pkgRKNEVRAExcluded.
''' Helper function to call _pkgExcludedRKNEVRA.
def _pkgExcluded(self, po): ''' Helper function to call _pkgRKNEVRAExcluded. Takes a package object. ''' return self._pkgExcludedRKT(po.repo, po.pkgKey, po.pkgtup)
if flags and type(flags) == type(0):
if flags and (type(flags) == type(0) or type(flags) == type(0L)):
def formatRequire (name, version, flags): ''' Return a human readable requirement string (ex. foobar >= 2.0) @param name: requirement name (ex. foobar) @param version: requirent version (ex. 2.0) @param flags: binary flags ( 0010 = equal, 0100 = greater than, 1000 = less than ) ''' s = name if flags and type(flags) == type(0): # Flag must be set and a int if flags & (rpm.RPMSENSE_LESS | rpm.RPMSENSE_GREATER | rpm.RPMSENSE_EQUAL): s = s + " " if flags & rpm.RPMSENSE_LESS: s = s + "<" if flags & rpm.RPMSENSE_GREATER: s = s + ">" if flags & rpm.RPMSENSE_EQUAL: s = s + "=" if version: s = "%s %s" %(s, version) return s
if count not in sorted_lists: sorted_lists[count] = [] sorted_lists[count].append((pkg, matchkeys, tagresults))
if pkg not in results_by_pkg: results_by_pkg[pkg] = [] results_by_pkg[pkg].append((matchkeys, tagresults))
def results2sorted_lists(tmpres, sorted_lists): for (po, count) in tmpres: # check the pkg for sanity # pop it into the sorted lists tmpkeys = set() tmpvalues = [] if count not in sorted_lists: sorted_lists[count] = [] for s in real_crit_lower: for field in fields: value = to_unicode(getattr(po, field)) if value and value.lower().find(s) != -1: tmpvalues.append(value) tmpkeys.add(rcl2c[s])
for item in sorted_lists.values(): for pkg, keys, values in item: if pkg not in results_by_pkg: results_by_pkg[pkg] = [] results_by_pkg[pkg].append((keys,values)) sorted_lists = {} for pkg in results_by_pkg: totkeys = [] totvals = [] for (keys, values) in results_by_pkg[pkg]: totkeys.extend(keys) totvals.extend(values) totkeys = misc.unique(totkeys) totvals = misc.unique(totvals) count = len(totkeys) if count not in sorted_lists: sorted_lists[count] = [] sorted_lists[count].append((pkg, totkeys, totvals))
def results2sorted_lists(tmpres, sorted_lists): for (po, count) in tmpres: # check the pkg for sanity # pop it into the sorted lists tmpkeys = set() tmpvalues = [] if count not in sorted_lists: sorted_lists[count] = [] for s in real_crit_lower: for field in fields: value = to_unicode(getattr(po, field)) if value and value.lower().find(s) != -1: tmpvalues.append(value) tmpkeys.add(rcl2c[s])
print x
print to_unicode(x.__str__())
def _out(x): print x
for error in msg.split('\n'):
for error in msg.splitlines():
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
if name is not None and name in self._pkgmatch_fails:
if name is not None and name in self._pkgname_fails:
def _search(self, name=None, epoch=None, ver=None, rel=None, arch=None): '''List of matching packages, to zero or more of NEVRA.''' if name is not None and name in self._pkgmatch_fails: return []
self._pkgmatch_fails.add(name)
self._pkgname_fails.add(name)
def _search(self, name=None, epoch=None, ver=None, rel=None, arch=None): '''List of matching packages, to zero or more of NEVRA.''' if name is not None and name in self._pkgmatch_fails: return []
return syslog_module.LOG_USER
return _syslog_facility_map["USER"]
def syslogFacilityMap(facility): if type(facility) == int: return facility elif facility.upper() in _syslog_facility_map: return _syslog_facility_map[facility.upper()] elif (facility.upper().startswith("LOG_") and facility[4:].upper() in _syslog_facility_map): return _syslog_facility_map[facility[4:].upper()] return syslog_module.LOG_USER
syslogformatter = logging.Formatter("yum: %(message)s")
def doLoggingSetup(debuglevel, errorlevel, syslog_ident=None, syslog_facility=None, syslog_device='/dev/log'): """ Configure the python logger. errorlevel is optional. If provided, it will override the logging level provided in the logging config file for error messages. debuglevel is optional. If provided, it will override the logging level provided in the logging config file for debug messages. """ global _added_handlers logging.basicConfig() if _added_handlers: if debuglevel is not None: setDebugLevel(debuglevel) if errorlevel is not None: setErrorLevel(errorlevel) return plainformatter = logging.Formatter("%(message)s") syslogformatter = logging.Formatter("yum: %(message)s") console_stdout = logging.StreamHandler(sys.stdout) console_stdout.setFormatter(plainformatter) verbose = logging.getLogger("yum.verbose") verbose.propagate = False verbose.addHandler(console_stdout) console_stderr = logging.StreamHandler(sys.stderr) console_stderr.setFormatter(plainformatter) logger = logging.getLogger("yum") logger.propagate = False logger.addHandler(console_stderr) filelogger = logging.getLogger("yum.filelogging") filelogger.setLevel(logging.INFO) filelogger.propagate = False log_dev = syslog_device global syslog if os.path.exists(log_dev): try: syslog = logging.handlers.SysLogHandler(log_dev) syslog.setFormatter(syslogformatter) filelogger.addHandler(syslog) if syslog_ident is not None or syslog_facility is not None: ident = syslog_ident or '' facil = syslog_facility or 'LOG_USER' syslog_module.openlog(ident, 0, syslogFacilityMap(facil)) except socket.error: if syslog is not None: syslog.close() _added_handlers = True if debuglevel is not None: setDebugLevel(debuglevel) if errorlevel is not None: setErrorLevel(errorlevel)
log_dev = syslog_device
def doLoggingSetup(debuglevel, errorlevel, syslog_ident=None, syslog_facility=None, syslog_device='/dev/log'): """ Configure the python logger. errorlevel is optional. If provided, it will override the logging level provided in the logging config file for error messages. debuglevel is optional. If provided, it will override the logging level provided in the logging config file for debug messages. """ global _added_handlers logging.basicConfig() if _added_handlers: if debuglevel is not None: setDebugLevel(debuglevel) if errorlevel is not None: setErrorLevel(errorlevel) return plainformatter = logging.Formatter("%(message)s") syslogformatter = logging.Formatter("yum: %(message)s") console_stdout = logging.StreamHandler(sys.stdout) console_stdout.setFormatter(plainformatter) verbose = logging.getLogger("yum.verbose") verbose.propagate = False verbose.addHandler(console_stdout) console_stderr = logging.StreamHandler(sys.stderr) console_stderr.setFormatter(plainformatter) logger = logging.getLogger("yum") logger.propagate = False logger.addHandler(console_stderr) filelogger = logging.getLogger("yum.filelogging") filelogger.setLevel(logging.INFO) filelogger.propagate = False log_dev = syslog_device global syslog if os.path.exists(log_dev): try: syslog = logging.handlers.SysLogHandler(log_dev) syslog.setFormatter(syslogformatter) filelogger.addHandler(syslog) if syslog_ident is not None or syslog_facility is not None: ident = syslog_ident or '' facil = syslog_facility or 'LOG_USER' syslog_module.openlog(ident, 0, syslogFacilityMap(facil)) except socket.error: if syslog is not None: syslog.close() _added_handlers = True if debuglevel is not None: setDebugLevel(debuglevel) if errorlevel is not None: setErrorLevel(errorlevel)
if os.path.exists(log_dev):
if os.path.exists(syslog_device):
def doLoggingSetup(debuglevel, errorlevel, syslog_ident=None, syslog_facility=None, syslog_device='/dev/log'): """ Configure the python logger. errorlevel is optional. If provided, it will override the logging level provided in the logging config file for error messages. debuglevel is optional. If provided, it will override the logging level provided in the logging config file for debug messages. """ global _added_handlers logging.basicConfig() if _added_handlers: if debuglevel is not None: setDebugLevel(debuglevel) if errorlevel is not None: setErrorLevel(errorlevel) return plainformatter = logging.Formatter("%(message)s") syslogformatter = logging.Formatter("yum: %(message)s") console_stdout = logging.StreamHandler(sys.stdout) console_stdout.setFormatter(plainformatter) verbose = logging.getLogger("yum.verbose") verbose.propagate = False verbose.addHandler(console_stdout) console_stderr = logging.StreamHandler(sys.stderr) console_stderr.setFormatter(plainformatter) logger = logging.getLogger("yum") logger.propagate = False logger.addHandler(console_stderr) filelogger = logging.getLogger("yum.filelogging") filelogger.setLevel(logging.INFO) filelogger.propagate = False log_dev = syslog_device global syslog if os.path.exists(log_dev): try: syslog = logging.handlers.SysLogHandler(log_dev) syslog.setFormatter(syslogformatter) filelogger.addHandler(syslog) if syslog_ident is not None or syslog_facility is not None: ident = syslog_ident or '' facil = syslog_facility or 'LOG_USER' syslog_module.openlog(ident, 0, syslogFacilityMap(facil)) except socket.error: if syslog is not None: syslog.close() _added_handlers = True if debuglevel is not None: setDebugLevel(debuglevel) if errorlevel is not None: setErrorLevel(errorlevel)
syslog = logging.handlers.SysLogHandler(log_dev) syslog.setFormatter(syslogformatter) filelogger.addHandler(syslog) if syslog_ident is not None or syslog_facility is not None: ident = syslog_ident or '' facil = syslog_facility or 'LOG_USER' syslog_module.openlog(ident, 0, syslogFacilityMap(facil))
facil = syslogFacilityMap(syslog_facility or "USER") syslog = logging.handlers.SysLogHandler(syslog_device, facil)
def doLoggingSetup(debuglevel, errorlevel, syslog_ident=None, syslog_facility=None, syslog_device='/dev/log'): """ Configure the python logger. errorlevel is optional. If provided, it will override the logging level provided in the logging config file for error messages. debuglevel is optional. If provided, it will override the logging level provided in the logging config file for debug messages. """ global _added_handlers logging.basicConfig() if _added_handlers: if debuglevel is not None: setDebugLevel(debuglevel) if errorlevel is not None: setErrorLevel(errorlevel) return plainformatter = logging.Formatter("%(message)s") syslogformatter = logging.Formatter("yum: %(message)s") console_stdout = logging.StreamHandler(sys.stdout) console_stdout.setFormatter(plainformatter) verbose = logging.getLogger("yum.verbose") verbose.propagate = False verbose.addHandler(console_stdout) console_stderr = logging.StreamHandler(sys.stderr) console_stderr.setFormatter(plainformatter) logger = logging.getLogger("yum") logger.propagate = False logger.addHandler(console_stderr) filelogger = logging.getLogger("yum.filelogging") filelogger.setLevel(logging.INFO) filelogger.propagate = False log_dev = syslog_device global syslog if os.path.exists(log_dev): try: syslog = logging.handlers.SysLogHandler(log_dev) syslog.setFormatter(syslogformatter) filelogger.addHandler(syslog) if syslog_ident is not None or syslog_facility is not None: ident = syslog_ident or '' facil = syslog_facility or 'LOG_USER' syslog_module.openlog(ident, 0, syslogFacilityMap(facil)) except socket.error: if syslog is not None: syslog.close() _added_handlers = True if debuglevel is not None: setDebugLevel(debuglevel) if errorlevel is not None: setErrorLevel(errorlevel)
foo.i386 will be compared"""
foo.i386 will be compared Note that given: foo-1.i386; foo-2.i386 and foo-3.x86_64 The last _two_ pkgs will be returned, not just one of them. """
def returnNewestByNameArch(self, naTup=None, patterns=None, ignore_case=False): """return list of newest packages based on name, arch matching this means(in name.arch form): foo.i386 and foo.noarch are not compared to each other for highest version only foo.i386 and foo.i386 will be compared""" raise NotImplementedError()
be compared to each other for highest version. Note that given: foo-1.i386; foo-2.i386 and foo-3.x86_64 The last _two_ pkgs will be returned, not just one of them. """
be compared to each other for highest version."""
def returnNewestByName(self, name=None, patterns=None, ignore_case=False): """return list of newest packages based on name matching this means(in name.arch form): foo.i386 and foo.noarch will be compared to each other for highest version. Note that given: foo-1.i386; foo-2.i386 and foo-3.x86_64 The last _two_ pkgs will be returned, not just one of them. """ raise NotImplementedError()
foo.i386 will be compared"""
foo.i386 will be compared. Note that given: foo-1.i386; foo-2.i386 and foo-3.x86_64 The last _two_ pkgs will be returned, not just one of them. """
def returnNewestByNameArch(self, naTup=None, patterns=None, ignore_case=False): """return list of newest packages based on name, arch matching this means(in name.arch form): foo.i386 and foo.noarch are not compared to each other for highest version only foo.i386 and foo.i386 will be compared""" calr = self._computeAggregateListResult pkgs = calr("returnNewestByNameArch", naTup, patterns, ignore_case) pkgs = packagesNewestByNameArch(pkgs) if not pkgs and (naTup or patterns): ui_pats = ", ".join(patterns or []) raise PackageSackError, 'No Package Matching %s' % ui_pats return pkgs
be compared to each other for highest version. Note that given: foo-1.i386; foo-2.i386 and foo-3.x86_64 The last _two_ pkgs will be returned, not just one of them. """
be compared to each other for highest version."""
def returnNewestByName(self, name=None, patterns=None, ignore_case=False): """return list of newest packages based on name matching this means(in name.arch form): foo.i386 and foo.noarch will be compared to each other for highest version. Note that given: foo-1.i386; foo-2.i386 and foo-3.x86_64 The last _two_ pkgs will be returned, not just one of them. """ pkgs = self._computeAggregateListResult("returnNewestByName", name, patterns, ignore_case) pkgs = packagesNewestByName(pkgs) if not pkgs and (name or patterns): if name: ui_pats = name else: ui_pats = ", ".join(patterns or []) raise PackageSackError, 'No Package Matching %s' % ui_pats return pkgs
foo.i386 will be compared"""
foo.i386 will be compared Note that given: foo-1.i386; foo-2.i386 and foo-3.x86_64 The last _two_ pkgs will be returned, not just one of them. """
def returnNewestByNameArch(self, naTup=None, patterns=None, ignore_case=False): """return list of newest packages based on name, arch matching this means(in name.arch form): foo.i386 and foo.noarch are not compared to each other for highest version only foo.i386 and foo.i386 will be compared""" highdict = {} # If naTup is set, only iterate through packages that match that # name if (naTup): self._checkIndexes(failure='build') where = self.nevra.get((naTup[0],None,None,None,None)) if (not where): raise PackageSackError, 'No Package Matching %s.%s' % naTup else: where = self.returnPackages(patterns=patterns, ignore_case=ignore_case)
be compared to each other for highest version. Note that given: foo-1.i386; foo-2.i386 and foo-3.x86_64 The last _two_ pkgs will be returned, not just one of them. """
be compared to each other for highest version."""
def returnNewestByName(self, name=None, patterns=None, ignore_case=False): """return list of newest packages based on name matching this means(in name.arch form): foo.i386 and foo.noarch will be compared to each other for highest version. Note that given: foo-1.i386; foo-2.i386 and foo-3.x86_64 The last _two_ pkgs will be returned, not just one of them. """
Note that given: foo-1.i386; foo-2.i386 and foo-3.x86_64 The last _two_ pkgs will be returned, not just one of them. """
Note that given: foo-1.i386; foo-2.i386 and foo-3.x86_64"""
def packagesNewestByName(pkgs): """ Does the same as PackageSack.returnNewestByName(). Note that given: foo-1.i386; foo-2.i386 and foo-3.x86_64 The last _two_ pkgs will be returned, not just one of them. """ newest = {} for pkg in pkgs: key = pkg.name # Can't use pkg.__cmp__ because it takes .arch into account cval = 1 if key in newest: cval = pkg.verCMP(newest[key][0]) if cval > 0: newest[key] = [pkg] elif cval == 0: newest[key].append(pkg) ret = [] for vals in newest.itervalues(): ret.extend(vals) return ret
def _ftype(mode): """ Given a "mode" return the name of the type of file. """ if stat.S_ISREG(mode): return "file" if stat.S_ISDIR(mode): return "directory" if stat.S_ISLNK(mode): return "symlink" if stat.S_ISFIFO(mode): return "fifo" if stat.S_ISCHR(mode): return "character device" if stat.S_ISBLK(mode): return "block device" return "<unknown>" statemap = {rpm.RPMFILE_STATE_REPLACED : 'replaced', rpm.RPMFILE_STATE_NOTINSTALLED : 'not installed', rpm.RPMFILE_STATE_WRONGCOLOR : 'wrong color', rpm.RPMFILE_STATE_NETSHARED : 'netshared'}
def _ftype(mode): """ Given a "mode" return the name of the type of file. """ if stat.S_ISREG(mode): return "file" if stat.S_ISDIR(mode): return "directory" if stat.S_ISLNK(mode): return "symlink" if stat.S_ISFIFO(mode): return "fifo" if stat.S_ISCHR(mode): return "character device" if stat.S_ISBLK(mode): return "block device" return "<unknown>"
for filetuple in fi: (fn, size, mode, mtime, flags, dev, inode, link, state, vflags, user, group, csum) = filetuple if patterns: matched = False for p in patterns: if fnmatch.fnmatch(fn, p): matched = True break if not matched: continue ftypes = [] if flags & rpm.RPMFILE_CONFIG: ftypes.append('configuration') if flags & rpm.RPMFILE_DOC: ftypes.append('documentation') if flags & rpm.RPMFILE_GHOST: ftypes.append('ghost') if flags & rpm.RPMFILE_LICENSE: ftypes.append('license') if flags & rpm.RPMFILE_PUBKEY: ftypes.append('public key') if flags & rpm.RPMFILE_README: ftypes.append('README') if flags & rpm.RPMFILE_MISSINGOK: ftypes.append('missing ok') if all: vflags = -1 if state != rpm.RPMFILE_STATE_NORMAL: if state in statemap: ftypes.append("state=" + statemap[state]) else: ftypes.append("state=<unknown>")
pfs = _RPMVerifyPackage(fi, csum_type, patterns, all) for pf in pfs: fn = pf.filename ftypes = list(pf.rpmfile_types) if pf.rpmfile_state != "normal": ftypes.append("state=" + pf.rpmfile_state)
def _ftype(mode): """ Given a "mode" return the name of the type of file. """ if stat.S_ISREG(mode): return "file" if stat.S_ISDIR(mode): return "directory" if stat.S_ISLNK(mode): return "symlink" if stat.S_ISFIFO(mode): return "fifo" if stat.S_ISCHR(mode): return "character device" if stat.S_ISBLK(mode): return "block device" return "<unknown>"
if flags & rpm.RPMFILE_MISSINGOK and fake_problems:
if 'missing ok' in pf.rpmfile_types and fake_problems:
def _ftype(mode): """ Given a "mode" return the name of the type of file. """ if stat.S_ISREG(mode): return "file" if stat.S_ISDIR(mode): return "directory" if stat.S_ISLNK(mode): return "symlink" if stat.S_ISFIFO(mode): return "fifo" if stat.S_ISCHR(mode): return "character device" if stat.S_ISBLK(mode): return "block device" return "<unknown>"
if flags & rpm.RPMFILE_MISSINGOK and not all:
if 'missing ok' in pf.rpmfile_types and not all:
def _ftype(mode): """ Given a "mode" return the name of the type of file. """ if stat.S_ISREG(mode): return "file" if stat.S_ISDIR(mode): return "directory" if stat.S_ISLNK(mode): return "symlink" if stat.S_ISFIFO(mode): return "fifo" if stat.S_ISCHR(mode): return "character device" if stat.S_ISBLK(mode): return "block device" return "<unknown>"
if flags & rpm.RPMFILE_GHOST and fake_problems:
if 'ghost' in pf.rpmfile_types and fake_problems:
def _ftype(mode): """ Given a "mode" return the name of the type of file. """ if stat.S_ISREG(mode): return "file" if stat.S_ISDIR(mode): return "directory" if stat.S_ISLNK(mode): return "symlink" if stat.S_ISFIFO(mode): return "fifo" if stat.S_ISCHR(mode): return "character device" if stat.S_ISBLK(mode): return "block device" return "<unknown>"
if flags & rpm.RPMFILE_GHOST and not all:
if 'ghost' in pf.rpmfile_types and not all:
def _ftype(mode): """ Given a "mode" return the name of the type of file. """ if stat.S_ISREG(mode): return "file" if stat.S_ISDIR(mode): return "directory" if stat.S_ISLNK(mode): return "symlink" if stat.S_ISFIFO(mode): return "fifo" if stat.S_ISCHR(mode): return "character device" if stat.S_ISBLK(mode): return "block device" return "<unknown>"
if os.path.lexists(fn):
if os.path.lexists(pf.filename):
def _ftype(mode): """ Given a "mode" return the name of the type of file. """ if stat.S_ISREG(mode): return "file" if stat.S_ISDIR(mode): return "directory" if stat.S_ISLNK(mode): return "symlink" if stat.S_ISFIFO(mode): return "fifo" if stat.S_ISCHR(mode): return "character device" if stat.S_ISBLK(mode): return "block device" return "<unknown>"
my_st = os.lstat(fn)
my_st = os.lstat(pf.filename)
def _ftype(mode): """ Given a "mode" return the name of the type of file. """ if stat.S_ISREG(mode): return "file" if stat.S_ISDIR(mode): return "directory" if stat.S_ISLNK(mode): return "symlink" if stat.S_ISFIFO(mode): return "fifo" if stat.S_ISCHR(mode): return "character device" if stat.S_ISBLK(mode): return "block device" return "<unknown>"
if mode < 0: mode = (mode & 0xFFFF) ftype = _ftype(mode) my_ftype = _ftype(my_st.st_mode) if vflags & _RPMVERIFY_RDEV and ftype != my_ftype: prob = _PkgVerifyProb('type', 'file type does not match', ftypes) prob.database_value = ftype prob.disk_value = my_ftype problems.append(prob) if (ftype == "symlink" and my_ftype == "symlink" and vflags & _RPMVERIFY_LINKTO): fnl = fi.FLink() my_fnl = os.readlink(fn) if my_fnl != fnl:
my_ftype = YUMVerifyPackageFile._ftype(my_st.st_mode) verify_dev = False if (pf.verify_dev and (pf.ftype.endswith("device") or my_ftype.endswith("device"))): verify_dev = True if verify_dev: if pf.ftype != my_ftype: prob = _PkgVerifyProb('type','file type does not match', ftypes) prob.database_value = pf.ftype prob.disk_value = my_ftype problems.append(prob) elif (pf.dev & 0xFFFF) != (my_st.st_dev & 0xFFFF): prob =_PkgVerifyProb('type','dev does not match',ftypes) prob.database_value = hex(pf.dev & 0xffff) prob.disk_value = hex(my_st.st_dev & 0xffff) problems.append(prob) if pf.verify_readlink: my_fnl = '' if my_ftype == "symlink": my_fnl = os.readlink(pf.filename) if my_fnl != pf.readlink:
def _ftype(mode): """ Given a "mode" return the name of the type of file. """ if stat.S_ISREG(mode): return "file" if stat.S_ISDIR(mode): return "directory" if stat.S_ISLNK(mode): return "symlink" if stat.S_ISFIFO(mode): return "fifo" if stat.S_ISCHR(mode): return "character device" if stat.S_ISBLK(mode): return "block device" return "<unknown>"
prob.database_value = fnl
prob.database_value = pf.readlink
def _ftype(mode): """ Given a "mode" return the name of the type of file. """ if stat.S_ISREG(mode): return "file" if stat.S_ISDIR(mode): return "directory" if stat.S_ISLNK(mode): return "symlink" if stat.S_ISFIFO(mode): return "fifo" if stat.S_ISCHR(mode): return "character device" if stat.S_ISBLK(mode): return "block device" return "<unknown>"
if my_ftype == "symlink" and ftype == "file":
if my_ftype == "symlink" and pf.ftype == "file":
def _ftype(mode): """ Given a "mode" return the name of the type of file. """ if stat.S_ISREG(mode): return "file" if stat.S_ISDIR(mode): return "directory" if stat.S_ISLNK(mode): return "symlink" if stat.S_ISFIFO(mode): return "fifo" if stat.S_ISCHR(mode): return "character device" if stat.S_ISBLK(mode): return "block device" return "<unknown>"
my_st_size = os.stat(fn).st_size
my_st_size = os.stat(pf.filename).st_size
def _ftype(mode): """ Given a "mode" return the name of the type of file. """ if stat.S_ISREG(mode): return "file" if stat.S_ISDIR(mode): return "directory" if stat.S_ISLNK(mode): return "symlink" if stat.S_ISFIFO(mode): return "fifo" if stat.S_ISCHR(mode): return "character device" if stat.S_ISBLK(mode): return "block device" return "<unknown>"
if (check_content and vflags & _RPMVERIFY_MTIME and int(my_st.st_mtime) != int(mtime)):
if (check_content and pf.verify_mtime and int(my_st.st_mtime) != int(pf.mtime)):
def _ftype(mode): """ Given a "mode" return the name of the type of file. """ if stat.S_ISREG(mode): return "file" if stat.S_ISDIR(mode): return "directory" if stat.S_ISLNK(mode): return "symlink" if stat.S_ISFIFO(mode): return "fifo" if stat.S_ISCHR(mode): return "character device" if stat.S_ISBLK(mode): return "block device" return "<unknown>"
prob.database_value = mtime
prob.database_value = pf.mtime
def _ftype(mode): """ Given a "mode" return the name of the type of file. """ if stat.S_ISREG(mode): return "file" if stat.S_ISDIR(mode): return "directory" if stat.S_ISLNK(mode): return "symlink" if stat.S_ISFIFO(mode): return "fifo" if stat.S_ISCHR(mode): return "character device" if stat.S_ISBLK(mode): return "block device" return "<unknown>"
if check_perms and vflags & _RPMVERIFY_USER and my_user != user:
if check_perms and pf.verify_user and my_user != pf.user:
def _ftype(mode): """ Given a "mode" return the name of the type of file. """ if stat.S_ISREG(mode): return "file" if stat.S_ISDIR(mode): return "directory" if stat.S_ISLNK(mode): return "symlink" if stat.S_ISFIFO(mode): return "fifo" if stat.S_ISCHR(mode): return "character device" if stat.S_ISBLK(mode): return "block device" return "<unknown>"
prob.database_value = user
prob.database_value = pf.user
def _ftype(mode): """ Given a "mode" return the name of the type of file. """ if stat.S_ISREG(mode): return "file" if stat.S_ISDIR(mode): return "directory" if stat.S_ISLNK(mode): return "symlink" if stat.S_ISFIFO(mode): return "fifo" if stat.S_ISCHR(mode): return "character device" if stat.S_ISBLK(mode): return "block device" return "<unknown>"
if (check_perms and vflags & _RPMVERIFY_GROUP and my_group != group):
if check_perms and pf.verify_group and my_group != pf.group:
def _ftype(mode): """ Given a "mode" return the name of the type of file. """ if stat.S_ISREG(mode): return "file" if stat.S_ISDIR(mode): return "directory" if stat.S_ISLNK(mode): return "symlink" if stat.S_ISFIFO(mode): return "fifo" if stat.S_ISCHR(mode): return "character device" if stat.S_ISBLK(mode): return "block device" return "<unknown>"
prob.database_value = group
prob.database_value = pf.group
def _ftype(mode): """ Given a "mode" return the name of the type of file. """ if stat.S_ISREG(mode): return "file" if stat.S_ISDIR(mode): return "directory" if stat.S_ISLNK(mode): return "symlink" if stat.S_ISFIFO(mode): return "fifo" if stat.S_ISCHR(mode): return "character device" if stat.S_ISBLK(mode): return "block device" return "<unknown>"
if check_perms and vflags & _RPMVERIFY_MODE and my_mode != mode:
if check_perms and pf.verify_mode and my_mode != pf.mode:
def _ftype(mode): """ Given a "mode" return the name of the type of file. """ if stat.S_ISREG(mode): return "file" if stat.S_ISDIR(mode): return "directory" if stat.S_ISLNK(mode): return "symlink" if stat.S_ISFIFO(mode): return "fifo" if stat.S_ISCHR(mode): return "character device" if stat.S_ISBLK(mode): return "block device" return "<unknown>"
prob.database_value = mode
prob.database_value = pf.mode
def _ftype(mode): """ Given a "mode" return the name of the type of file. """ if stat.S_ISREG(mode): return "file" if stat.S_ISDIR(mode): return "directory" if stat.S_ISLNK(mode): return "symlink" if stat.S_ISFIFO(mode): return "fifo" if stat.S_ISCHR(mode): return "character device" if stat.S_ISBLK(mode): return "block device" return "<unknown>"
if fast and not problems and (my_st_size == size): vflags &= ~_RPMVERIFY_DIGEST
verify_digest = pf.verify_digest if fast and not problems and (my_st_size == pf.size): verify_digest = False if not pf.digest: verify_digest = False
def _ftype(mode): """ Given a "mode" return the name of the type of file. """ if stat.S_ISREG(mode): return "file" if stat.S_ISDIR(mode): return "directory" if stat.S_ISLNK(mode): return "symlink" if stat.S_ISFIFO(mode): return "fifo" if stat.S_ISCHR(mode): return "character device" if stat.S_ISBLK(mode): return "block device" return "<unknown>"
((have_prelink and (vflags & _RPMVERIFY_FILESIZE) and (my_st_size != size)) or (csum and vflags & _RPMVERIFY_DIGEST))):
(verify_digest or (pf.verify_size and have_prelink and my_st_size != pf.size))): if pf.digest: digest_type = pf.digest[0] csum = pf.digest[0] + ':' + pf.digest[1] else: digest_type = csum_type csum = ''
def _ftype(mode): """ Given a "mode" return the name of the type of file. """ if stat.S_ISREG(mode): return "file" if stat.S_ISDIR(mode): return "directory" if stat.S_ISLNK(mode): return "symlink" if stat.S_ISFIFO(mode): return "fifo" if stat.S_ISCHR(mode): return "character device" if stat.S_ISBLK(mode): return "block device" return "<unknown>"
my_csum = misc.checksum(csum_type, fn) gen_csum = True
my_csum = misc.checksum(digest_type, pf.filename) my_csum = digest_type + ':' + my_csum
def _ftype(mode): """ Given a "mode" return the name of the type of file. """ if stat.S_ISREG(mode): return "file" if stat.S_ISDIR(mode): return "directory" if stat.S_ISLNK(mode): return "symlink" if stat.S_ISFIFO(mode): return "fifo" if stat.S_ISCHR(mode): return "character device" if stat.S_ISBLK(mode): return "block device" return "<unknown>"
gen_csum = False if csum and vflags & _RPMVERIFY_DIGEST and not gen_csum:
my_csum = None if pf.verify_digest and my_csum is None:
def _ftype(mode): """ Given a "mode" return the name of the type of file. """ if stat.S_ISREG(mode): return "file" if stat.S_ISDIR(mode): return "directory" if stat.S_ISLNK(mode): return "symlink" if stat.S_ISFIFO(mode): return "fifo" if stat.S_ISCHR(mode): return "character device" if stat.S_ISBLK(mode): return "block device" return "<unknown>"
if gen_csum and my_csum != csum and have_prelink:
if my_csum != csum and have_prelink:
def _ftype(mode): """ Given a "mode" return the name of the type of file. """ if stat.S_ISREG(mode): return "file" if stat.S_ISDIR(mode): return "directory" if stat.S_ISLNK(mode): return "symlink" if stat.S_ISFIFO(mode): return "fifo" if stat.S_ISCHR(mode): return "character device" if stat.S_ISBLK(mode): return "block device" return "<unknown>"
p = Popen([prelink_cmd, "-y", fn],
p = Popen([prelink_cmd, "-y", pf.filename],
def _ftype(mode): """ Given a "mode" return the name of the type of file. """ if stat.S_ISREG(mode): return "file" if stat.S_ISDIR(mode): return "directory" if stat.S_ISLNK(mode): return "symlink" if stat.S_ISFIFO(mode): return "fifo" if stat.S_ISCHR(mode): return "character device" if stat.S_ISBLK(mode): return "block device" return "<unknown>"
tcsum = misc.checksum(csum_type, fp)
tcsum = misc.checksum(digest_type, fp)
def _ftype(mode): """ Given a "mode" return the name of the type of file. """ if stat.S_ISREG(mode): return "file" if stat.S_ISDIR(mode): return "directory" if stat.S_ISLNK(mode): return "symlink" if stat.S_ISFIFO(mode): return "fifo" if stat.S_ISCHR(mode): return "character device" if stat.S_ISBLK(mode): return "block device" return "<unknown>"
if (csum and vflags & _RPMVERIFY_DIGEST and gen_csum and my_csum != csum):
if pf.verify_digest and my_csum != csum:
def _ftype(mode): """ Given a "mode" return the name of the type of file. """ if stat.S_ISREG(mode): return "file" if stat.S_ISDIR(mode): return "directory" if stat.S_ISLNK(mode): return "symlink" if stat.S_ISFIFO(mode): return "fifo" if stat.S_ISCHR(mode): return "character device" if stat.S_ISBLK(mode): return "block device" return "<unknown>"
if (check_content and vflags & _RPMVERIFY_FILESIZE and my_st_size != size):
if check_content and pf.verify_size and my_st_size != pf.size:
def _ftype(mode): """ Given a "mode" return the name of the type of file. """ if stat.S_ISREG(mode): return "file" if stat.S_ISDIR(mode): return "directory" if stat.S_ISLNK(mode): return "symlink" if stat.S_ISFIFO(mode): return "fifo" if stat.S_ISCHR(mode): return "character device" if stat.S_ISBLK(mode): return "block device" return "<unknown>"
prob.database_value = size
prob.database_value = pf.size
def _ftype(mode): """ Given a "mode" return the name of the type of file. """ if stat.S_ISREG(mode): return "file" if stat.S_ISDIR(mode): return "directory" if stat.S_ISLNK(mode): return "symlink" if stat.S_ISFIFO(mode): return "fifo" if stat.S_ISCHR(mode): return "character device" if stat.S_ISBLK(mode): return "block device" return "<unknown>"
os.stat(fn)
os.stat(pf.filename)
def _ftype(mode): """ Given a "mode" return the name of the type of file. """ if stat.S_ISREG(mode): return "file" if stat.S_ISDIR(mode): return "directory" if stat.S_ISLNK(mode): return "symlink" if stat.S_ISFIFO(mode): return "fifo" if stat.S_ISCHR(mode): return "character device" if stat.S_ISBLK(mode): return "block device" return "<unknown>"
results[fn] = problems
results[pf.filename] = problems
def _ftype(mode): """ Given a "mode" return the name of the type of file. """ if stat.S_ISREG(mode): return "file" if stat.S_ISDIR(mode): return "directory" if stat.S_ISLNK(mode): return "symlink" if stat.S_ISFIFO(mode): return "fifo" if stat.S_ISCHR(mode): return "character device" if stat.S_ISBLK(mode): return "block device" return "<unknown>"