def main(): api_key = "YOUR_API_KEY_HERE" token = "YOUR_TOKEN_HERE" board_id = "BOARD_ID_HERE" list_name = "LIST_NAME_HERE" xlsx_file_path = "data.xlsx" label_name = "LABEL_NAME_HERE" MyTrello = Trello(api_key, token) B = MyTrello.GetBoardById(board_id) TodoList = B.GetListByName(list_name) wb = load_workbook(xlsx_file_path) sheet = wb.active max_row = sheet.max_row label = B.GetLabelByName(label_name) for i in range(2, max_row + 1): # iterate over all columns print(i) question = sheet.cell(row=i, column=1).value Card = MyTrello.new('Card', question, TodoList) comment = sheet.cell(row=i, column=2).value # Test if comment is empty if comment is not None: Card.SetDesc(comment) priority = sheet.cell(row=i, column=3).value difficulty = sheet.cell(row=i, column=4).value Card.AddLabel(label)
def get_mock_trello(trello_config): api_client = ApiClient() api_client.get = mock_get([{ "id": "5eeb648682bb2c685cc659f0", "name": NOT_STARTED, "closed": False, "pos": 1, "softLimit": None, "idBoard": "5eeb6486ebbfa66d2e519922", "subscribed": False }, { "id": "5eeb648623bb2c685cc659f0", "name": IN_PROGRESS, "closed": False, "pos": 2, "softLimit": None, "idBoard": "5eeb6486ebbfa66d2e519922", "subscribed": False }, { "id": "5eeb6486cae807625c9f0819", "name": COMPLETED, "closed": False, "pos": 3, "softLimit": None, "idBoard": "5eeb6486ebbfa66d2e519922", "subscribed": False }]) trello = Trello(trello_config, api_client) return trello, api_client, trello_config
def process_trello_token_conv(self, bot, update, user_data): logger.info("Got to process_trello_token") trello_token = update.message.text.strip() trello = Trello(trello_token) starred_boards = trello.get_starred_boards() if starred_boards is None: update.message.reply_text( "Sorry, the token looks invalid. " "Restart the process using /setup and then " "choose a new, valid one.\nEND." ) return ConversationHandler.END user_data["trello_token"] = trello_token update.message.reply_text( "Token validated successfully. Please choose, among these, your preferred board for " "ideas collection. There are listed only starred boards. " "If it's not among them, star your preferred board, and then restart the process.", reply_markup=ReplyKeyboardMarkup( [ [ '{name} ({part_id})'.format(name=x['name'], part_id=x['id'][:4]) for k, x in starred_boards.items() ], ['/cancel'] ], one_time_keyboard=True, ), ) return _CONV_STATE_SETUP_BOARD
def form(form_id, label, title): trel = Trello() conf = Confluence() """ makes form options is a dict? possible dec num of params? """ # headers: is label neccesary? form = '<form id="{}">'.format(form_id) label = '<label for="{}">{}</label>'.format(label, title) # generalize below using "for options in options_list" resp = trel.get_a_on_b(a='lists', b='boards', b_id=board_id) lists = { l['name'] : l['id'] for l in resp } html += select('trello', 'trelloList', lists) spaces = conf.get_spaces() html += select('confluence', 'confSpace', spaces) html += button('submit', 'mod-primary', 'Create Page!') # close form html += '</form>' html += '<script src="{}"></script>'.format('./js/modal.js') pprint(html) return html
def main(): colorama.init() parser = argparse.ArgumentParser( description='Convert Trello list to web page.') parser.add_argument('--board', metavar='BOARD', type=str, help='Trello board', required=True) group = parser.add_mutually_exclusive_group(required=True) group.add_argument('--list', action='store_true', help='show Trello lists') group.add_argument('--convert', metavar='LIST', type=str, help='convert Trello list') args = parser.parse_args() trello = Trello("443c66695279580563e6aee40eed2811") # Read or generate token try: trello.set_token(open(".token", "r").read()) trello.user_get("me") except Exception as e: print( "Go to", trello.get_token_url("trello-to-html"), "and authorize the application. After you have" "authorized the application you'll be given a token. Copy and paste that here", "\n") trello.set_token(input("Enter your token: ")) open(".token", "w").write(trello.get_token()) # List Trello lists if args.list: trello_lists = trello.boards_get_list_open(args.board) for trello_list in trello_lists: print(trello_list["name"]) return 0 # Convert Trello list elif args.convert is not None: trello_lists = trello.boards_get_list_open(args.board) for trello_list in trello_lists: if trello_list["name"] == args.convert: print("Converting", trello_list["name"]) trello_list = trello.list_get_cards(trello_list["id"]) generate(trello_list) return 0 else: print("No such list") return 1 return 0
def process_trello_board_conv(self, bot, update, user_data): logger.info("Got to process_trello_board") trello_token = user_data["trello_token"] chosen_board_name = update.message.text.split("(")[0].strip() chosen_board_id = update.message.text.split("(")[1].replace(")", "") trello = Trello(trello_token) starred_boards = trello.get_starred_boards() if starred_boards is None: return self.error(update, user_data, "invalid trello token") candidate_boards = [v for k, v in starred_boards.items() if chosen_board_id in k] final_board = None for candidate_board in candidate_boards: if candidate_board['name'] == chosen_board_name: final_board = candidate_board break if final_board is None: return self.error(update, user_data, "No valid board found") else: chosen_board_id = final_board['id'] chosen_board_name = final_board['name'] board_lists = trello.get_board_lists(chosen_board_id) if board_lists is None: return self.error(update, {}, "Trello token expired. Restart doing /setup and " "then saving your stuff again.") inbox_list_id = None for k, l in board_lists.items(): if l['name'] == DEFAULT_LIST_NAME: inbox_list_id = l['id'] break else: if len(board_lists.items()) > 0: inbox_list_id = [v for k, v in board_lists.items()][0]['id'] self.setup_user(tg_id=update.message.from_user.id, trello_token=trello_token, chosen_board_id=chosen_board_id, chosen_board_name=chosen_board_name, inbox_list_id=inbox_list_id) update.message.reply_text("Setup completed. You can now fully use the bot.") return ConversationHandler.END
def test_app(): trello_config = Config(".env").trello_config trello = Trello(trello_config, ApiClient()).create_test_board() application = app.create_app({}, trello) thread = Thread(target=lambda: application.run(use_reloader=False)) thread.daemon = True thread.start() # I really feel like this shouldn't be necessary, but otherwise selenium makes requests before flask has started time.sleep(1) yield app thread.join(1) trello.delete_board()
def append_card(self, update, content, card_name, list_name=None, list_id=None, content_type='text'): if (list_name is None) & (list_id is None): raise Exception("No list provided!") trello = Trello(self._USER_SETUPS[self.get_tg_id(update)]['trello_token']) if list_id is not None: list_name = DEFAULT_LIST_NAME else: board_lists = trello.get_board_lists(self._USER_SETUPS[self.get_tg_id(update)]['board_id']) if board_lists is None: return self.error(update, {}, "Trello token expired. Restart doing /setup and " "then saving your stuff again.") if list_name[0] == "_": list_name = list_name[1:] # Check if it already exists for k, l in board_lists.items(): if l['name'] == list_name: list_id = l['id'] break else: # NEW LIST! list_id = trello.create_list_in_board(list_name, self._USER_SETUPS[self.get_tg_id(update)]['board_id']) else: for k, l in board_lists.items(): if l['name'] == list_name: list_id = l['id'] break else: return self.error(update, {}, "No list found matching your choice. Restart please.") result = trello.create_card_in_list(list_id, card_name, content, content_type) logger.info("Done! Created card with ID: {}".format(result)) update.message.reply_text("Done! Put the {} into #{} as *{}".format(content_type, list_name, card_name))
def process_anything_text(bot, update, user_data): if not app.is_user_setup(update): update.message.reply_text("You are not authenticated yet. Use /setup please.") user_data.clear() return content = update.message.text content_type = 'text' if len(update.message.entities) > 0: if update.message.entities[0].type == 'url': content_type = 'url' user_data['_content'] = content user_data['_content_type'] = content_type user_data['_card_name'] = str(content)[:DEFAULT_CARD_NAME_LEN] if content_type != 'url' else content trello = Trello(app._USER_SETUPS[app.get_tg_id(update)]['trello_token']) board_lists = trello.get_board_lists(app._USER_SETUPS[app.get_tg_id(update)]['board_id']) if board_lists is None: board_lists = [] update.message.reply_text( "Where do you want to save it?", reply_markup=ReplyKeyboardMarkup( [ [ '#{list_name}'.format(list_name=l['name']) for k, l in board_lists.items() ], ['/cancel'] ], one_time_keyboard=True, ), ) return _CONV_STATE_CHOOSE_LIST
import requests as r import json as j from trello import Trello from zendesk import Zendesk trl = Trello() zd = Zendesk() def create_ticket_card(id): tk = zd.get_ticket(id) ticket_name = f"{id} - {tk['ticket']['subject']}" ticket_desc = tk['ticket']['description'] response = trl.create_card(ticket_name, ticket_desc) if response == r.codes.ok: print(f'Card do ticket {id} criado com sucesso.')
def main(list_id, space_id): trel = Trello() conf = Confluence() page = trel.format_page(list_id) # html pageData conf.create_page(page, space_key) # creates page print('\n\n\n page.py script is done!!! \n\n\n') # TEST
import sys from trello import Trello if __name__ == '__main__': try: obj = Trello() obj.login() obj.build_team() obj.create_new_board() obj.init_tasks() obj.rand_drag_all_cards() except Exception as e: print(f'{e.__class__.__name__}: {e}') sys.exit(1)
def setUp(self): self.trello = Trello(TrelloTestCase.TEST_TOKEN)
from flask import Flask, render_template, request, redirect, url_for from config import Config from trello import Trello from status import COMPLETED, IN_PROGRESS from view_model import ViewModel from api_client import ApiClient config = Config('.env') trello = Trello(config.trello_config, ApiClient()) def create_app(script_info, trello=trello): app = Flask(__name__) # Allowing POST so we don't need frontend JS @app.route('/item/<id>/mark-completed', methods=['PUT', 'POST']) def mark_completed(id): trello.set_status(id, COMPLETED) return redirect('/') @app.route('/item/<id>/start-item', methods=['PUT', 'POST']) def start_item(id): trello.set_status(id, IN_PROGRESS) return redirect('/') @app.route('/item/<id>/delete', methods=['DELETE', 'POST']) def delete(id): item = trello.delete_item(id) return redirect('/') @app.route('/item/add', methods=['POST']) def add_item():
# main script to make Conf page from Trello list from trello import Trello from confluence import Confluence if __name__ == "__main__": t = Trello() conf = Confluence() conf.create_page(t.mmain()) print('main sript done!')
} # Get the options parser = ArgumentParser(description='Manage Josue''s Trello cards') parser.add_argument('-d', '--directory', default='.', help='Directory to check for files (default is the current directory)') parser.add_argument('-l', '--language', default='es', help='Language to be used for the card (default = "es")') parser.add_argument('NAME', help='The card name') args = parser.parse_args() directory = args.directory language = args.language.upper() name = args.NAME # Get the card description if not path.exists(directory): exit('No se encontró el directorio {}'.format(directory)) files = '\n'.join(['- ' + f for f in listdir(directory)]) description = '{}:\n{}'.format(LABELS[language], files) # Create the card configFile = '{}/.config/trllmgr/josue.yml'.format(str(Path.home())) config = safe_load(open(configFile)) listId = config['board']['lists'][language] trll = Trello(config['security']['key'], config['security']['token']) response = trll.addCard(listId, name, description).json() print(response)