コード例 #1
0
def main():
    config_info = get_config_info()
    api = trelloclient.TrelloClient(api_key=config_info['api_key'],
                                    token=config_info['access_token'])

    b = get_board(api, 'Daniel\'s tasks')
    assert b is not None

    in_progress_list = get_list(b, 'In progress')
    assert in_progress_list is not None

    done_list = get_list(b, 'Done')
    assert done_list is not None

    print 'Report generated on: %s.' % datetime.date.today().isoformat()
    print 'Generated by: https://github.com/booxter/trello-report\n'

    labels = get_board_labels(b)

    for l in (in_progress_list, done_list):
        _print_list_header(l)
        cards = get_cards(l)
        for label in labels:
            labeled_cards = get_cards_by_label(cards, label)
            if labeled_cards:
                _print_label_header(label)
                for card in labeled_cards:
                    print card
                    cards.remove(card)

        # handle remaining, unlabeled cards
        if cards:
            _print_label_header('Other')
            for card in cards:
                print card
コード例 #2
0
ファイル: cards.py プロジェクト: d0ugal/filch
def create_card(api_key,
                access_token,
                board_name,
                card_name,
                card_desc,
                card_labels=[],
                card_due="null",
                list_name='New'):

    trello_api = trelloclient.TrelloClient(api_key=api_key, token=access_token)
    board = [b for b in trello_api.list_boards() if b.name == board_name][0]
    default_labels = [
        label for label in board.get_labels() if label.name in card_labels
    ]
    new_list = [
        trello_list for trello_list in board.open_lists()
        if trello_list.name == list_name
    ][0]
    card_dup = [
        card for card in new_list.list_cards()
        if card.name == card_name and card.desc == card_desc
    ]
    if not card_dup:
        card_desc = _get_description(card_desc)
        card = new_list.add_card(card_name, card_desc, default_labels,
                                 card_due)
        card.add_checklist("Reviews", [])
        return card
コード例 #3
0
 def __init__(self, api_key: AnyStr, api_secret: AnyStr, token: AnyStr,
              token_secret: AnyStr, team_id: AnyStr):
     self.api_key = api_key
     self.api_secret = api_secret
     self.client = trelloclient.TrelloClient(api_key=self.api_key,
                                             api_secret=self.api_secret,
                                             token=token,
                                             token_secret=token_secret)
     self.team_id = team_id
コード例 #4
0
def main(days, skip_not_updated):
    config_info = get_config_info()
    api = trelloclient.TrelloClient(api_key=config_info['api_key'],
                                    token=config_info['access_token'])

    b = get_board(api, config_info['board'])
    assert b is not None

    in_progress_list = get_list(b, config_info['in_progress_list'])
    assert in_progress_list is not None

    done_list = get_list(b, config_info['done_list'])
    assert done_list is not None

    top_labels = [l.strip() for l in config_info['top_labels'].split(',')]
    end_labels = [l.strip() for l in config_info['bottom_labels'].split(',')]

    print('Report generated on: %s.' % datetime.date.today().isoformat())
    print('Generated by: https://github.com/booxter/trello-report\n')

    labels = get_board_labels(b, top_labels, end_labels)
    since = (datetime.datetime.now(datetime.timezone.utc) -
             datetime.timedelta(days=days)) if days else None
    d = rstcloth.RstCloth()
    for l in (in_progress_list, done_list):
        d.h1(l.name)
        d.newline()
        cards, not_updated = get_cards(l, updated_since=since)
        for label in labels:
            labeled_cards = get_cards_by_label(cards, label)
            if labeled_cards:
                d.h2(label)
                for card in labeled_cards:
                    d.newline()
                    d._add(str(card))
                    cards.remove(card)
                d.newline()

        # handle remaining, unlabeled cards
        if cards:
            d.h2('Other')
            for card in cards:
                d.newline()
                d._add(str(card))
            d.newline()
        # special section for cards that haven't had updates this week
        if not_updated and not skip_not_updated:
            d.h2("Not Updated")
            for card in not_updated:
                d.newline()
                d._add(str(card))

    d.print_content()
コード例 #5
0
ファイル: boards.py プロジェクト: infraredgirl/filch
def get_or_create_board(config, name):
    trello_api = trelloclient.TrelloClient(
        api_key=config['trello']['api_key'],
        token=config['trello']['access_token']
    )
    boards = trello_api.list_boards()
    board_filter = [b for b in boards if b.name == name]
    if len(board_filter) > 0:
        board = board_filter[0]
    else:
        board = trello_api.add_board(name)
        board.open()
    return board
