本文整理汇总了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)