diff --git a/src/mio/daemon_cage.py b/src/mio/daemon_cage.py index 50cded9347f2ecdd8249709867c14b81527b6e9a..bf5df16e4ed2abf303110438b4e5c90673c1cbf2 100755 --- a/src/mio/daemon_cage.py +++ b/src/mio/daemon_cage.py @@ -26,7 +26,7 @@ def system(command): if len(c) == 0: # Normal exit, subprocess has closed stdout break - sys.stdout.write(c) + os.write(sys.stdout.fileno(), c) sys.stdout.flush() elif p.poll() != None: # Child has exited, but stdout is still open diff --git a/src/mio/installer.py b/src/mio/installer.py index d2f6c47f71f146ee3c3f65ed3cd48b0bc6e54301..2af36c7792bdf0b3eee8de0229a5066c3d24c492 100755 --- a/src/mio/installer.py +++ b/src/mio/installer.py @@ -79,6 +79,7 @@ class Installer: elif node._tag == 'rpm': rpm = rpm_node(node.name[0], node, group) + if rpm in exclude: mio.log.log(CHATTY, "excluding rpm '%s'" % node.name[0]) diff --git a/src/mio/node.py b/src/mio/node.py index eaacc59e4c7b0e31d000c8d1bde4af9d64d8401c..30f8eeedf5a63e020c231dbcdee502024e1bbb13 100755 --- a/src/mio/node.py +++ b/src/mio/node.py @@ -8,6 +8,7 @@ import os import hashlib import shutil import tempfile +from functools import total_ordering from mio.exception import * from mio.log import log, declaration, SILENT, NORMAL, VERBOSE, DEBUG @@ -20,7 +21,8 @@ def parse_boolean(value): if value.upper() == 'NO' or value.upper() == 'FALSE': return False raise Exception("yes, no, true or false expected (not '%s')" % value) - + +@total_ordering class target_node: def __init__(self, kind, name, decl, group): assert name != None @@ -31,21 +33,19 @@ class target_node: self.is_installed = False self.is_tested = False self.is_trigged = None + + def __repr__(self): + return "%s(%s)" % (self.kind, self.name) - def __cmp__(self, other): - result = 0 - if self.kind == other.kind: - if self.name < other.name: - result = -1 - elif self.name == other.name: - result = 0 - else: - result = -1 - elif self.kind < other.kind: - result = -1 - else: - result = 1 - return result + def __eq__(self, other): + return self.kind == other.kind and self.name == other.name + + def __ne__(self, other): + return not self.__eq__(other) + + def __lt__(self, other): + return (self.kind < other.kind or + self.kind == other.kind and self.name < other.name) def __hash__(self): return self.name.__hash__() @@ -86,7 +86,7 @@ class group_node(target_node): self.post = [] def assert_identical(self, other): - if self.__cmp__(other) != 0: + if self != other: raise Exception("%s %s" % (self.name, other.name)) if self.target != other.target: raise TargetException(self, other) @@ -179,7 +179,7 @@ class dir_node(target_node): self.delete = parse_boolean(self.decl.delete[0]) def assert_identical(self, other): - if self.__cmp__(other) != 0: + if self != other: raise Exception("%s %s" % (self.name, other.name)) if self.mode != other.mode: raise ModeException(self, other) @@ -267,7 +267,7 @@ class file_node(target_node): self.touch = parse_boolean(self.decl.touch_when_copied[0]) def assert_identical(self, other): - if self.__cmp__(other) != 0: + if self != other: raise Exception("%s %s" % (self.name, other.name)) if self.mode != other.mode: raise ModeException(self, other) @@ -283,7 +283,7 @@ class file_node(target_node): raise DeleteException(self, other) def digest(self, name): - f = open(name) + f = open(name, 'rb') digest = hashlib.sha1(f.read()).hexdigest() f.close() return digest @@ -431,7 +431,7 @@ class symlink_node(target_node): self.delete = parse_boolean(self.decl.delete[0]) def assert_identical(self, other): - if self.__cmp__(other) != 0: + if self != other: raise Exception("%s %s" % (self.name, other.name)) if not self.delete and (self.decl.value[0] == None or self.decl.value[0] != other.decl.value[0]): diff --git a/src/mio/rpmDB.py b/src/mio/rpmDB.py index 07ef123fcd730e56d4d9f84eec8327f7a2ff1d7f..95bc885694d27bfb0eac6e4bf8914ab57cbfa28d 100755 --- a/src/mio/rpmDB.py +++ b/src/mio/rpmDB.py @@ -38,28 +38,32 @@ class VersionDB: read_ts = initReadOnlyTransaction() for e in read_ts.dbMatch(): (name, arch, version, release) = ( - e[rpm.RPMTAG_NAME], e[rpm.RPMTAG_ARCH], - e[rpm.RPMTAG_VERSION], e[rpm.RPMTAG_RELEASE]) + e[rpm.RPMTAG_NAME].decode('utf-8'), + e[rpm.RPMTAG_ARCH].decode('utf-8'), + e[rpm.RPMTAG_VERSION].decode('utf-8'), + e[rpm.RPMTAG_RELEASE].decode('utf-8')) if not name in self.rpm: self.rpm[name] = [] pass self.rpm[name].append(RPM(name, arch, version, release)) del read_ts except: + raise pass pass def __getitem__(self, name): - try: - if name in self.rpm: - return self.rpm[name] + if name in self.rpm: + return self.rpm[name] + if name.rfind('.') >= 0: name, arch = name.rsplit('.', 1) - for r in self.rpm[name]: - if arch == r.arch: - return [r] + if name in self.rpm: + for r in self.rpm[name]: + if arch == r.arch: + return [r] + pass pass - return None - except: - return None - pass + pass + return None + pass