当前位置: 首页>>代码示例>>Python>>正文


Python TrelloClient.create_hook方法代码示例

本文整理汇总了Python中trello.TrelloClient.create_hook方法的典型用法代码示例。如果您正苦于以下问题:Python TrelloClient.create_hook方法的具体用法?Python TrelloClient.create_hook怎么用?Python TrelloClient.create_hook使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在trello.TrelloClient的用法示例。


在下文中一共展示了TrelloClient.create_hook方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: from trello import TrelloClient [as 别名]
# 或者: from trello.TrelloClient import create_hook [as 别名]
def main():
    try:
        parser = argparse.ArgumentParser(description="Webhook helpers")
        parser.add_argument('--cleanup', dest='cleanup', action='store_true', help='delete webhook from your SETTINGS.')
        parser.add_argument('--update', dest='update', action='store_true', help='upsert webhook from your SETTINGS.')
        parser.add_argument('--init', dest='init', action='store_true', help='delete and create webhook from your SETTINGS.')

        args = parser.parse_args()
        if not args.cleanup and not args.update and not args.init:
            print parser.print_help()
            sys.exit(0)

        client = TrelloClient(api_key=SETTINGS['trello_api_key'], token=SETTINGS['trello_api_token'])
        trello_boards = client.list_boards()

        boards_name = [slugify(b['name']) for b in SETTINGS.get('boards', {}).values()]

        # cleanup part
        if args.cleanup or args.init:
            result = [h.delete() for h in client.list_hooks()]
            LOGGING.info('delete {} webhook'.format(len(result)))

        # update / init part
        if args.update or args.init:
            for board in trello_boards:
                board_name = slugify(board.name)
                if board_name not in boards_name:
                    continue

                LOGGING.info('try to create webhook board :: {}'.format(board_name))
                url = SETTINGS['callback_url'] + '/trelloCallbacks/'
                result = client.create_hook(url, board.id)
                LOGGING.info('create webhook board :: {} :: {}'.format(board_name, result))
    except Exception as e:
        LOGGING.error('unable init webhook :: {}'.format(e))
        sys.exit(1)
开发者ID:GhostLyrics,项目名称:matterllo,代码行数:38,代码来源:helper.py


注:本文中的trello.TrelloClient.create_hook方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。