Author: poeml Date: Fri May 7 00:39:41 2010 New Revision: 8063 URL: http://svn.mirrorbrain.org/viewvc/mirrorbrain?rev=8063&view=rev Log: mb: - pass zsync_hashes parameter to the hashing functions, if configured - catch interruptions by Ctrl-C and various signals Modified: trunk/mb/mb.py Modified: trunk/mb/mb.py URL: http://svn.mirrorbrain.org/viewvc/mirrorbrain/trunk/mb/mb.py?rev=8063&r1=8062&r2=8063&view=diff ============================================================================== --- trunk/mb/mb.py (original) +++ trunk/mb/mb.py Fri May 7 00:39:41 2010 _at_@ -12,7 +12,7 @@ (it is not in the Python CheeseShop so far) """ -__version__ = '2.12.0' +__version__ = '2.13.0' __author__ = 'Peter Poeml <poeml_at_cmdline.net>' __copyright__ = 'Novell / SUSE Linux Products GmbH' __license__ = 'GPL' _at_@ -22,21 +22,16 @@ import cmdln import mb.geoip - - - -# todo: - -# abstractions: -# - append a comment -# - with timestamp -# -# - select a server from the database - -# table changes; -# identifier MUST be unique (schema change required) -# baseurlFtp could be empty, no problem. -# baseurlHttp must not be empty +import mb.mberr +import signal + + +def catchterm(*args): + raise mb.mberr.SignalInterrupt + +for name in 'SIGBREAK', 'SIGHUP', 'SIGTERM': + num = getattr(signal, name, None) + if num: signal.signal(num, catchterm) _at_@ -388,7 +383,6 @@ """ from mb.asn import iplookup from mb.util import hostname_from_url - import mb.mberr from sqlobject.sqlbuilder import AND if opts.all: _at_@ -425,7 +419,7 @@ try: res = iplookup(self.conn, hostname) except mb.mberr.NameOrServiceNotKnown, e: - print '%s:' % mirror.identifier, e + print '%s:' % mirror.identifier, e.msg #print '%s: without DNS lookup, no further lookups are possible' % mirror.identifier continue _at_@ -1043,7 +1037,8 @@ hasheable = mb.hashes.Hasheable(src_basename, src_dir=src_dir, dst_dir=dst_dir, - base_dir=opts.base_dir) + base_dir=opts.base_dir, + do_zsync=self.config.dbconfig.get('zsync_hashes')) except OSError, e: if e.errno == errno.ENOENT: sys.stderr.write('File vanished: %r\n' % src) _at_@ -1591,5 +1586,27 @@ if __name__ == '__main__': import sys mirrordoctor = MirrorDoctor() - sys.exit( mirrordoctor.main() ) - + try: + r = mirrordoctor.main() + + except mb.mberr.SignalInterrupt: + print >>sys.stderr, 'killed!' + r = 1 + + except KeyboardInterrupt: + print >>sys.stderr, 'interrupted!' + r = 1 + + except mb.mberr.UserAbort: + print >>sys.stderr, 'aborted.' + r = 1 + + except (mb.mberr.ConfigError, + mb.mberr.NoConfigfile, + mb.mberr.MirrorNotFoundError, + mb.mberr.SocketError), e: + print >>sys.stderr, e.msg + r = 1 + + sys.exit(r) + _______________________________________________ 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 Thu May 06 2010 - 22:39:43 GMT
This archive was generated by hypermail 2.3.0 : Mon Feb 20 2012 - 23:47:04 GMT