kadischi/lib functions.py,1.1.1.1,1.2

Darko Ilic (darko) fedora-extras-commits at redhat.com
Sun Aug 28 10:20:19 UTC 2005


Author: darko

Update of /cvs/devel/kadischi/lib
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv18342/lib

Modified Files:
	functions.py 
Log Message:
repository verification, buildstamp manipulation, UI mode selection, minor bugfixes


Index: functions.py
===================================================================
RCS file: /cvs/devel/kadischi/lib/functions.py,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- functions.py	21 Aug 2005 17:08:47 -0000	1.1.1.1
+++ functions.py	28 Aug 2005 10:20:17 -0000	1.2
@@ -4,6 +4,7 @@
 import sys
 import shvar
 import rpm
+import urlgrabber.grabber as grabber
 
 def normalize_path (parts, rootpath = None):
 	if rootpath == None:
@@ -12,7 +13,30 @@
 	for part in parts:
 		path = '/'.join([path, part])
 	return os.path.normpath (path)
-	
+
+def path_exists (path, quiet = False):
+	if os.path.exists (path):
+		if not quiet:
+			flc_log ('Path %s exists. OK' % path)
+		return True
+	else:
+		if not quiet:
+			flc_log ('Error - path %s doesn`t exist.' % path)
+		return False
+
+def url_exists (url, quiet = False):
+	try:
+		u = grabber.urlopen (url, retry = 5)
+		if not quiet:
+			flc_log ('URL %s contacted. OK' % url)
+		u.close ()
+		return True
+	except grabber.URLGrabError, e:
+		if not quiet:
+			flc_log ("An error occurred contacting %s." % url)
+			flc_log ("URLGrabError:\n %s" % e.strerror)
+		return False
+
 def clear_rpm_db_files (rootdir):
 	"""Removes rpm database files in the destination if they exist"""
 	def rmpath (p):
@@ -69,9 +93,17 @@
 
 def flc_log (msg):
 	sys.stdout.write (msg + '\n')
-	
+
 def cleanup (builddir):
 	os.system ("umount %s 2>/dev/null" % normalize_path(['/system/proc'],builddir))
+	if os.path.exists (normalize_path([builddir,'product'])):
+		clean_directory ('/tmp/product')
+		shutil.move (normalize_path([builddir,'product']), '/tmp/product')
+	elif os.path.exists (normalize_path([builddir,'.buildstamp'])):
+		os.unlink ('/tmp/product/.buildstamp')
+		shutil.move (normalize_path([builddir,'.buildstamp']), '/tmp/product/.buildstamp')
+	else:
+		os.unlink ('/tmp/product/.buildstamp')
 	clean_directory (builddir)
 	
 def run (command, builddir = None):




More information about the scm-commits mailing list