def create_milkinfo(): """Ask some questions and create a ".milk.info" file with the needed API key, secret and eventually the token. """ milk_key = raw_input("What is your Remember The Milk (RTM) api key? ") milk_sec = raw_input("And what is your RTM secret? ") print "Okay, we're going to generate a token based on your key and secret" mh = rtm.createRTM(milk_key, milk_sec) milk_toc = mh.authInfo.data['token'] # We can actually do some more initialization now lists = mh.lists.getList() ll = [ l for l in lists.lists.list if l.name == 'TrackTime' ] if ll: tt_list = ll[0] else: timeline = mh.timelines.create() tt_list = mh.lists.add(timeline=timeline.timeline, name='TrackTime') milk_lid = tt_list.id try: fh = open('%s%s.milk.info' % (REL_DIR, os.sep), 'w') fh.write('milk_key=%s\nmilk_sec=%s\nmilk_toc=%s\nmilk_lid=%s\n' % (milk_key, milk_sec, milk_toc, milk_lid)) fh.close() except (Exception), e: print 'Error: Could not writeout the .milk.info file: %s' % (str(e))
def main(args): init_logger(level=args.log_level.upper()) GITHUB_ACCESS_TOKEN = os.environ.get('GITHUB_ACCESS_TOKEN', None) if GITHUB_ACCESS_TOKEN is None: print("Missing GITHUB_ACCESS_TOKEN!", file=sys.stderr) sys.exit(1) RTM_API_KEY = os.environ.get('RTM_API_KEY', None) RTM_SHARED_SECRET = os.environ.get('RTM_SHARED_SECRET', None) RTM_TOKEN = os.environ.get('RTM_TOKEN', None) if None in (RTM_API_KEY, RTM_SHARED_SECRET, RTM_TOKEN): print("Missing RTM_API_KEY, RTM_SHARED_SECRET or RTM_TOKEN!", file=sys.stderr) sys.exit(1) log = get_logger() log = log.bind(component="main") log.info("gh.init") gh = github.GitHub(access_token=GITHUB_ACCESS_TOKEN) log.info("gh.get_issues") issues = get_github_issues(gh, GITHUB_ISSUE_QUERIES) log.info("rtm.init") rtm = createRTM(RTM_API_KEY, RTM_SHARED_SECRET, RTM_TOKEN) log.info("complete_missing_issues.start") complete_missing_issues(rtm, issues) log.info("complete_missing_issues.finish") log.info("add_new_issues.start") add_new_issues(rtm, issues) log.info("add_new_issues.finish")
def get_task(list_id, series_id, task_id): rtm = createRTM(secret.API_KEY, secret.SHARED_SECRET, secret.TOKEN) rspTasks = rtm.tasks.getList() tasks = [] if hasattr(rspTasks.tasks, "list") and \ hasattr(rspTasks.tasks.list, "__getitem__"): for l in rspTasks.tasks.list: # XXX: taskseries *may* be a list if not hasattr(l, "taskseries"): continue if isinstance(l.taskseries, (list, tuple)): for taskserie in l.taskseries: if isinstance(taskserie.task, (list, tuple)): for task in taskserie.task: t = Task(rtm, l, taskserie, task) if t.list_id == list_id and t.series_id == series_id and t.id == task_id: return t else: t = Task(rtm, l, taskserie) if t.list_id == list_id and t.series_id == series_id and t.id == task_id: return t else: t = Task(rtm, l, l.taskseries) if t.list_id == list_id and t.series_id == series_id and t.id == task_id: return t return None
def runTest(self): """""" import rtm rtm2 = rtm.createRTM(apiKey='fe049e2cec86568f3d79c964d4a45f5c', secret='b57757de51f7e919', token=None) get_all_tasks(rtm2)
def sendToRTM (token, task, audioPath): apiKey='yourApiKey' secret='yourSecret' try: rtm = createRTM(apiKey, secret, token) except Exception,e: return {'name': 'error', 'errVal': str(e)}
def api(self, token=None, test_login=True): """Create RTM api client and test login.""" # pylint: disable=no-member if token is None: token = self.token api = rtm.createRTM(self.key, self.secret, token) if test_login: api.test.login() return api
def __init__(self, token): self.token = token apik = 'e282189b97ed465ba34b5bc000543065' secret = 'b68702a7f207244c' if not token: raise ValueError('Error: Need token configured') else: self.rtm = createRTM(apik, secret, token) self._active_list_name = False self.active_task_id = 0 self.lists = {} self._list_names = [] self.buffer_create()
def main(): rtm = createRTM(API_KEY, SECRET ,"e2a5a534409b85f87d8767616f7340bebaf86676") # print "\n".join([eval("u'%s'"%mylist.name) for mylist in rtm.lists.getList().lists.list]) print """ <table> <tr> <th> </th> <th align="left">Task</th> <th align="left">Has due time</th> </tr> """ for task in getTasks(rtm): print item_html(*task) print "</table>"
def main(api_key, secret): token = None try: f = open('rtm.dat') token = pickle.load(f) except: None rtm = createRTM(api_key, secret, token) if token == None: token = rtm.getToken() f = open('rtm.dat','w') pickle.dump(token,f) loaddata(rtm)
def get_date(date): rtm = createRTM(secret.API_KEY, secret.SHARED_SECRET, secret.TOKEN) rspTasks = rtm.tasks.getList(filter='due:' + date) tasks = [] if hasattr(rspTasks.tasks, "list") and \ hasattr(rspTasks.tasks.list, "__getitem__"): for l in rspTasks.tasks.list: # XXX: taskseries *may* be a list if isinstance(l.taskseries, (list, tuple)): for t in l.taskseries: tasks.append(Task(rtm, l, t)) else: tasks.append(Task(rtm, l, l.taskseries)) return tasks
def test(apiKey, secret, token=None): rtm = createRTM(apiKey, secret, token) stats(rtm)
import rtm # TODO: jlevine - Squash this commit and all the previous stupid Markdown issue commits together. # I should be embarrassed. # TODO: jlevine - Maybe find a way to get these constants dynamically from the user on the command-line. APIKEY = '#########################' SHARED_SECRET = '####################' TOKEN = '#######################' # TODO; jlevine - Move each section into a function. if __name__ == '__main__': my_rtm = rtm.createRTM(APIKEY, SHARED_SECRET, TOKEN) time = my_rtm.timelines.create() # TODO: jlevine - Maybe use dotted-map for consistency with RTM API. general_filter = 'list:important_can_do OR list:not_important_but_due OR list:somewhat_important_can_do' list_5_error_filter = """ NOT ( list:0_due_soon OR list:1_urgent_important OR list:2_urgent OR list:3_important OR list:4_somewhat_important OR list:not_important OR location:waiting ) """ smart_smartlists = [ {'name': 'important', 'filter': 'tag:iu OR tag:inu'}, {'name': 'not_important', 'filter': 'tag:niu OR tag:ninu'}, {'name': 'somewhat_important', 'filter': 'tag:siu OR tag:sinu'}, {'name': 'due_now', 'filter': 'dueBefore:tomorrow'},
import rtm # TODO: jlevine - Squash this commit and all the previous stupid Markdown issue commits together. # I should be embarrassed. # TODO: jlevine - Maybe find a way to get these constants dynamically from the user on the command-line. APIKEY = '#########################' SHARED_SECRET = '####################' TOKEN = '#######################' # TODO; jlevine - Move each section into a function. if __name__ == '__main__': my_rtm = rtm.createRTM(APIKEY, SHARED_SECRET, TOKEN) time = my_rtm.timelines.create() # TODO: jlevine - Maybe use dotted-map for consistency with RTM API. general_filter = 'list:important_can_do OR list:not_important_but_due OR list:somewhat_important_can_do' list_5_error_filter = """ NOT ( list:0_due_soon OR list:1_urgent_important OR list:2_urgent OR list:3_important OR list:4_somewhat_important OR list:not_important OR location:waiting ) """ smart_smartlists = [{ 'name': 'important', 'filter': 'tag:iu OR tag:inu' }, { 'name': 'not_important',
def test(apiKey, secret, token=None): rtm = createRTM(apiKey, secret, token) createApp(rtm)
def main(args): init_logger(level=args.log_level.upper()) with open(args.config, 'r') as f: config = yaml.safe_load(f) log = get_logger() rtm = createRTM(config['rtm']['api_key'], config['rtm']['shared_secret'], config['rtm']['token']) tags = ["imap2rtm"] + config["rtm"].get('extra_tags', []) imap = new_imap_connection( log=log, host=config['imap']['host'], port=config['imap'].get('port', 143), legacy_ssl=config['imap'].get('legacy_ssl', False), username=config['imap']['username'], password=config['imap']['password'], ) messages = get_messages(log, imap, config['imap']['folder']) tasks = get_tasks(log, rtm, list=config['rtm']['list'], tags=tags) message_set = set(messages.keys()) task_set = set(tasks.keys()) now = datetime.datetime.now() tomorrow = now + datetime.timedelta(days=1) not_in_rtm = message_set.difference(task_set) not_in_imap = task_set.difference(message_set) timeline = rtm.timelines.create().timeline for title in not_in_rtm: log.info("Adding task", title=title) task = rtm.tasks.add( timeline=timeline, list_id=config['rtm']['list'], name=title, parse=0 ) log.debug("Applying tags", task=title, tags=tags) rtm.tasks.setTags( timeline=timeline, list_id=config['rtm']['list'], taskseries_id=task.list.taskseries.id, task_id=task.list.taskseries.task.id, tags=tags ) log.debug("Setting due date", task=title) rtm.tasks.setDueDate( timeline=timeline, list_id=config['rtm']['list'], taskseries_id=task.list.taskseries.id, task_id=task.list.taskseries.task.id, due=tomorrow.isoformat(), has_due_time=True, parse=False, ) for title in not_in_imap: log.info("Marking task completed", task=title) task = tasks[title] rtm.tasks.complete( timeline=timeline, list_id=config['rtm']['list'], taskseries_id=task.id, task_id=task.task.id )
def add(string): rtm = createRTM(secret.API_KEY, secret.SHARED_SECRET, secret.TOKEN) time = rtm.timelines.create() rtm.tasks.add(timeline=time.timeline, name=string, parse=1) return
def create_rtm(): token = config.get(ck.KEY_RTM_TOKEN) return rtm.createRTM(apikey, secret, token)
def init_auth(): api = rtm.createRTM(apikey, secret, token=None) config.put(ck.KEY_RTM_AUTH_INPROGRESS, True) config.put(ck.KEY_RTM_FROB, api.getFrob()) config.put(ck.KEY_RTM_AUTH_STARTED, mktime(datetime.now().timetuple())) call(['open', api.getAuthURL()])
line += ' #%s' % (task.tags.tag) print line if task.notes and human: for i, note in enumerate(task.notes.note): print ' Note(%d): %s' % (i, getattr(note, '$t')) if __name__ == "__main__": # Get necessary auth information for RTM... or first time generate it. milk_key, milk_sec, milk_toc, milk_lid = init() if not milk_key: create_milkinfo() milk_key, milk_sec, milk_toc, milk_lid = init() # Create a milk handle (mh) for the RTM operations mh = rtm.createRTM(milk_key, milk_sec, token=milk_toc) # Add - [epoch, task, minutes, title] USAGE = """Usage: milk.py add|update|complete|uncomplete project duedate minutes title milk.py list|extract milk.py init""" try: # single argument commands if sys.argv[1] == "list": printtodos(mh, milk_lid) sys.exit(0) elif sys.argv[1] == "extract": printtodos(mh, milk_lid, human=False) sys.exit(0) elif sys.argv[1] == "init": create_milkinfo()
def auth(): """first time auth with RTM""" moo = rtm.createRTM(API_KEY, API_SECRET, token=None) print 'Allow tasktwit access: ', moo.getAuthURL() raw_input('Press enter once you gave access') return moo.getToken()
def end_auth(): api = rtm.createRTM(apikey, secret, token=None) api.setFrob(config.get(ck.KEY_RTM_FROB)) token = api.getToken() config.put(ck.KEY_RTM_TOKEN, token) config.put(ck.KEY_RTM_AUTH_INPROGRESS, False)
def test(apiKey, secret, token=None): rtm = createRTM(apiKey, secret, token) # call createApp and send above as arguments createApp(rtm)
def test(taskName_test, apiKey, secret, token=None): rtm = createRTM(apiKey, secret, token) # calls createApp createApp(rtm, taskName_test)
def __init__(self, apiKey, secret, token=None): self.rtm = createRTM(apiKey, secret, token)
def runTest(self): """""" import rtm rtm2 = rtm.createRTM(apiKey='fe049e2cec86568f3d79c964d4a45f5c',secret='b57757de51f7e919',token=None) get_all_tasks(rtm2)