extras-repoclosure rc-run.py,1.2,1.3
Michael Schwendt (mschwendt)
fedora-extras-commits at redhat.com
Wed May 17 13:41:14 UTC 2006
Author: mschwendt
Update of /cvs/fedora/extras-repoclosure
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv22698
Modified Files:
rc-run.py
Log Message:
make it possible that one job interrupts a running job gracefully
Index: rc-run.py
===================================================================
RCS file: /cvs/fedora/extras-repoclosure/rc-run.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- rc-run.py 13 May 2006 00:13:40 -0000 1.2
+++ rc-run.py 17 May 2006 13:41:11 -0000 1.3
@@ -7,6 +7,9 @@
import datetime, time
import tempfile
+workdir = '/srv/rpmbuild/extras-repoclosure'
+breakfile = 'rc-run.breakfile'
+
allreleases = [ '3', '4', '5', 'development' ]
archs = { '3' : ['i386','x86_64'],
@@ -75,24 +78,43 @@
return conffile
+def checkbreakfile():
+ # If the breakfile exists, we terminate prematurely, so another job
+ # can take over (= clumsy restart without killing metadata processing).
+ f = os.path.join(workdir,breakfile)
+ if not os.path.exists(f):
+ return
+ try:
+ os.remove(f)
+ except:
+ print 'ERROR: Removing breakfile %s failed!' % f
+ pass
+ sys.exit(1)
+
+
def makereport():
try:
os.remove(logfilename)
except:
pass
for arch in archs[release]:
+ print '%s (%s)' % (release,arch)
rcargs = ('-a %s ' % targetarchs[arch])
for r in repos[release]:
repoid = '%s-%s-%s' % (r,release,arch)
rcargs += ('-r %s ' % repoid)
# -n, --newest : yum-utils 0.5
rc = os.system('./rc-modified -q -n -c %s %s >> %s' % (conffile,rcargs,logfilename))
+ checkbreakfile()
if rc:
return False
return True
# Main.
+cwd = os.getcwd()
+os.chdir(workdir)
+
# Delete old log files.
import glob
now = time.time()
@@ -106,12 +128,16 @@
today = datetime.date.today()
releases = []
-f = open('rc-run.lockfile','w')
+lockfilename = 'rc-run.lockfile'
+f = open(lockfilename,'w')
try:
- rc = fcntl.flock(f, fcntl.LOCK_EX | fcntl.LOCK_NB)
+ print "Trying to acquire lock file:",
+ sys.stdout.flush()
+ rc = fcntl.flock(f, fcntl.LOCK_EX)
f.write( ('%s' % today) )
-except IOError:
- print 'ERROR: script locked via lockfile - it seems to be running already'
+ print "OK"
+except IOError (errno, strerr):
+ print 'ERROR: %s: %s' % (strerr,lockfilename)
sys.exit(11)
if sys.argv[0].endswith('rc-run-all.py'): # process all releases
@@ -149,4 +175,5 @@
fcntl.flock(f, fcntl.LOCK_UN)
f.close()
+os.chdir(cwd)
sys.exit(0)
More information about the scm-commits
mailing list