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 |
#
|
14564.3.1
by Jeroen Vermeulen
Lint. |
3 |
# Copyright 2009-2011 Canonical Ltd. This software is licensed under the
|
8687.15.7
by Karl Fogel
Add the copyright header block to more files. |
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 |
|
14564.3.1
by Jeroen Vermeulen
Lint. |
8 |
from optparse import OptionParser |
9 |
||
4898.2.26
by Jonathan Lange
Refactor server-side protocol to be more generic. Restore '_pythonpath' import |
10 |
import _pythonpath |
14564.3.1
by Jeroen Vermeulen
Lint. |
11 |
from twisted.internet import ( |
12 |
defer, |
|
13 |
reactor, |
|
14 |
)
|
|
6108.1.1
by Michael Hudson
the fix :( |
15 |
from twisted.python import log as tplog |
4898.2.7
by Jonathan Lange
Mirror multiple branches in subprocesses, limited by a semaphore |
16 |
|
6971.2.1
by Jonathan Lange
Get rid of BranchStatusClient. This should avoid the attribute error we |
17 |
from canonical.config import config |
14564.3.1
by Jeroen Vermeulen
Lint. |
18 |
from lp.codehosting.puller import ( |
19 |
mirror, |
|
20 |
scheduler, |
|
21 |
)
|
|
14565.2.15
by Curtis Hovey
Moved canonical.launchpad.scripts __init__ to lp.services.scripts. |
22 |
from lp.services.scripts import logger_options |
10548.1.1
by Jonathan Lange
Move twistedsupport to lp.services |
23 |
from lp.services.twistedsupport.loggingsupport import ( |
14564.3.1
by Jeroen Vermeulen
Lint. |
24 |
LoggingProxy, |
25 |
set_up_logging_for_script, |
|
26 |
)
|
|
27 |
||
2770.1.56
by Guilherme Salgado
Cleanup loads of code, improved some tests and got all of them to work. |
28 |
|
4898.2.49
by Jonathan Lange
Make the scripts pass on errors more reliably and fix a bunch of them. |
29 |
def clean_shutdown(ignored): |
30 |
reactor.stop() |
|
31 |
||
32 |
||
33 |
def shutdown_with_errors(failure): |
|
6108.1.1
by Michael Hudson
the fix :( |
34 |
tplog.err(failure) |
4898.2.49
by Jonathan Lange
Make the scripts pass on errors more reliably and fix a bunch of them. |
35 |
failure.printTraceback() |
36 |
reactor.stop() |
|
37 |
||
38 |
||
4898.2.7
by Jonathan Lange
Mirror multiple branches in subprocesses, limited by a semaphore |
39 |
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. |
40 |
# It's conceivable that mirror() might raise an exception before it
|
41 |
# returns a Deferred -- maybeDeferred means we don't have to worry.
|
|
42 |
deferred = defer.maybeDeferred(mirror, log, manager) |
|
43 |
deferred.addCallback(clean_shutdown) |
|
44 |
deferred.addErrback(shutdown_with_errors) |
|
4898.2.7
by Jonathan Lange
Mirror multiple branches in subprocesses, limited by a semaphore |
45 |
|
46 |
||
2770.1.56
by Guilherme Salgado
Cleanup loads of code, improved some tests and got all of them to work. |
47 |
if __name__ == '__main__': |
48 |
parser = OptionParser() |
|
49 |
logger_options(parser) |
|
10379.2.4
by Michael Hudson
puller-side changes |
50 |
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. |
51 |
(options, arguments) = parser.parse_args() |
52 |
if arguments: |
|
53 |
parser.error("Unhandled arguments %s" % repr(arguments)) |
|
14564.3.1
by Jeroen Vermeulen
Lint. |
54 |
log = set_up_logging_for_script( |
55 |
options, 'supermirror_puller', options.log_file) |
|
4898.2.49
by Jonathan Lange
Make the scripts pass on errors more reliably and fix a bunch of them. |
56 |
manager = scheduler.JobScheduler( |
9590.1.49
by Michael Hudson
more combining the puller and filesystem endpoints |
57 |
LoggingProxy(config.codehosting.codehosting_endpoint, log), log, |
10379.2.5
by Michael Hudson
integration test and implied fixes |
58 |
options.branch_type) |
2770.1.62
by Guilherme Salgado
Huge cleanup done on a pair programming session with Rob. |
59 |
|
4898.2.7
by Jonathan Lange
Mirror multiple branches in subprocesses, limited by a semaphore |
60 |
reactor.callWhenRunning(run_mirror, log, manager) |
61 |
reactor.run() |