コード例 #1
0
ファイル: cmds.py プロジェクト: GymWenFLL/tpp_libs
    def run(self,
            public_url=None,
            project='',
            product=None,
            branch_name='',
            branch_title='',
            branch_description='',
            author='',
            link_bug=None,
            dry_run=False):
        from bzrlib.plugins.launchpad.lp_registration import (
            BranchRegistrationRequest, BranchBugLinkRequest,
            DryRunLaunchpadService, LaunchpadService)
        if public_url is None:
            try:
                b = _mod_branch.Branch.open_containing('.')[0]
            except NotBranchError:
                raise BzrCommandError(gettext(
                            'register-branch requires a public '
                            'branch url - see bzr help register-branch.'))
            public_url = b.get_public_branch()
            if public_url is None:
                raise NoPublicBranch(b)
        if product is not None:
            project = product
            trace.note(gettext(
                '--product is deprecated; please use --project.'))


        rego = BranchRegistrationRequest(branch_url=public_url,
                                         branch_name=branch_name,
                                         branch_title=branch_title,
                                         branch_description=branch_description,
                                         product_name=project,
                                         author_email=author,
                                         )
        linko = BranchBugLinkRequest(branch_url=public_url,
                                     bug_id=link_bug)
        if not dry_run:
            service = LaunchpadService()
            # This gives back the xmlrpc url that can be used for future
            # operations on the branch.  It's not so useful to print to the
            # user since they can't do anything with it from a web browser; it
            # might be nice for the server to tell us about an html url as
            # well.
        else:
            # Run on service entirely in memory
            service = DryRunLaunchpadService()
        service.gather_user_credentials()
        rego.submit(service)
        if link_bug:
            linko.submit(service)
        self.outf.write('Branch registered.\n')
コード例 #2
0
ファイル: cmds.py プロジェクト: pombreda/dist-packages
    def run(self,
            public_url=None,
            project='',
            product=None,
            branch_name='',
            branch_title='',
            branch_description='',
            author='',
            link_bug=None,
            dry_run=False):
        from bzrlib.plugins.launchpad.lp_registration import (
            BranchRegistrationRequest, BranchBugLinkRequest,
            DryRunLaunchpadService, LaunchpadService)
        if public_url is None:
            try:
                b = _mod_branch.Branch.open_containing('.')[0]
            except NotBranchError:
                raise BzrCommandError(
                    gettext('register-branch requires a public '
                            'branch url - see bzr help register-branch.'))
            public_url = b.get_public_branch()
            if public_url is None:
                raise NoPublicBranch(b)
        if product is not None:
            project = product
            trace.note(
                gettext('--product is deprecated; please use --project.'))

        rego = BranchRegistrationRequest(
            branch_url=public_url,
            branch_name=branch_name,
            branch_title=branch_title,
            branch_description=branch_description,
            product_name=project,
            author_email=author,
        )
        linko = BranchBugLinkRequest(branch_url=public_url, bug_id=link_bug)
        if not dry_run:
            service = LaunchpadService()
            # This gives back the xmlrpc url that can be used for future
            # operations on the branch.  It's not so useful to print to the
            # user since they can't do anything with it from a web browser; it
            # might be nice for the server to tell us about an html url as
            # well.
        else:
            # Run on service entirely in memory
            service = DryRunLaunchpadService()
        service.gather_user_credentials()
        rego.submit(service)
        if link_bug:
            linko.submit(service)
        self.outf.write('Branch registered.\n')
コード例 #3
0
ファイル: test_register.py プロジェクト: saminigod/cygwin
 def test_gather_user_credentials_prompts(self):
     service = LaunchpadService()
     self.assertIs(None, service.registrant_password)
     g_conf = config.GlobalConfig()
     g_conf.set_user_option('email', 'Test User <*****@*****.**>')
     stdout = tests.StringIOWrapper()
     ui.ui_factory = tests.TestUIFactory(stdin='userpass\n',
                                         stdout=stdout)
     self.assertIs(None, service.registrant_password)
     service.gather_user_credentials()
     self.assertEqual('*****@*****.**', service.registrant_email)
     self.assertEqual('userpass', service.registrant_password)
     self.assertContainsRe(stdout.getvalue(),
                          'launchpad.net password for test@user\\.com')
コード例 #4
0
ファイル: test_register.py プロジェクト: GymWenFLL/tpp_libs
 def test_gather_user_credentials_from_auth_conf(self):
     auth_path = config.authentication_config_filename()
     service = LaunchpadService()
     g_conf = config.GlobalStack()
     g_conf.set('email', 'Test User <*****@*****.**>')
     f = open(auth_path, 'wb')
     try:
         scheme, hostinfo = urlparse.urlsplit(service.service_url)[:2]
         f.write('[section]\n'
                 'scheme=%s\n'
                 'host=%s\n'
                 '[email protected]\n'
                 'password=testpass\n'
                 % (scheme, hostinfo))
     finally:
         f.close()
     self.assertIs(None, service.registrant_password)
     service.gather_user_credentials()
     self.assertEqual('*****@*****.**', service.registrant_email)
     self.assertEqual('testpass', service.registrant_password)
コード例 #5
0
ファイル: test_register.py プロジェクト: saminigod/cygwin
 def test_gather_user_credentials_from_auth_conf(self):
     auth_path = config.authentication_config_filename()
     service = LaunchpadService()
     g_conf = config.GlobalConfig()
     g_conf.set_user_option('email', 'Test User <*****@*****.**>')
     f = open(auth_path, 'wb')
     try:
         scheme, hostinfo = urlparse.urlsplit(service.service_url)[:2]
         f.write('[section]\n'
                 'scheme=%s\n'
                 'host=%s\n'
                 '[email protected]\n'
                 'password=testpass\n'
                 % (scheme, hostinfo))
     finally:
         f.close()
     self.assertIs(None, service.registrant_password)
     service.gather_user_credentials()
     self.assertEqual('*****@*****.**', service.registrant_email)
     self.assertEqual('testpass', service.registrant_password)
コード例 #6
0
 def test_gather_user_credentials_from_auth_conf(self):
     auth_path = config.authentication_config_filename()
     service = LaunchpadService()
     g_conf = config.GlobalStack()
     g_conf.set('email', 'Test User <*****@*****.**>')
     g_conf.store.save()
     # FIXME: auth_path base dir exists only because bazaar.conf has just
     # been saved, brittle... -- vila 20120731
     f = open(auth_path, 'wb')
     try:
         scheme, hostinfo = urlparse.urlsplit(service.service_url)[:2]
         f.write('[section]\n'
                 'scheme=%s\n'
                 'host=%s\n'
                 '[email protected]\n'
                 'password=testpass\n'
                 % (scheme, hostinfo))
     finally:
         f.close()
     self.assertIs(None, service.registrant_password)
     service.gather_user_credentials()
     self.assertEqual('*****@*****.**', service.registrant_email)
     self.assertEqual('testpass', service.registrant_password)
コード例 #7
0
 def test_gather_user_credentials_has_password(self):
     service = LaunchpadService()
     service.registrant_password = '******'
     # This should be a basic no-op, since we already have the password
     service.gather_user_credentials()
     self.assertEqual('mypassword', service.registrant_password)