Author: poeml Date: Wed Feb 10 05:29:50 2010 New Revision: 7953 URL: http://svn.mirrorbrain.org/viewvc/mirrorbrain?rev=7953&view=rev Log: mb scan: - If rsync 3.0.0 or newer is available, we can try harder to avoid infinite hangs by using the --contimeout option in addition to --timeout. Issue #12. Modified: trunk/mirrordoctor/mb/testmirror.py trunk/mirrordoctor/mb/util.py Modified: trunk/mirrordoctor/mb/testmirror.py URL: http://svn.mirrorbrain.org/viewvc/mirrorbrain/trunk/mirrordoctor/mb/testmirror.py?rev=7953&r1=7952&r2=7953&view=diff ============================================================================== --- trunk/mirrordoctor/mb/testmirror.py (original) +++ trunk/mirrordoctor/mb/testmirror.py Wed Feb 10 05:29:50 2010 @@ -103,9 +103,16 @@ # presumably runs a really old rsync server. The system seems to be # SuSE Linux 8.2.) # poeml, Mon Jun 22 18:10:33 CEST 2009 - cmd = 'rsync -d --timeout=%d %s %s/' % (TIMEOUT, S.probeurl, tmpdir) + cmd = ['rsync -d'] + if mb.util.get_rsync_version().startswith('3.'): + cmd.append('--contimeout=%s' % TIMEOUT) + cmd.append('--timeout=%d %s %s/' % (TIMEOUT, S.probeurl, tmpdir)) + if not S.get_content: - cmd += ' --list-only' + cmd.append('--list-only') + + cmd = ' '.join(cmd) + (rc, out) = commands.getstatusoutput(cmd) targetfile = os.path.join(tmpdir, os.path.basename(S.filename)) if rc == 0 or os.path.exists(targetfile): Modified: trunk/mirrordoctor/mb/util.py URL: http://svn.mirrorbrain.org/viewvc/mirrorbrain/trunk/mirrordoctor/mb/util.py?rev=7953&r1=7952&r2=7953&view=diff ============================================================================== --- trunk/mirrordoctor/mb/util.py (original) +++ trunk/mirrordoctor/mb/util.py Wed Feb 10 05:29:50 2010 @@ -2,6 +2,7 @@ import time t_start = 0 +rsync_version = None class Afile: @@ -151,6 +152,24 @@ pass +def get_rsync_version(): + """call the rsync program and get to know its version number. Save the + result in a global, and returned only the "cached" result in subsequent + calls.""" + + global rsync_version + + if rsync_version: + return rsync_version + else: + import commands + status, output = commands.getstatusoutput('rsync --version') + if status != 0: + sys.exit('rsync command not found') + rsync_version = output.splitlines()[0].split()[2] + return rsync_version + + def timer_start(): global t_start t_start = time.time() _______________________________________________ mirrorbrain-commits mailing list Archive: http://mirrorbrain.org/archive/mirrorbrain-commits/ Note: To remove yourself from this list, send a mail with the content unsubscribe to the address mirrorbrain-commits-request_at_mirrorbrain.orgReceived on Wed Feb 10 2010 - 04:29:54 GMT
This archive was generated by hypermail 2.2.0 : Wed Feb 10 2010 - 04:32:10 GMT