~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/plugins/launchpad/__init__.py

  • Committer: Jonathan Lange
  • Date: 2009-12-09 09:27:59 UTC
  • mto: This revision was merged to the branch mainline in revision 4907.
  • Revision ID: jml@canonical.com-20091209092759-pncdxwh7jwdr3gq7
Always register the lp-mirror command. Only try to load launchpadlib if
you try to run lp-mirror.

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
    NotLaunchpadBranch,
47
47
    )
48
48
 
49
 
try:
50
 
    from bzrlib.plugins.launchpad import lp_api
51
 
except ImportError:
52
 
    lp_api = None
53
 
 
54
49
 
55
50
class cmd_register_branch(Command):
56
51
    """Register a branch with launchpad.net.
266
261
    aliases = ['lp-mirror']
267
262
    takes_args = ['location?']
268
263
 
 
264
    def _get_lp_api(self):
 
265
        """Return the lp_api module, if it's loadable."""
 
266
        try:
 
267
            from bzrlib.plugins.launchpad import lp_api
 
268
        except ImportError:
 
269
            raise BzrCommandError(
 
270
                "%s requires launchpadlib" % self.name())
 
271
        return lp_api
 
272
 
269
273
    def run(self, location='.'):
270
274
        service = LaunchpadService()
 
275
        lp_api = self._get_lp_api()
271
276
        launchpad = lp_api.login(service)
272
277
        branch = _mod_branch.Branch.open(location)
273
278
        lp_branch = lp_api.load_branch(launchpad, branch)
274
279
        lp_branch.requestMirror()
275
280
 
276
281
 
277
 
if lp_api is not None:
278
 
    register_command(cmd_launchpad_mirror)
 
282
register_command(cmd_launchpad_mirror)
279
283
 
280
284
 
281
285
def _register_directory():