コード例 #6
0
ファイル: board_report.py プロジェクト: rbrady/trello-extras
def board_report(access_token, api_key, config, board_name, output, template):
    # check for access_token and api_key
    # if the access_token and api_key are not provided, try to use the config.
    if access_token is None or api_key is None:
        # if the config value is None, the method will try the default path.
        config_data = get_config_info(config)
        access_token = config_data['access_token']
        api_key = config_data['api_key']

    # if no trello auth data found, print message and exit
    if access_token is None or api_key is None:
        click.echo("No authentication data was provided for Trello")

    if not board_name:
        click.echo("You must provide a board_name.")
        sys.exit(1)

    if not output:
        output = "{}.txt".format(board_name)

    trello_api = trelloclient.TrelloClient(api_key=api_key, token=access_token)

    # check for board existence
    board = [b for b in trello_api.list_boards() if b.name == board_name][0]
    # if no board, print error and exit
    if not board:
        click.echo("Trello board not found!")
        sys.exit(1)

    # create board context
    context = {'board': board}

    # if template is included, render the template and return
    if template:
        with open(template,'r') as template_file:
            template_data = template_file.read()
            try:
                # Render the j2 template
                raw_template = jinja2.Environment().from_string(template_data)
                r_template = raw_template.render(**context)
                with open(output, 'w') as output_file:
                    output_file.write(r_template)
            except jinja2.exceptions.TemplateError as ex:
                error_msg = ("Error rendering template %s : %s"
                             % (template, six.text_type(ex)))
                raise Exception(error_msg)
    else:
        click.echo(board_name.title())
        click.echo(pprint(context))
    pass
コード例 #7
0
    async def feedback(self, message_object, list_name, text):
        if text is None or text == "" or len(text) < 4:
            await self.pm.client.send_message(message_object.channel,
                                              message_object.author.mention + " please enter a description.")
            return

        trello = trelloclient.TrelloClient(self.api_key, token=self.token)

        board = trello.get_board(self.board)

        for list in board.get_lists(None):
            if list.name == list_name:
                list.add_card(text + " (by " + message_object.author.name + ")")
                await self.pm.client.send_message(message_object.channel,
                                                  message_object.author.mention + " your feedback has been submitted. ("
                                                  + text + ")")
コード例 #8
0
from trello import trelloclient
from trt13.leitor_configuracao import configuracao
import plotly.graph_objs as go
import sys
import plotly
import datetime

trello = trelloclient.TrelloClient(configuracao['TRELLO_API_KEY'], None,
                                   configuracao['OAUTH_TOKEN'], None)

#média de tempo em homologação
#"datetime saída de homologação" - "datetime chegada homologação"
brd_manutencao = trello.get_board(configuracao['ID_BOARD'])
data_entrada = None
data_saida = None
tempos = list()
padrao_entrada = {'entrada': None, 'saida': None, 'total': 0, 'quant': 0}
tempo_medio_dic = {
    'Homologando': padrao_entrada,
    'Fazendo': padrao_entrada,
    'Aguardando': padrao_entrada,
    'Testando': padrao_entrada,
    'Implantando': padrao_entrada
}

#porcentagem que passou em cada lista
quant_fechados_manutencao = len(brd_manutencao.get_cards(card_filter='closed'))
lista_cartoes_fechados_manutencao = brd_manutencao.get_cards(
    card_filter='closed')
print('Quantidade cartões:', quant_fechados_manutencao)
コード例 #9
0
ファイル: boards.py プロジェクト: infraredgirl/filch
 def get_client(self):
     return trelloclient.TrelloClient(
         api_key=self.config['api_key'],
         token=self.config['access_token']
     )
