def __init__(self, config): self.config = config self.app_key = self.config.get_app_key() self.app_token = self.config.get_app_token() self.board_id = self.config.get_boardid() self.trello = trello.TrelloApi(self.app_key) self.trello.set_token(self.app_token) self.trello_boards = trello.Boards(self.app_key, self.app_token) # We map Trello lists into Munki catalogs # # Each Munki Catalog will have multiple lists: # * a 'To' list # * Either: # * a list representing the munki catalog # * a dated set of lists representing the munki catalog # self.catalog_lists = None self.list_id_catalog = None self.trello_id_list = None self.trello_name_list = None self.cards = None # List ... currently
def main(): parser = argparse.ArgumentParser() parser.add_argument('-k', '--key', help='trello member key') parser.add_argument('-t', '--token', help='trello security token') parser.add_argument('-b', '--board', help='the board ID of the Trello board to sync to') parser.add_argument('-v', '--verbose', help='print verbose logs', action='store_true') command = parser.add_subparsers() fetch_command = command.add_parser('fetch') fetch_command.set_defaults(func=fetch_board) update_command = command.add_parser('update') update_command.set_defaults(func=update_board) update_command.add_argument('-f', '--filename', help='full path of the YAML file to sync') mock_command = command.add_parser('mock') mock_command.set_defaults(func=mock) args = parser.parse_args(sys.argv[1:]) logging.basicConfig( stream=sys.stderr, format='%(asctime)s | %(levelname)-8.8s | %(message).10000s', datefmt='%Y/%m/%d %H:%M:%S', level=logging.DEBUG if args.verbose else logging.INFO) load_configuration_file( os.path.join(os.getenv('HOME'), DEFAULT_CONFIG_FILENAME), args) args.client = trello.TrelloApi(apikey=args.key, token=args.token) args.func(args)
def __init__(self, board_id, list_name): self.board_id = board_id self.list_name = list_name self.trelo = trello.TrelloApi( apikey='40b1ba0b3506b70fdd24fe3654697479' ) self.trelo.set_token( token='1546d5ce710fe94801d36df875313fc4e3aa78a5a5e5cca3c811ca232356dc4a' ) self.list_id = self._get_list_id()
def pytest_configure(config): ''' Validate --trello-* parameters. ''' log.debug("pytest_configure() called") # Add marker config.addinivalue_line("markers", """trello(*cards): Trello card integration""") # Sanitize key and token trello_cfg_file = config.getoption('trello_cfg_file') trello_api_key = config.getoption('trello_api_key') trello_api_token = config.getoption('trello_api_token') trello_completed = config.getoption('trello_completed') # If not --help or --collectonly or --showfixtures ... if not (config.option.help or config.option.collectonly or config.option.showfixtures): # Warn if file does not exist if not os.path.isfile(trello_cfg_file): errstr = "No trello configuration file found matching: %s" % trello_cfg_file log.warning(errstr) # Load configuration file ... if os.path.isfile(trello_cfg_file): trello_cfg = yaml.load(open(trello_cfg_file, 'r')) try: trello_cfg = trello_cfg.get('trello', {}) except AttributeError: trello_cfg = {} errstr = "No trello configuration found in file: %s" % trello_cfg_file log.warning(errstr) if trello_api_key is None: trello_api_key = trello_cfg.get('key', None) if trello_api_token is None: trello_api_token = trello_cfg.get('token', None) if trello_completed is None or trello_completed == []: trello_completed = trello_cfg.get('completed', []) # Initialize trello api connection api = trello.TrelloApi(trello_api_key, trello_api_token) # If completed is still empty, load default ... if trello_completed is None or trello_completed == []: trello_completed = DEFAULT_TRELLO_COMPLETED # Register pytest plugin assert config.pluginmanager.register( TrelloPytestPlugin(api, completed_lists=trello_completed), 'trello_helper' )
def get_connection(): ''' Connect to the trello API and return a TrelloApi instance. If no ``.trello_api_key`` or ``.trello_token`` exist, ask the user for their api key/token and create the missing files. ''' try: logger.debug('Reading api key...') with open(os.environ.get('TRELLO_API_KEY', '.trello_api_key')) as f: key = f.readline().strip() except FileNotFoundError: print('Get your Trello API key here: https://trello.com/app-key') with open(os.environ.get('TRELLO_API_KEY', '.trello_api_key'), 'w') as f: key = input('Please input your Trello api key: ') f.write(key) finally: api = trello.TrelloApi(key) logger.debug('api key OK') try: logger.debug('Reading token...') with open(os.environ.get('TRELLO_TOKEN', '.trello_token')) as f: token = f.readline().strip() except FileNotFoundError: url = api.get_token_url('Thing Doer', expires='30days', write_access=True) print('Get your Trello token here: {}'.format(url)) with open(os.environ.get('TRELLO_TOKEN', '.trello_token'), 'w') as f: token = input('Please input your Trello token: ') f.write(token) finally: api = trello.TrelloApi(key, token) logger.info('token OK') return api
class TrelloApi(object): api = trello.TrelloApi( 'c381956e52fa72621677b692064051df', 'bc0d96b75ac6a07aacc2872f1f9898c3cac7981855c8b5c1dff165a98c3ce05c') def post_pedidos(self): with urllib.request.urlopen( "https://api-loja-virtual.herokuapp.com/pedidos/") as url: pedidos = json.loads(url.read().decode()) for p in pedidos: descricao = json.dumps(p, indent=4) self.api.cards.new(name='Pedido {}'.format(p.get('id')), idList='5b03fc922eb84b18fa9b3f00', desc='Produtos {}'.format(descricao)) def get_status_pedido(self): return 'Status'
def main(board_id, dry_run, raw_lists): print "This will reset all points on your board with (0). Please be careful." if dry_run: print "NOTHING IS BEING CHANGED NOW. THIS IS DRY RUN. RUN WITH --4-real IF YOU WANT TO CHANGE ANYTHING." lists_to_use = map(lambda x: x.lower().strip(), raw_lists) trello_api = trello.TrelloApi(apikey=KEY, token=TOKEN) lists = trello_api.boards.get_list(board_id) list_ids_to_use = map(lambda x: x['id'], filter(lambda x: x['name'].lower() in lists_to_use, lists)) cards_from_board = trello_api.boards.get_card(board_id) compiled = re.compile(REGEX_SCORE) for card in filter(lambda x: x['idList'] in list_ids_to_use, cards_from_board): matches = re.match(compiled, card['name']) if matches: print 'Reseting: {}'.format(card['name']) if dry_run is False: card_new_name = re.sub(compiled, '(0)', card['name']) trello_api.cards.update(card['id'], card_new_name) else: print 'Ignoring: {}'.format(card['name'])
def main(): "main" trello = tr.TrelloApi(secrets.apikey, secrets.token) columns = trello.boards.get_list(BOARD_ID) cards = trello.boards.get_card(BOARD_ID) owned = collections.defaultdict(list) names = {} for member in trello.boards.get_member(BOARD_ID): names[member["id"]] = member["fullName"] for card in cards: columnId = card["idList"] game = card_info(card, names) owned[columnId].append(game) for column in columns: columnName = column["name"] columnId = column["id"] print columnName print "-" * len(columnName) print "\n".join(owned[columnId]) print
def initTrello(cmdLineOptions): """Return a trelloApi that has the token set. If no token provided, output token URL. Also check required arguments are present""" requiredOptions = {'trelloUser', 'trelloBoard', 'trelloList'} print 'Setting up Trello (trello v(0.9.1))...' if 'trelloID' in cmdLineOptions: trelloApi = trello.TrelloApi(cmdLineOptions['trelloID']) else: print "ERROR: No trelloID specified" sys.exit() if 'trelloToken' not in cmdLineOptions: url = trelloApi.get_token_url("Rally Integration") print "ERROR: trelloToken required: Token URL: '{}'".format(url) sys.exit() if not requiredOptions.issubset(cmdLineOptions): print "ERROR: One of more of the required Trello options ({}) missing.".format(requiredOptions) sys.exit() trelloApi.set_token(cmdLineOptions['trelloToken']) return trelloApi
def __init__(self): """ Initilize the Base CMTS Class. Class Properties Should be set in Child Class Args: fqdn (string): hostname or fqdn """ logging.info('Creating Trello Object and Instantiating API') logging.info(CONFIGS.TRELLO_APP_KEY) logging.info(CONFIGS.TRELLO_APP_TOKEN) self.trello_api =\ trello.TrelloApi(apikey=CONFIGS.TRELLO_APP_KEY) self.trello_api.set_token(CONFIGS.TRELLO_APP_TOKEN) self.known_boards = { '56e1cbce8bde063d47d1db02': 'To Do List', } self.board = None self.lists = None self.cards = None
import trello from slacker import Slacker import datetime import dateutil.parser import pytz # API keys: trello_key = # trello key trello_token = # trello token slack_key = # slack key # trello things trello_board_id = #'Main' board trello = trello.TrelloApi(trello_key, token=trello_token) # function to post daily tasks to Slack # takes list of tuples (task_string, task_time) def slackPost(task_list): # Slack setup slack_channel = # Slack channel or message "#channel_name" or "@message_recipient" slack_bot_name = # name of Slack bot (string) # create a Slack object slack = Slacker(slack_key) #print header slack.chat.post_message(slack_channel, 'Here are your tasks for today!', username=slack_bot_name) for task in task_list: slack.chat.post_message(slack_channel, format(task), username=slack_bot_name) # function to format a list [task_string, task_time] # ex: 00:00 AM/PM - Title of Task def format(task): task_string = task[0]
run_command('make install') os.chdir('..') ######################################## Dependencies of both run_command('apt-get update') run_command('apt-get install git supervisor') ######################################## Oscar itself os.chdir('/var') run_command('git clone https://github.com/danslimmon/oscar.git') os.chdir('/var/oscar/web') run_command('npm install') ######################################## Create the appropriate Trello lists import trello trello_api = trello.TrelloApi(trello_app_key) trello_api.set_token(trello_token) # Grocery list trello_api.boards.new_list(trello_grocery_board, 'Groceries') # oscar_db lists for db_list in [ 'description_rules', 'barcode_rules', 'learning_opportunities' ]: trello_api.boards.new_list(trello_db_board, db_list) ######################################## Create the default description rules new_rules = [ { 'search_term': 'coffee', 'item': 'coffee' },
grocery_list = [ x for x in all_lists if x['name'] == conf.get()['trello_grocery_list'] ][0] cards = trello_api.lists.get_card(grocery_list['id']) card_names = [card['name'] for card in cards] # Add item if it's not there already if item not in card_names: print "Adding '{0}' to grocery list".format(item) trello_api.lists.new_card(grocery_list['id'], item) else: print "Item '{0}' is already on the grocery list; not adding".format( item) trello_api = trello.TrelloApi(conf.get()['trello_app_key']) trello_api.set_token(conf.get()['trello_token']) trello_db = trellodb.TrelloDB(trello_api, conf.get()['trello_db_board']) f = open(conf.get()['scanner_device'], 'rb') while True: print 'Waiting for scanner data' # Wait for binary data from the scanner and then read it scan_complete = False scanner_data = '' while True: rlist, _wlist, _elist = select.select([f], [], [], 0.1) if rlist != []: new_data = '' while not new_data.endswith('\x01\x00\x1c\x00\x01\x00\x00\x00'):
def __init__(self): self.trello = trello.TrelloApi(TRELLO_APP_KEY) self.board_id, token = self.get_board_token() self.trello.set_token(token)
def __init__(self, key, token, boardId): self.boardId = boardId self.client = trello.TrelloApi(key, token=token)
TO_DEV_LIST = opts.to_dev_list DEV_LIST = opts.dev_list TO_TEST_LIST = opts.to_test_list TEST_LIST = opts.test_list TO_PROD_LIST = opts.to_prod_list DEV_CATALOG = opts.dev_catalog TEST_CATALOG = opts.test_catalog PROD_CATALOG = opts.prod_catalog PRODUCTION_SUFFIX = opts.suffix MUNKI_PATH = opts.repo_path MAKECATALOGS = opts.makecatalogs if not os.path.exists(MUNKI_PATH): fail('Munki path not accessible') trello = trellomodule.TrelloApi(KEY) trello.set_token(TOKEN) lists = trello.boards.get_list(BOARD_ID) for list in lists: if list['name'] == TO_DEV_LIST: to_dev_id = list['id'] if list['name'] == DEV_LIST: dev_id = list['id'] if list['name'] == TEST_LIST: test_id = list['id']
import csv, pyral, trello, getpass, requests, urllib from urllib import quote_plus DEBUG_OUTPUT = True TRELLO_ID = "984edd6395e2c74b5a35ffec6400be0b" print "Connecting to Trello (with ID '{}')...".format(TRELLO_ID) trelloApi = trello.TrelloApi(TRELLO_ID) TRELLO_USER = "******" TRELLO_TOKEN = "" TRELLO_BOARD = "" TRELLO_LIST = "" def get_token_url(app_name, expires='30days', write_access=True): return 'https://trello.com/1/authorize?key=%s&name=%s&expiration=%s&response_type=token&scope=%s' % ( TRELLO_ID, quote_plus(app_name), expires, 'read,write,account' if write_access else 'read') #Trello: Get token to use #url = trelloApi.get_token_url("Rally Integration") #Cant use this as additional scope (account) is needed to view e-mail #url = get_token_url("Rally Integration") #print "Token URL: '{}'".format(url) trelloApi.set_token(TRELLO_TOKEN) boards = trello.Members(TRELLO_ID, TRELLO_TOKEN).get_board(TRELLO_USER) testBoard = [board for board in boards if board['name'] == TRELLO_BOARD][0] boardList = [ list for list in trello.Boards(TRELLO_ID, TRELLO_TOKEN).get_list(
educe_group = arg_parser.add_argument_group('corpus filtering arguments') util.add_corpus_filters(educe_group, fields=['doc']) args = arg_parser.parse_args() args.subdoc = None args.stage = 'unannotated' args.annotator = None is_interesting = util.mk_is_interesting(args) # --------------------------------------------------------------------- # main # --------------------------------------------------------------------- reader = educe.stac.Reader(args.idir) anno_files = reader.filter(reader.files(), is_interesting) trello = tr.TrelloApi(secrets.apikey, secrets.token) board = trello.boards.get(board_id) columns = trello.boards.get_list(board_id) cards = trello.boards.get_card(board_id) subdocs = collections.defaultdict(list) for k in anno_files: subdocs[k.doc].append(k.subdoc) for d in subdocs: subdocs[d] = sorted(subdocs[d]) annotated_ = filter(lambda x: x['name'] == 'Annotated', columns) if not annotated_: raise Exception("Can't find the annotated column") annotated_id = annotated_[0]['id'] # ensure that each document is associated with a card