コード例 #1
0
ファイル: ls-emails.py プロジェクト: sjl421/pycr
    def run(self, arguments, *args, **kwargs):
        account_id = self.parse_command_line(arguments)

        try:
            account = Gerrit.get_account(account_id or 'self')
            emails = Gerrit.get_emails(account_id or 'self')

        except PyCRError as why:
            fail('cannot list account emails', why)

        table = PrettyTable(['Email', 'Preferred', 'Confirmed'])
        table.align = 'l'

        for email in emails:
            table.add_row([
                email.email,
                checkmark(True) if email.preferred else '',
                'No' if email.pending_confirmation else 'Yes'
            ])

        with Pager(command=self.name):
            print 'Account: {}'.format(account.username)
            if emails:
                print table
            else:
                print 'No email address'
コード例 #2
0
ファイル: ls-ssh-keys.py プロジェクト: sjl421/pycr
    def run(self, arguments, *args, **kwargs):
        account_id = self.parse_command_line(arguments)

        try:
            account = Gerrit.get_account(account_id or 'self')
            keys = Gerrit.get_ssh_keys(account_id or 'self')

        except PyCRError as why:
            fail('cannot list account SSH keys', why)

        table = PrettyTable(
            ['Id', 'Algorithm', 'Comment', 'Valid', 'Encoded key'])
        table.align = 'l'

        for key in keys:
            table.add_row([
                key.seq, key.algorithm, key.comment,
                checkmark(key.valid), key.encoded_key
            ])

        with Pager(command=self.name):
            print 'Account: {}'.format(account.username)
            if keys:
                print table
            else:
                print 'No SSH keys'
コード例 #3
0
ファイル: ls-starred.py プロジェクト: sjl421/pycr
    def run(self, arguments, *args, **kwargs):
        account_id = self.parse_command_line(arguments)

        try:
            changes = Gerrit.get_starred_changes(account_id or 'self')

        except PyCRError as why:
            fail('cannot list account starred changes', why)

        with Pager(command=self.name):
            for idx, change in enumerate(changes):
                print Formatter.format(self.tokenize(idx, change))
コード例 #4
0
ファイル: show.py プロジェクト: sjl421/pycr
    def run(self, arguments, *args, **kwargs):
        changes = self.parse_command_line(arguments)
        assert changes, 'unexpected empty list'

        with Pager(command=self.name):
            for idx, change in enumerate(changes):
                try:
                    reviews = Gerrit.get_reviews(change.uuid)
                    patch = Gerrit.get_patch(change.uuid)

                except PyCRError as why:
                    warn('%s: cannot list reviewers' % change.change_id[:9],
                         why)
                    continue

                print Formatter.format(
                    self.tokenize(idx, change, reviews, patch))
コード例 #5
0
ファイル: show.py プロジェクト: sjl421/pycr
    def run(self, arguments, *args, **kwargs):
        account_ids = self.parse_command_line(arguments)

        try:
            accounts = (Gerrit.get_account(a) for a in account_ids or ['self'])

        except PyCRError as why:
            fail('cannot list accounts', why)

        table = PrettyTable(['Username', 'Name', 'Email'])
        table.align = 'l'

        for account in set(accounts):
            table.add_row([account.username, account.name, account.email])

        with Pager(command=self.name):
            print table
コード例 #6
0
    def run(self, arguments, *args, **kwargs):
        account_id = self.parse_command_line(arguments)

        try:
            account = Gerrit.get_account(account_id or 'self')
            prefs = Gerrit.get_diff_prefs(account_id or 'self')

        except PyCRError as why:
            fail('cannot list account diff preferences', why)

        table = PrettyTable(['Preference', 'Value'])
        table.align['Preference'] = 'l'
        table.align['Value'] = 'c'

        table.add_row(['Context', prefs.context])
        table.add_row(
            ['Expand all comments',
             checkmark(prefs.expand_all_comments)])
        table.add_row(['Ignore whitespace', prefs.ignore_whitespace])
        table.add_row(
            ['Intraline difference',
             checkmark(prefs.intraline_difference)])
        table.add_row(['Line length', prefs.line_length])
        table.add_row(['Manual review', checkmark(prefs.manual_review)])
        table.add_row(['Retain header', checkmark(prefs.retain_header)])
        table.add_row(
            ['Show line endings',
             checkmark(prefs.show_line_endings)])
        table.add_row(['Show tabs', checkmark(prefs.show_tabs)])
        table.add_row([
            'Show whitespace errors',
            checkmark(prefs.show_whitespace_errors)
        ])
        table.add_row(['Skip deleted', checkmark(prefs.skip_deleted)])
        table.add_row(['Skip uncommented', checkmark(prefs.skip_uncommented)])
        table.add_row(
            ['Syntax highlighting',
             checkmark(prefs.syntax_highlighting)])
        table.add_row(['Tab size', prefs.tab_size])

        with Pager(command=self.name):
            print 'Account: {}'.format(account.username)
            print table
コード例 #7
0
    def run(self, arguments, *args, **kwargs):
        owner, status, watched = self.parse_command_line(arguments)

        try:
            if watched:
                changes = Gerrit.list_watched_changes(status=status)
            else:
                changes = Gerrit.list_changes(status=status, owner=owner)

        except QueryError as why:
            # No result, not an error
            self.log.debug(str(why))
            return

        except PyCRError as why:
            fail('cannot list changes', why)

        with Pager(command=self.name):
            for idx, change in enumerate(changes):
                print Formatter.format(self.tokenize(idx, change))
コード例 #8
0
ファイル: ls-groups.py プロジェクト: sjl421/pycr
    def run(self, arguments, *args, **kwargs):
        account_id = self.parse_command_line(arguments)

        try:
            groups = Gerrit.get_groups(account_id or 'self')

        except PyCRError as why:
            fail('cannot list account groups', why)

        table = PrettyTable(['Group', 'Description', 'Visible to all'])
        table.align = 'l'
        table.align['Visible to all'] = 'c'

        for group in groups:
            table.add_row([
                group.name, group.description or '',
                checkmark(group.options.visible_to_all)
            ])

        with Pager(command=self.name):
            print table
コード例 #9
0
    def run(self, arguments, *args, **kwargs):
        account_id = self.parse_command_line(arguments)

        try:
            account = Gerrit.get_account(account_id or 'self')
            capabilities = Gerrit.get_capabilities(account_id or 'self')

        except PyCRError as why:
            fail('cannot list account capabilities', why)

        table = PrettyTable(['Capability', 'Value'])
        table.align['Capability'] = 'l'
        table.align['Value'] = 'c'

        table.add_row(['Administrate server',
                       checkmark(capabilities.administrate_server)])
        table.add_row(['Min Query limit', capabilities.query_limit.min])
        table.add_row(['Max Query limit', capabilities.query_limit.max])
        table.add_row(['Create account',
                       checkmark(capabilities.create_account)])
        table.add_row(['Create group', checkmark(capabilities.create_group)])
        table.add_row(['Create project',
                       checkmark(capabilities.create_project)])
        table.add_row(['Email reviewers',
                       checkmark(capabilities.email_reviewers)])
        table.add_row(['Kill task', checkmark(capabilities.kill_task)])
        table.add_row(['View caches', checkmark(capabilities.view_caches)])
        table.add_row(['Flush caches', checkmark(capabilities.flush_caches)])
        table.add_row(['View connections',
                       checkmark(capabilities.view_connections)])
        table.add_row(['View queue', checkmark(capabilities.view_queue)])
        table.add_row(['Run GC', checkmark(capabilities.run_gc)])

        with Pager(command=self.name):
            print 'Account: {}'.format(account.username)
            print table