コード例 #10
0
ファイル: importer.py プロジェクト: infraredgirl/filch
def importer(service, id, url, host, user, password, project, board, labels,
             list_name):
    try:
        config = configuration.get_config()
    except Exception as err:
        click.echo(err)
        sys.exit(1)

    trello_key = config['trello']['api_key']
    trello_token = config['trello']['access_token']
    if not board:
        if 'default_board' not in config['trello']:
            click.echo("No default_board exists in ~/filch.conf")
            click.echo("You must either set a default_board in ~/filch.conf "
                       "or use the --board_name option.")
            sys.exit(1)
        else:
            board = config['trello']['default_board']

    trello_api = trelloclient.TrelloClient(
        api_key=config['trello']['api_key'],
        token=config['trello']['access_token'])

    board_obj = [b for b in trello_api.list_boards() if b.name == board][0]

    # ensure labels being used are actually in the board
    card_labels = [
        label for label in board_obj.get_labels() if label.name in list(labels)
    ]

    # ensure list name exists in board
    board_list = [
        trello_list for trello_list in board_obj.open_lists()
        if trello_list.name == list_name
    ][0]

    if service == 'gerrit':
        # default to upstream openstack
        # if host is present then use that
        # if url is present then use that
        gerrit_url = "https://review.openstack.org"
        if host:
            gerrit_url = config['gerrit'][host]['url']
        if url:
            gerrit_url = url

        gerrit_api = GerritRestAPI(url=gerrit_url, auth=None)
        for change_id in list(id):
            change = gerrit_api.get("/changes/%s" % change_id)
            cards.create_card(
                board_list,
                change['subject'],
                constants.GERRIT_CARD_DESC.format(**change),
                labels=card_labels,
                due="null",
            )
            click.echo('You have successfully imported "%s"' %
                       change['subject'])

    if service == 'blueprint':
        if not project:
            click.echo('To import a blueprint you must provide a project.')
            sys.exit(1)
        for bp_id in list(id):
            blueprint = utils.get_blueprint(project, bp_id)
            cards.create_card(
                board_list,
                blueprint['title'],
                constants.BLUEPRINT_CARD_DESC.format(**blueprint),
                labels=card_labels,
                due="null",
            )
            click.echo('You have successfully imported "%s"' %
                       blueprint['title'])

    if service == 'bug':
        for bug_id in list(id):
            bug = utils.get_launchpad_bug(bug_id)
            cards.create_card(
                board_list,
                bug['title'],
                constants.BUG_CARD_DESC.format(**bug),
                labels=card_labels,
                due="null",
            )
            click.echo('You have successfully imported "%s"' % bug['title'])

    if service == 'story':
        for story_id in list(id):
            story = utils.get_storyboard_story(story_id)
            cards.create_card(
                board_list,
                story['title'],
                constants.STORY_CARD_DESC.format(**story),
                labels=card_labels,
                due="null",
            )
            click.echo('You have successfully imported "%s"' % story['title'])

    if service in ['bz', 'bugzilla']:
        if url:
            # also need user & password.  sslverify is optional
            if not user or not password:
                click.echo("If using a url for Bugzilla, you must also "
                           "provide a user and password.")
                sys.exit(1)

        # if host arg is not used, use first host from
        # configuration as default
        if not host:
            # check to ensure a host for bugzilla exists in config
            if len(config['bugzilla'].keys()) == 0:
                click.echo("No Bugzilla data configuration file.  Please "
                           "add configuration data or pass url, user and "
                           "password arguments.")
                sys.exit(1)
            else:
                host = list(config['bugzilla'].keys())[0]

        url = config['bugzilla'][host]['url']
        user = config['bugzilla'][host]['user']

        sslverify = config['bugzilla'][host].get('sslverify', True)

        for bz_id in list(id):
            try:
                bug = utils.get_bz(bz_id,
                                   url=url,
                                   user=user,
                                   password=password,
                                   sslverify=sslverify)

                if len(bug.comments) > 0:
                    bug.description = bug.comments[0]['text']

                bug_card = cards.create_card(
                    board_list,
                    bug.summary,
                    constants.BZ_CARD_DESC.format(**bug.__dict__),
                    labels=card_labels,
                    due="null",
                )

                # adds comments to a card
                if len(bug.comments) > 1:
                    for comment in bug.comments[1:]:
                        bug_card.comment(
                            constants.COMMENT_TEXT.format(
                                text=comment['text'],
                                author=comment['author'],
                                create_time=comment['creation_time'],
                                is_private=constants.COMMENT_PRIVACY[
                                    comment['is_private']],
                            ))

                # adds external trackers to card
                if len(bug.external_bugs) > 0:
                    external_trackers = []
                    for ext_bug in bug.external_bugs:
                        external_trackers.append(
                            os.path.join(ext_bug['type']['url'],
                                         ext_bug['ext_bz_bug_id']))
                    bug_card.add_checklist('External Trackers',
                                           external_trackers)

                click.echo('You have successfully imported "%s"' % bug.summary)
            except Exception as err:
                click.echo(err)

    if service == 'debug':
        ids = list(id)
        print(ids)