10637.3.1
by Guilherme Salgado
Use the default python version instead of a hard-coded version |
1 |
#!/usr/bin/python -S
|
8687.15.7
by Karl Fogel
Add the copyright header block to more files. |
2 |
#
|
3 |
# Copyright 2009 Canonical Ltd. This software is licensed under the
|
|
4 |
# GNU Affero General Public License version 3 (see the file LICENSE).
|
|
5 |
||
4935.3.7
by Curtis Hovey
Added bad name suppression to cronscripts. |
6 |
# pylint: disable-msg=C0103,W0403
|
2770.1.56
by Guilherme Salgado
Cleanup loads of code, improved some tests and got all of them to work. |
7 |
|
4898.2.26
by Jonathan Lange
Refactor server-side protocol to be more generic. Restore '_pythonpath' import |
8 |
import _pythonpath |
2770.1.56
by Guilherme Salgado
Cleanup loads of code, improved some tests and got all of them to work. |
9 |
from optparse import OptionParser |
10 |
||
4898.2.49
by Jonathan Lange
Make the scripts pass on errors more reliably and fix a bunch of them. |
11 |
from twisted.internet import defer, reactor |
6108.1.1
by Michael Hudson
the fix :( |
12 |
from twisted.python import log as tplog |
4898.2.7
by Jonathan Lange
Mirror multiple branches in subprocesses, limited by a semaphore |
13 |
|
6971.2.1
by Jonathan Lange
Get rid of BranchStatusClient. This should avoid the attribute error we |
14 |
from canonical.config import config |
6034.1.5
by Michael Hudson
progress? |
15 |
from canonical.launchpad.scripts import logger_options |
10548.1.1
by Jonathan Lange
Move twistedsupport to lp.services |
16 |
from lp.codehosting.puller import mirror, scheduler |
17 |
from lp.services.twistedsupport.loggingsupport import ( |
|
9587.1.2
by Michael Hudson
blat |
18 |
LoggingProxy, set_up_logging_for_script) |
2770.1.56
by Guilherme Salgado
Cleanup loads of code, improved some tests and got all of them to work. |
19 |
|
4898.2.49
by Jonathan Lange
Make the scripts pass on errors more reliably and fix a bunch of them. |
20 |
def clean_shutdown(ignored): |
21 |
reactor.stop() |
|
22 |
||
23 |
||
24 |
def shutdown_with_errors(failure): |
|
6108.1.1
by Michael Hudson
the fix :( |
25 |
tplog.err(failure) |
4898.2.49
by Jonathan Lange
Make the scripts pass on errors more reliably and fix a bunch of them. |
26 |
failure.printTraceback() |
27 |
reactor.stop() |
|
28 |
||
29 |
||
4898.2.7
by Jonathan Lange
Mirror multiple branches in subprocesses, limited by a semaphore |
30 |
def run_mirror(log, manager): |
4898.2.49
by Jonathan Lange
Make the scripts pass on errors more reliably and fix a bunch of them. |
31 |
# It's conceivable that mirror() might raise an exception before it
|
32 |
# returns a Deferred -- maybeDeferred means we don't have to worry.
|
|
33 |
deferred = defer.maybeDeferred(mirror, log, manager) |
|
34 |
deferred.addCallback(clean_shutdown) |
|
35 |
deferred.addErrback(shutdown_with_errors) |
|
4898.2.7
by Jonathan Lange
Mirror multiple branches in subprocesses, limited by a semaphore |
36 |
|
37 |
||
2770.1.56
by Guilherme Salgado
Cleanup loads of code, improved some tests and got all of them to work. |
38 |
if __name__ == '__main__': |
39 |
parser = OptionParser() |
|
40 |
logger_options(parser) |
|
10379.2.4
by Michael Hudson
puller-side changes |
41 |
parser.add_option('--branch-type', action='append', default=[]) |
2770.1.56
by Guilherme Salgado
Cleanup loads of code, improved some tests and got all of them to work. |
42 |
(options, arguments) = parser.parse_args() |
43 |
if arguments: |
|
44 |
parser.error("Unhandled arguments %s" % repr(arguments)) |
|
8721.2.12
by Michael Hudson
create a generic supermirror_puller config section |
45 |
log = set_up_logging_for_script(options, 'supermirror_puller') |
4898.2.49
by Jonathan Lange
Make the scripts pass on errors more reliably and fix a bunch of them. |
46 |
manager = scheduler.JobScheduler( |
9590.1.49
by Michael Hudson
more combining the puller and filesystem endpoints |
47 |
LoggingProxy(config.codehosting.codehosting_endpoint, log), log, |
10379.2.5
by Michael Hudson
integration test and implied fixes |
48 |
options.branch_type) |
2770.1.62
by Guilherme Salgado
Huge cleanup done on a pair programming session with Rob. |
49 |
|
4898.2.7
by Jonathan Lange
Mirror multiple branches in subprocesses, limited by a semaphore |
50 |
reactor.callWhenRunning(run_mirror, log, manager) |
51 |
reactor.run() |