diff options
author | Arun Raghavan <ford_prefect@gentoo.org> | 2009-01-10 23:13:49 +0530 |
---|---|---|
committer | Arun Raghavan <ford_prefect@gentoo.org> | 2009-01-10 23:13:49 +0530 |
commit | cd2ce78a3583fd9673905e9d9ba503483cec0f8b (patch) | |
tree | 9d41fbcb9c4769fd1d0a20dac9c6778bc92af5d6 /check.py | |
parent | Switch gentoo-portage checking to PortageCheck (diff) | |
download | gard-cd2ce78a3583fd9673905e9d9ba503483cec0f8b.tar.gz gard-cd2ce78a3583fd9673905e9d9ba503483cec0f8b.tar.bz2 gard-cd2ce78a3583fd9673905e9d9ba503483cec0f8b.zip |
Add rsync URL support to DistfilesCheck, and some minor changes
Diffstat (limited to 'check.py')
-rw-r--r-- | check.py | 27 |
1 files changed, 17 insertions, 10 deletions
@@ -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 |