本文整理汇总了Python中trello.TrelloClient类的典型用法代码示例。如果您正苦于以下问题:Python TrelloClient类的具体用法?Python TrelloClient怎么用?Python TrelloClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TrelloClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: save_to_trello
def save_to_trello(self):
# print clean_form_data
api_key = settings.TRELLO_KEY
secret = settings.TRELLO_SECRET
token = settings.TRELLO_TOKEN
board = settings.TRELLO_REQUEST_BOARD
c = TrelloClient(api_key, secret, token)
b = c.get_board(board)
# Currently we default to adding card to first list
l = b.all_lists()[0]
label_list = b.get_labels()
ds_name = "%s - %s" % (self.dataset_name, self.dataset_source)
ds_description = "%s\n%s\nRequested by: %s %s, %s" % \
(self.dataset_name,
self.dataset_description,
self.user_first_name,
self.user_last_name,
self.user_email)
try:
label_to_add = next(x for x in label_list if x.name == 'Request')
except StopIteration:
label_to_add = b.add_label('Request', "lime")
try:
card = l.add_card(ds_name, ds_description, [label_to_add])
self.trello_id = card.id
except Exception:
pass
示例2: sync_trello_cards
def sync_trello_cards(self):
if not self.trello_id:
logger.exception("Trello board id for %s not set", self.name)
raise NotSetTrelloBoardID
client = TrelloClient(**TRELLO_KEYS)
tasks = client.fetch_json("boards/{}/cards".format(self.trello_id))
for task_dict in tasks:
last_activity = task_dict.get('dateLastActivity')
task, created = Task.objects.get_or_create(
trello_id=task_dict['id'],
project=self
)
if created or last_activity != task.trello_last_activity:
task.name = task_dict['name']
task.description = task_dict['desc']
task.trello_url = task_dict['shortUrl']
task.trello_last_activity = last_activity
task.save()
logger.info(
"Trello card with id %s and name %s has ben %s",
task_dict['id'],
task_dict['name'],
'created' if created else 'updated'
)
示例3: create_trello_board
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)
示例4: __init__
def __init__(self):
# API = "9cc1470c039f9f1bf8fe3ce35689a127"
# TOKEN = "2093b976115e83e07b33321b359aa53a74d612aeec6373218d15796bd78a45b1"
API = get_credentials()["api"]
TOKEN = get_credentials()["token"]
client = TrelloClient(api_key=API,
token=TOKEN)
self.boards = client.list_boards()
示例5: post
def post(self):
""" Collect data from the HTML form to fill in a Trello card.
That card will be uploaded to Suggestion Box board, on the corresponding
list, determined by the "System" attribute given in the form.
"""
# Get form data
date = datetime.now()
title = self.get_argument('title')
area = self.get_argument('area')
system = self.get_argument('system')
importance = self.get_argument('importance')
difficulty = self.get_argument('difficulty')
user = self.get_current_user_name()
description = self.get_argument('description')
suggestion = self.get_argument('suggestion')
client = TrelloClient(api_key = self.application.trello_api_key,
api_secret = self.application.trello_api_secret,
token = self.application.trello_token)
# Get Suggestion Box board
boards = client.list_boards()
suggestion_box = None
for b in boards:
if b.name == 'Suggestion Box':
suggestion_box = client.get_board(b.id)
break
# Get the board lists (which correspond to System in the form data) and
# concretely get the list where the card will go
lists = b.all_lists()
card_list = None
for l in lists:
if l.name == system:
card_list = l
break
# Create new card using the info from the form
new_card = card_list.add_card(TITLE_TEMPLATE.format(title=title, area=area))
new_card.set_description(DESCRIPTION_TEMPLATE.format(date = date.ctime(),
area=area,
system=system,
importance=importance,
difficulty=difficulty,
user=user,
description=description,
suggestion=suggestion))
# Save the information of the card in the database
self.application.suggestions_db.create({'date': date.isoformat(),
'card_id': new_card.id,
'description': new_card.description,
'name': new_card.name,
'url': new_card.url,
'archived': False})
self.set_status(200)
示例6: get_trello_boards
def get_trello_boards():
""" Get all Trello boards """
logger.info('Fetching Trello boards ...')
trello_client = TrelloClient(
api_key=trello_api_key,
api_secret=trello_api_secret,
token=trello_token,
token_secret=trello_token_secret)
logger.info('... done')
return trello_client.list_boards()
示例7: delete_from_trello
def delete_from_trello(self):
api_key = settings.TRELLO_KEY
secret = settings.TRELLO_SECRET
token = settings.TRELLO_TOKEN
id = self.trello_id
c = TrelloClient(api_key, secret, token)
card = c.get_card(id)
try:
card.set_closed(True)
except Exception:
pass
示例8: main
def main(api_key, token):
"""List out the boards for our client"""
trello_client = TrelloClient(
api_key=api_key,
token=token,
)
print('Boards')
print('-----')
print('Name: Id')
for board in trello_client.list_boards():
print('{board.name}: {board.id}'.format(board=board))
示例9: delete_trello_card
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))
示例10: get_client
def get_client(self):
client = None
while client is None:
self._set_creds()
client = TrelloClient(api_key=self._api_key, token=self._token)
try:
client.list_hooks(self._token)
except Unauthorized:
print('Trello client is not authorized.')
client = None
self._write_config()
print('Trello client successfully authorized.')
return client
示例11: connectionJASON
class connectionJASON():
def setUp(self):
self._trello = TrelloClient(api_key='f8fd231446c1fd27f49e0d8f933252f3',
api_secret='338b8eef2cc489ce5cfc9f2252c73f5cf51b44a41cc6cb790be20feb9ed19f2d',
token='8004f00bc94627ac6eb98333492a76315821ed06e9d04eec4b6480d1f575758b',
token_secret='a528cdd05a0dd7314f45995fdf457c45')
def getCards(self):
boards = [board for board in self._trello.list_boards() if 'Proy Industria' in str(board.name) ]
board = boards[0]
cards = board.get_cards()
return cards
def arrangeCards(self,cards):
resultTree = AVLTree();
for i in cards:
if resultTree.rootNode == None:
resultTree.insert(i,0)
else:
#resultTree.rootNode.text
currentNode = resultTree.rootNode
done = True
while(done):
moreImportant = (input(str(i)+" is more important than "+str(currentNode.text)+" y/n "))
if moreImportant == "y":
if(currentNode.rightChild == None):
resultTree.add_as_child2(i,currentNode,1)
done = False
else:
currentNode = currentNode.rightChild
else:
if(currentNode.leftChild == None):
resultTree.add_as_child2(i,currentNode,0)
done = False
else:
currentNode = currentNode.leftChild
print(resultTree.as_list(1))
#print(resultTree.rebalance_count)
#print (resultTree.out())
return resultTree
def sendCards(self,cards):
boards = [board for board in self._trello.list_boards() if 'Proy Industria' in str(board.name) ]
board = boards[0]
cards = board.get_cards()
return cards
示例12: TrelloWrapper
class TrelloWrapper():
def __init__(self, api_key, api_token):
self.tc = TrelloClient(api_key, api_token)
def add_card(self, list_target, card_name, card_due, desc=None):
"""
Add card to list with a due date
card_due: time.stuct_time object,
use time.localtime()
"""
try:
# Convert to UTC datetime object
card_due_utc = time.gmtime(time.mktime(card_due))
due_str = time.strftime("%Y-%m-%dT%H:%M", card_due_utc)
json_obj = list_target.client.fetch_json(
'/lists/' + list_target.id + '/cards',
http_method='POST',
post_args={'name': card_name, 'due': due_str,
'idList': list_target.id, 'desc': desc}, )
except Exception as e:
print(str(e))
def smart_add_card(self, sentence):
"""Check date keywords in the sentence,
and use as card's due date."""
# TODO Life/Inbox as default, move to config
target_default = ("Life", "Inbox")
t_curr = time.time()
p = parser.Parser(t_curr)
target = p.parse_list(sentence)
if target is None:
target = target_default
due = p.parse_due_time(sentence)
list_target = self.find_list(target[0],
target[1])
if list_target is None:
return False
self.add_card(list_target, sentence, due.timetuple())
return True
def find_list(self, board_name, list_name):
""" Return list specified by board_name/list_name"""
for b in self.tc.list_boards():
if b.name != board_name:
continue
for l in b.open_lists():
if l.name != list_name:
continue
return l
return None
示例13: get_trello_list
def get_trello_list():
# connect to trello
trello_api_key = 'xxxx'
trello_api_secret = 'xxxx'
# this oauth token and secret are fetched using trello_oauth_util.py
trello_oauth_token = "xxxx"
trello_oauth_token_secret = "xxxx"
trello_client = TrelloClient(api_key=trello_api_key, api_secret=trello_api_secret, token=trello_oauth_token,
token_secret=trello_oauth_token_secret)
# fetch the desired board
# noinspection PyTypeChecker
for board in trello_client.list_boards():
if TRELLO_BOARD_NAME == board.name:
for board_list in board.all_lists():
if TRELLO_LIST_NAME == board_list.name:
return board_list
示例14: __init__
def __init__(self, credentials, boards=None):
self.trello_client = TrelloClient(
api_key=credentials['public_key'],
token=credentials['member_token'],
)
self.boards = boards
示例15: __init__
def __init__(self, token=None, **kwargs):
super(ServiceTrello, self).__init__(token, **kwargs)
# app name
self.app_name = DjangoThConfig.verbose_name
# expiration
self.expiry = "30days"
# scope define the rights access
self.scope = 'read,write'
self.oauth = 'oauth1'
self.service = 'ServiceTrello'
base = 'https://www.trello.com'
self.AUTH_URL = '{}/1/OAuthAuthorizeToken'.format(base)
self.REQ_TOKEN = '{}/1/OAuthGetRequestToken'.format(base)
self.ACC_TOKEN = '{}/1/OAuthGetAccessToken'.format(base)
self.consumer_key = settings.TH_TRELLO_KEY['consumer_key']
self.consumer_secret = settings.TH_TRELLO_KEY['consumer_secret']
if token:
token_key, token_secret = token.split('#TH#')
try:
self.trello_instance = TrelloClient(self.consumer_key,
self.consumer_secret,
token_key,
token_secret)
except ResourceUnavailable as e:
us = UserService.objects.get(token=token)
logger.error(e.msg, e.error_code)
update_result(us.trigger_id, msg=e.msg, status=False)