26
26
from canonical.config import config
27
27
from lp.codehosting import load_optional_plugin
28
28
from lp.codehosting.codeimport.worker import (
29
BzrSvnImportWorker, CSCVSImportWorker, CodeImportSourceDetails,
30
GitImportWorker, HgImportWorker, get_default_bazaar_branch_store)
29
BzrSvnImportWorker, CSCVSImportWorker, CodeImportBranchOpenPolicy,
30
CodeImportSourceDetails, GitImportWorker, HgImportWorker,
31
get_default_bazaar_branch_store)
31
32
from lp.codehosting.safe_open import AcceptAnythingPolicy
32
33
from canonical.launchpad import scripts
37
"anything": AcceptAnythingPolicy(),
38
"default": CodeImportBranchOpenPolicy()
35
42
def force_bzr_to_use_urllib():
36
43
"""Prevent bzr from using pycurl to connect to http: urls.
38
45
We want this because pycurl rejects self signed certificates, which
39
46
prevents a significant number of import branchs from updating. Also see
40
https://bugs.edge.launchpad.net/bzr/+bug/516222.
47
https://bugs.launchpad.net/bzr/+bug/516222.
42
49
from bzrlib.transport import register_lazy_transport
43
50
register_lazy_transport('http://', 'bzrlib.transport.http._urllib',
51
58
def __init__(self):
52
59
parser = OptionParser()
53
60
scripts.logger_options(parser)
54
options, self.args = parser.parse_args()
55
self.logger = scripts.logger(options, 'code-import-worker')
61
parser.add_option("--access-policy", type="choice", metavar="ACCESS_POLICY",
62
choices=["anything", "default"], default="default")
63
self.options, self.args = parser.parse_args()
64
self.logger = scripts.logger(self.options, 'code-import-worker')
58
67
force_bzr_to_use_urllib()
76
85
get_transport(config.codeimport.foreign_tree_store),
77
86
get_default_bazaar_branch_store(), self.logger,
78
AcceptAnythingPolicy())
87
opener_policies[self.options.access_policy])
79
88
return import_worker.run()