summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Raghavan <ford_prefect@gentoo.org>2009-01-10 23:13:49 +0530
committerArun Raghavan <ford_prefect@gentoo.org>2009-01-10 23:13:49 +0530
commitcd2ce78a3583fd9673905e9d9ba503483cec0f8b (patch)
tree9d41fbcb9c4769fd1d0a20dac9c6778bc92af5d6
parentSwitch gentoo-portage checking to PortageCheck (diff)
downloadgard-cd2ce78a3583fd9673905e9d9ba503483cec0f8b.tar.gz
gard-cd2ce78a3583fd9673905e9d9ba503483cec0f8b.tar.bz2
gard-cd2ce78a3583fd9673905e9d9ba503483cec0f8b.zip
Add rsync URL support to DistfilesCheck, and some minor changes
-rw-r--r--check.py27
-rwxr-xr-xgard-v2.py45
2 files changed, 28 insertions, 44 deletions
diff --git a/check.py b/check.py
index 3695f91..4ec769a 100644
--- a/check.py
+++ b/check.py
@@ -39,16 +39,21 @@ class GardCheck:
return ret
# Gets a file over rsync and puts it in a temporary directory,
- # if specified
+ # if specified (assumes URL is the form rsync://server/module
+ # and takes path relative to this)
def get_file_rsync(self, path, dir='.'):
- target = '%s::%s' % (self.url, path)
-
+ urlp = urlparse.urlparse(self.url)
+ if len(urlp.path) > 1:
+ # strip leading '/' from URL path
+ path = urlp.path[1:] + '/' + path
+ target = '%s::%s' % (urlp.netloc, path)
retcode = subprocess.call(['rsync', '-aqP', '--no-motd',
'--contimeout=30', target, dir])
if retcode > 0:
- logging.error('return value of rsync during \
- gentoo-portage check was ' + str(retcode))
- return None
+ logging.error('rsync returned %d during gentoo-portage check' % retcode)
+ return False
+
+ return True
# Takes the URL to a timestamp.{chk|x} file and returns the
# corresponding time stamp in seconds
@@ -117,12 +122,12 @@ class DistfilesCheck(GardCheck):
if scheme == 'http' or scheme == 'ftp':
path = '/distfiles/timestamp.chk'
lag = self.get_lag(self.url + path)
- else:
- # XXX: to be tested!
+ elif scheme == 'rsync':
file = 'timestamp.x'
path = 'distfiles/' + file
- self.get_file_rsync(path)
+ if self.get_file_rsync(path) is False:
+ return None
url = 'file://%s/%s' % (os.path.abspath(''), file)
lag = self.get_lag(url)
@@ -164,11 +169,13 @@ class ReleasesCheck(GardCheck):
return ret
class PortageCheck(GardCheck):
+ # Takes a URL in rsync://host/module/path form
def lag(self):
file = 'timestamp.chk'
path = 'gentoo-portage/metadata/' + file
- self.get_file_rsync(path)
+ if self.get_file_rsync(path) is False:
+ return None
# This is Linux-specific, but who's going to run this on
# Windows anyway? :D
diff --git a/gard-v2.py b/gard-v2.py
index a811cd3..647501c 100755
--- a/gard-v2.py
+++ b/gard-v2.py
@@ -17,7 +17,7 @@ import urllib2
import check
-rmaxlag=45
+rmaxlag = 45 * 60
dmaxlag = 5.5 * 3600
relmaxlag = 2 * 3600
@@ -89,7 +89,12 @@ for line in file:
handler = add_handler(fname)
info4=grsync+" wants to be a gentoo-portage mirror and is being checked as per Bug #"+bugnum
logging.info(info4)
+ addy = 'rsync://%s/' % addy
check.PortageCheck(addy).check(rmaxlag)
+
+ bugurl1 = "Bug URL : https://bugs.gentoo.org/"+bugnum+" , "+duedate
+ logging.info(bugurl1)
+
# New line for the prettiness
logging.info('')
remove_handler(handler)
@@ -154,43 +159,15 @@ for line in file:
else:
os.makedirs(reportpath)
add_handler(fname)
+
info7 = addy+" wants to be an source mirror and is being checked as per Bug #"+bugnum+ " over rsync"
logging.info(info7)
- target=drsync+"/distfiles/timestamp.x"
- retcode4=subprocess.call(['rsync','-aqP','--no-motd','--contimeout=30',target,'.'])
- lag=False
- ots='Unknown'
- if retcode4 > 0:
- logging.error("return value of rsync during distfiles check was "+str(retcode4))
- else:
- temp=open('timestamp.x','r')
- ots=temp.readline()
- temp.close()
- os.unlink('timestamp.x')
- try:
- t1=ots.split()[0]
- lag=(time.time()-t1)/(60*60)
- except:
- t1=False
- lag=False
-
- # Unique line first
- if t1 is False or lag is False:
- error7 = "Mirror is not reachable or has a corrupt timestamp."
- logging.error(error7)
- elif lag > dmaxlag:
- error7 = "Mirror is lagging by over %.1f hours, difference is : %.2f hours" % (dmaxlag, lag)
- logging.error(error7)
- else:
- info7 = addy+" is in sync, current lag : %.2f hours" % (lag)
- logging.info(info7)
-
+
+ addy = 'rsync://%s/' % addy
+ check.DistfilesCheck(addy).check(dmaxlag)
+
# Now common lines
- tstamp7 = "Timestamp on Mirror : "+str(ots).strip()
- curtime7= "Current time in UTC : "+str(time.strftime("%s %a, %d %b %Y %H:%M:%S +0000", time.gmtime()))
bugurl7 = "Bug URL : https://bugs.gentoo.org/"+bugnum+" , "+duedate
- logging.info(tstamp7)
- logging.info(curtime7)
logging.info(bugurl7)
# New line for the prettiness