pld-builder.new: PLD_Builder/util.py Use internal python uuid module if ava...
arekm
arekm at pld-linux.org
Sun Jun 22 14:20:48 CEST 2008
Author: arekm Date: Sun Jun 22 12:20:48 2008 GMT
Module: pld-builder.new Tag: HEAD
---- Log message:
Use internal python uuid module if available. Fallback to external uuidgen binary.
---- Files affected:
pld-builder.new/PLD_Builder:
util.py (1.6 -> 1.7)
---- Diffs:
================================================================
Index: pld-builder.new/PLD_Builder/util.py
diff -u pld-builder.new/PLD_Builder/util.py:1.6 pld-builder.new/PLD_Builder/util.py:1.7
--- pld-builder.new/PLD_Builder/util.py:1.6 Thu Dec 9 19:09:06 2004
+++ pld-builder.new/PLD_Builder/util.py Sun Jun 22 14:20:43 2008
@@ -6,6 +6,25 @@
import log
import string
+def uuid_python():
+ return uuid.uuid4()
+
+def uuid_external():
+ f = os.popen("uuidgen 2>&1")
+ u = string.strip(f.read())
+ f.close()
+ if len(u) != 36:
+ raise "uuid: fatal, cannot generate uuid: %s" % u
+ return u
+
+# uuid module available in python >= 2.5
+try:
+ import uuid
+except ImportError:
+ uuid = uuid_external
+else:
+ uuid = uuid_python
+
def pkg_name(nvr):
return re.match(r"(.+)-[^-]+-[^-]+", nvr).group(1)
@@ -29,14 +48,6 @@
def clean_tmp(dir):
# FIXME: use python
os.system("rm -f %s/* 2>/dev/null; rmdir %s 2>/dev/null" % (dir, dir))
-
-def uuid():
- f = os.popen("uuidgen 2>&1")
- u = string.strip(f.read())
- f.close()
- if len(u) != 36:
- raise "uuid: fatal, cannot generate uuid: %s" % u
- return u
def collect_files(log):
f = open(log)
================================================================
---- CVS-web:
http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/pld-builder.new/PLD_Builder/util.py?r1=1.6&r2=1.7&f=u
More information about the pld-cvs-commit
mailing list