~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Ian Clatworthy
  • Date: 2009-02-09 23:33:58 UTC
  • mfrom: (3955.3.10 open-in-launchpad)
  • mto: This revision was merged to the branch mainline in revision 3992.
  • Revision ID: ian.clatworthy@canonical.com-20090209233358-87e0072zgnkomb6v
Command for opening Launchpad pages (Jonathan Lange)

Show diffs side-by-side

added added

removed removed

Lines of Context:
127
127
register_command(cmd_register_branch)
128
128
 
129
129
 
 
130
# XXX: Make notes to test this.
 
131
class cmd_launchpad_open(Command):
 
132
    """Open a Launchpad branch page in your web browser."""
 
133
 
 
134
    aliases = ['lp-open']
 
135
    takes_options = [
 
136
        Option('dry-run',
 
137
               'Do not actually open the browser. Just say the URL we would '
 
138
               'use.'),
 
139
        ]
 
140
    takes_args = ['location?']
 
141
 
 
142
    def run(self, location=None, dry_run=False):
 
143
        from bzrlib.plugins.launchpad.lp_registration import LaunchpadService
 
144
        from bzrlib.trace import note
 
145
        import webbrowser
 
146
        if location is None:
 
147
            location = u'.'
 
148
        branch = Branch.open(location)
 
149
        branch_url = branch.get_public_branch()
 
150
        if branch_url is None:
 
151
            raise NoPublicBranch(branch)
 
152
        service = LaunchpadService()
 
153
        web_url = service.get_web_url_from_branch_url(branch_url)
 
154
        note('Opening %s in web browser' % web_url)
 
155
        if not dry_run:
 
156
            webbrowser.open(web_url)
 
157
 
 
158
register_command(cmd_launchpad_open)
 
159
 
 
160
 
130
161
class cmd_launchpad_login(Command):
131
162
    """Show or set the Launchpad user ID.
132
163
 
182
213
    """Called by bzrlib to fetch tests for this plugin"""
183
214
    from unittest import TestSuite, TestLoader
184
215
    from bzrlib.plugins.launchpad import (
185
 
         test_account, test_lp_directory, test_lp_service, test_register,
186
 
         )
 
216
        test_account,
 
217
        test_lp_directory,
 
218
        test_lp_open,
 
219
        test_lp_service,
 
220
        test_register,
 
221
        )
187
222
 
188
223
    loader = TestLoader()
189
224
    suite = TestSuite()
191
226
        test_account,
192
227
        test_register,
193
228
        test_lp_directory,
 
229
        test_lp_open,
194
230
        test_lp_service,
195
231
        ]:
196
232
        suite.addTests(loader.loadTestsFromModule(module))