~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to scripts/code-import-worker.py

  • Committer: Jelmer Vernooij
  • Date: 2011-08-24 19:39:15 UTC
  • mto: (13756.5.2 bzr-code-imports-ui)
  • mto: This revision was merged to the branch mainline in revision 13810.
  • Revision ID: jelmer@canonical.com-20110824193915-u2i701luca2guysr
Default to default access policy.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
33
34
 
34
35
 
 
36
opener_policies = {
 
37
    "anything": AcceptAnythingPolicy(),
 
38
    "default": CodeImportBranchOpenPolicy()
 
39
    }
 
40
 
 
41
 
35
42
def force_bzr_to_use_urllib():
36
43
    """Prevent bzr from using pycurl to connect to http: urls.
37
44
 
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.
41
48
    """
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')
56
65
 
57
66
    def main(self):
58
67
        force_bzr_to_use_urllib()
75
84
            source_details,
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()
80
89
 
81
90