本文整理汇总了Python中trello.TrelloClient方法的典型用法代码示例。如果您正苦于以下问题:Python trello.TrelloClient方法的具体用法?Python trello.TrelloClient怎么用?Python trello.TrelloClient使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类trello
的用法示例。
在下文中一共展示了trello.TrelloClient方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_context_data
# 需要导入模块: import trello [as 别名]
# 或者: from trello import TrelloClient [as 别名]
def get_context_data(self, **kwargs):
""" Fishy way to ensure trello_client is configured.
"""
try:
context = super(BoardView, self).get_context_data(**kwargs)
token = self.request.GET.get('token')
if token is None:
context['board_list'] = None
trello_client = TrelloClient(api_key=settings.TRELLO_APIKEY, token=token)
trello_client.list_boards()
user = self.request.user
listboard = Board.objects.filter(trello_token=token)
context['board_list'] = listboard
context['trello_error'] = None
except Exception as e:
context['trello_error'] = "{} :: api_key={} :: token={}".format(e,
settings.TRELLO_APIKEY, settings.TRELLO_TOKEN)
finally:
return context
示例2: __connect
# 需要导入模块: import trello [as 别名]
# 或者: from trello import TrelloClient [as 别名]
def __connect(self, config):
trello_client = trello.TrelloClient(
api_key=config.api_key,
api_secret=config.api_secret,
token=config.oauth_token,
token_secret=config.oauth_token_secret,
)
try:
# A simple API call (data reused in self.main_board) to initiate connection & test our credentials etc
self.boards = trello_client.fetch_json('/members/me/boards/?filter=open')
return trello_client
except requests.exceptions.ConnectionError:
print('[FATAL] Could not connect to the Trello API!')
raise GTDException(1)
except trello.exceptions.Unauthorized:
print('[FATAL] Trello API credentials are invalid')
raise GTDException(1)
示例3: __init__
# 需要导入模块: import trello [as 别名]
# 或者: from trello import TrelloClient [as 别名]
def __init__(self):
trello_config = Config.open_api.trello
self.client = TrelloClient(
api_key=trello_config.API_KEY,
api_secret=trello_config.API_SECRET,
token=trello_config.TOKEN,
)
self.board = self.client.get_board(trello_config.BOARD)
示例4: _get_client
# 需要导入模块: import trello [as 别名]
# 或者: from trello import TrelloClient [as 别名]
def _get_client(self) -> trello.TrelloClient:
if not self._client:
self._client = trello.TrelloClient(
api_key=self.api_key,
api_secret=self.api_secret,
token=self.token,
)
return self._client
示例5: _get_trello_client
# 需要导入模块: import trello [as 别名]
# 或者: from trello import TrelloClient [as 别名]
def _get_trello_client(self):
client = TrelloClient(
api_key=self.trello_member_profile.api_key,
api_secret=self.trello_member_profile.api_secret,
token=self.trello_member_profile.token,
token_secret=self.trello_member_profile.token_secret
)
return client
示例6: get
# 需要导入模块: import trello [as 别名]
# 或者: from trello import TrelloClient [as 别名]
def get(self, request):
try:
token = request.GET.get('token')
user = request.user
if token is None:
boards = None
return super(BoardView, self).get(request)
else:
trello_client = TrelloClient(api_key=settings.TRELLO_APIKEY, token=token)
boards = trello_client.list_boards()
if boards:
result = [h.delete() for h in trello_client.list_hooks()]
print("delete trello hook :: result={}".format(result))
for board in boards:
print ("BOARD_ID:", board.id)
slug_board = slugify(board.name, allow_unicode=False)
b, created = Board.objects.get_or_create(name=slug_board, user=user, trello_board_id = board.id, trello_token = token)
host = getenv("MATTERLLO_HOST") or request.get_host()
url = "{}://{}/callback/{}/".format(request.scheme, host, b.id)
result = trello_client.create_hook(url, board.id)
print("create trello hook :: callback={} :: board={} :: result={}".format(url, slug_board, result))
return super(BoardView, self).get(request)
except Exception as e:
print("unable to display board :: {}".format(e))
return super(BoardView, self).get(request)
示例7: perform_import
# 需要导入模块: import trello [as 别名]
# 或者: from trello import TrelloClient [as 别名]
def perform_import(self, retreival_param, unit, token=None):
#from clatoolkit.models import ApiCredentials
#Set up trello auth and API
self.TrelloCient = TrelloClient(
api_key=os.environ.get("TRELLO_API_KEY"),
token=token
)
#Get user-registered board in trello
trello_board = self.TrelloCient.get_board(retreival_param)
#Get boards activity/action feed
trello_board.fetch_actions('all') #fetch_actions() collects actions feed and stores to trello_board.actions
self.import_TrelloActivity(trello_board.actions, unit)
示例8: get_trello_boards
# 需要导入模块: import trello [as 别名]
# 或者: from trello import TrelloClient [as 别名]
def get_trello_boards():
""" Get all Trello boards """
trello_client = TrelloClient(api_key=trello_api_key, api_secret=trello_api_secret, token=trello_token, token_secret=trello_token_secret)
return trello_client.list_boards(board_filter="open")
示例9: create_trello_board
# 需要导入模块: import trello [as 别名]
# 或者: from trello import TrelloClient [as 别名]
def create_trello_board(board_name):
"""
Create Trello board and returns it
:board_name: the board name
"""
trello_client = TrelloClient(api_key=trello_api_key, api_secret=trello_api_secret, token=trello_token, token_secret=trello_token_secret)
return trello_client.add_board(board_name)
示例10: delete_trello_card
# 需要导入模块: import trello [as 别名]
# 或者: from trello import TrelloClient [as 别名]
def delete_trello_card(trello_card_id):
"""
Delete (forever) a Trello Card by ID
:trello_card_id: Trello card ID
"""
trello_client = TrelloClient(api_key=trello_api_key, api_secret=trello_api_secret, token=trello_token, token_secret=trello_token_secret)
try:
trello_card = trello_client.get_card(trello_card_id)
trello_card.delete()
except Exception:
print('Cannot find Trello card with ID {0} deleted in Task Warrior. Maybe you deleted it in Trello too.'.format(trello_card_id))