1 # vi: encoding=utf-8 ts=8 sts=4 sw=4 et
10 return str(uuid_random())
13 f = os.popen("uuidgen 2>&1")
17 raise Exception("uuid: fatal, cannot generate uuid: %s" % u)
20 # uuid module available in python >= 2.5
22 from uuid import uuid4 as uuid_random
29 return re.match(r"(.+)-[^-]+-[^-]+", nvr).group(1)
34 def sendfile(src, dst):
43 def append_to(log, msg):
50 os.system("rm -f %s/* 2>/dev/null; rmdir %s 2>/dev/null" % (dir, dir))
52 def collect_files(log, basedir = "/home"):
54 rx = re.compile(r"^Wrote: (%s.*\.rpm)$" % basedir)
55 proc = re.compile(r"^Processing files:.*$")
57 for l in reversed(list(f)):
62 files.append(m.group(1))
66 def find_last_section(log):
68 rx1 = re.compile(r"^Executing\(%(\w+)\).*$")
69 rx2 = re.compile(r"^Processing (files):.*$")
76 last_section = m.group(1)
80 def cmp_to_key(mycmp):
81 'Convert a cmp= function into a key= function'
83 def __init__(self, obj, *args):
85 def __lt__(self, other):
86 return mycmp(self.obj, other.obj) < 0
87 def __gt__(self, other):
88 return mycmp(self.obj, other.obj) > 0
89 def __eq__(self, other):
90 return mycmp(self.obj, other.obj) == 0
91 def __le__(self, other):
92 return mycmp(self.obj, other.obj) <= 0
93 def __ge__(self, other):
94 return mycmp(self.obj, other.obj) >= 0
95 def __ne__(self, other):
96 return mycmp(self.obj, other.obj) != 0