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


Python trello.TrelloClient类代码示例

本文整理汇总了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
开发者ID:CT-Data-Collaborative,项目名称:dataset-requests,代码行数:33,代码来源:models.py

示例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'
                )
开发者ID:novirael,项目名称:django-projects-manager,代码行数:27,代码来源:models.py

示例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)
开发者ID:ogarcia,项目名称:trellowarrior,代码行数:8,代码来源:trellowarrior.py

示例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()
开发者ID:hypha,项目名称:work,代码行数:8,代码来源:board_api.py

示例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)
开发者ID:guillermo-carrasco,项目名称:status,代码行数:58,代码来源:suggestion_box.py

示例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()
开发者ID:jean,项目名称:trellowarrior,代码行数:10,代码来源:trellowarrior.py

示例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
开发者ID:CT-Data-Collaborative,项目名称:dataset-requests,代码行数:11,代码来源:models.py

示例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))
开发者ID:underdogio,项目名称:slack-to-trello,代码行数:11,代码来源:list-trello-boards.py

示例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))
开发者ID:ogarcia,项目名称:trellowarrior,代码行数:12,代码来源:trellowarrior.py

示例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
开发者ID:DataKind-SG,项目名称:test-driven-data-cleaning,代码行数:14,代码来源:credentials.py

示例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
开发者ID:marsanem,项目名称:arbolAVL,代码行数:48,代码来源:avltree.py

示例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
开发者ID:zzdoo,项目名称:trello-service,代码行数:60,代码来源:trello_wrapper.py

示例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
开发者ID:knoxxs,项目名称:evernote_to_trello_exporter,代码行数:16,代码来源:exporter.py

示例14: __init__

    def __init__(self, credentials, boards=None):
        self.trello_client = TrelloClient(
            api_key=credentials['public_key'],
            token=credentials['member_token'],
        )

        self.boards = boards
开发者ID:kogan,项目名称:eClaire,代码行数:7,代码来源:base.py

示例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)
开发者ID:foxmask,项目名称:django-th,代码行数:28,代码来源:my_trello.py


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