Example #1
0
def main():
    args = parse_args()
    task = ' '.join(args.task)
    if args.test:
        print("Task={}\nDue={}".format(task, args.due))
    else:
        user = todoist.login_with_api_token(TOKEN)
        inbox = user.get_project('Inbox')
        task = inbox.add_task(task, date=args.due)
Example #2
0
def main():
    API_TOKEN = get_token()
    if not API_TOKEN:
        print "Please set the API token in environment variable."
        exit()
    user = todoist.login_with_api_token(API_TOKEN)
    movies = user.get_project(MOVIES_PROJECT)
    tasks = movies.get_tasks()
    add_details(tasks)
Example #3
0
def main():
    args = parse_args()
    task = ' '.join(args.task)
    if args.test:
        print("Task={}\nDue={}".format(task, args.due))
    else:
        user = todoist.login_with_api_token(TOKEN)
        inbox = user.get_project('Inbox')
        task = inbox.add_task(task, date=args.due)
Example #4
0
 def __init__(self):
     try:
         with open(TODOIST_PATH, 'rb') as f:
             self.token = pickle.load(f)
     except:
         self.token=getpass('API_Token>>')
         with open(TODOIST_PATH, 'wb') as f:
             pickle.dump(self.token , f)
     self.user = todoist.login_with_api_token(self.token)
     self.works = self.user.get_project('homework')
Example #5
0
    def __init__(self):

        self.selectedProject = Observable(None)
        self._api_token = 'c37ac7d6aaf139372705b239f73855c29728e088'
        self._user = todoist.login_with_api_token(self._api_token)

        self.projects = Observable([])

        self.releventProjects = Observable([])
        
        self.refreshData()
Example #6
0
def todoist_login(apiKey, _times=0):
    """
  A workaround for https://github.com/Garee/pytodoist/issues/12
  """
    try:
        return todoist.login_with_api_token(apiKey)
    except KeyError:
        if _times >= 10:
            raise Exception(
                'Unable to login to Todoist. (Got a KeyError 10 times!) Please try again.'
            )
        else:
            # Ignore it and try again
            return todoist_login(apiKey, _times=_times + 1)
Example #7
0
def main():
    API_TOKEN = get_token()
    if not API_TOKEN:
        logging.warn('Please set the API token in environment variable.')
        exit()
    user = todoist.login_with_api_token(API_TOKEN)
    tasks = user.search_tasks(todoist.Query.TODAY)
    for task in tasks:
        habit = is_habit(task.content)
        if habit:
            streak = int(habit.group(1)) + 1
            update_streak(task, streak)

    tasks = user.search_tasks(todoist.Query.OVERDUE)
    for task in tasks:
        habit = is_habit(task.content)
        if habit:
            task.date_string = 'ev day starting tod'
            update_streak(task, 0)
Example #8
0
def main():
    tw_cli = taskw.TaskWarrior()
    ti_cli = todoist.login_with_api_token(TODOIST_API_TOKEN)

    ti_tasks = ti_cli.get_tasks()
    tw_tasks = tw_cli.load_tasks()

    # NOTE: todoist only returns uncompleted tasks whereas taskwarrier returns
    # all

    for ti_task in ti_tasks:
        if ti_task.project.name in SKIP_TODOIST_PROJECT_NAMES:
            continue

        if not ti_task_synced_to_tw(ti_task=ti_task):
            create_tw_task(ti_task=ti_task, tw_cli=tw_cli)

    for tw_task in tw_tasks['pending']:
        if not tw_task_synced_to_ti(tw_task=tw_task):
            create_ti_task(tw_task=tw_task, ti_cli=ti_cli)
        else:
            # check if task has been marked completed on todoist by seeing if
            # it's in the list returned from todoist
            sync_rec = TodoistTaskWarrierSyncModel.get(
                taskwarrier=tw_task['uuid'])
            if not sync_rec.completed:
                ti_id = sync_rec.todoist
                if not ti_id in map(lambda t: t.id, ti_tasks):
                    mark_tw_task_complete(tw_task=tw_task, tw_cli=tw_cli)
                sync_rec.update(completed=True)

    for tw_task in tw_tasks['completed']:
        if tw_task_synced_to_ti(tw_task=tw_task):
            sync_rec = TodoistTaskWarrierSyncModel.get(
                taskwarrier=tw_task['uuid'])
            if not sync_rec.completed:
                ti_id = sync_rec.todoist
                mark_ti_task_complete(ti_id=ti_id,
                                      ti_tasks=ti_tasks,
                                      tw_task=tw_task)
                sync_rec.update(completed=True)
Example #9
0
def main():
    API_TOKEN = get_token()
    today = datetime.utcnow().replace(tzinfo=None)

    if not API_TOKEN:
        logging.warn('Please set the API token in environment variable.')
        exit()

    user = todoist.login_with_api_token(API_TOKEN)
    #Check for Completion
    tasks = user.search_tasks(todoist.Query.TODAY)
    for task in tasks:
        print(task.content)
        habit = is_habit(task.content)
        if habit:
            streak = int(habit.group(1)) + 1
            update_streak(task, streak)

    #Check for Overdue
    tasks = user.get_tasks()
    for task in tasks:

        content = task.content
        habit = is_habit(content)
        if habit:
            due = datetime.strptime(
                task.due_date_utc,
                '%a %d %b %Y %H:%M:%S %z').replace(tzinfo=None)
            complete = task.checked
            #print(content)
            #print(due)
            #print(today)
            #print(complete)

            if today > due and complete == 0:
                task.date_string = 'ev day starting tod'
                update_streak(task, 0)
Example #10
0
def add_task(request):
    sender = request.values.get('From')
    body = request.values.get('Body')

    user = todoist.login_with_api_token(TODOIST_API_KEY)
    project = user.get_project(TODOIST_PROJECT)

    if body.startswith("!!"):
        priority = todoist.Priority.VERY_HIGH
        text = body[2:].lstrip()
    elif body.startswith("!"):
        priority = todoist.Priority.HIGH
        text = body[1:].lstrip()
    else:
        priority = todoist.Priority.LOW
        text = body

    task = project.add_task(text, priority=priority)

    # Respond to confirm
    resp = MessagingResponse()
    resp.message("Thanks, your task has been added to %s" % project.name)

    return str(resp), 200, {'Content-Type': 'application/xml'}
Example #11
0
 def test_login_with_api_token_success(self):
     todoist.login_with_api_token(self.user.api_token)
Example #12
0
 def test_login_with_api_token_failure(self):
     with self.assertRaises(todoist.RequestError):
         todoist.login_with_api_token('')
Example #13
0
 def test_login_with_api_token_success(self):
     todoist.login_with_api_token(self.user.api_token)
Example #14
0
def login():
    return todoist.login_with_api_token(os.environ['TODOIST_API_TOKEN'])
Example #15
0
####################################################################
# Command line arguments
####################################################################
parser = argparse.ArgumentParser(description="Automate Todoist workflows.")
parser.add_argument("--loglevel", dest="loglevel", nargs=1, help="set a log level")
args = parser.parse_args()

# If the user specified a log level, use it.
if args.loglevel is not None:
    loglevel, *rest = args.loglevel
    ch.setLevel(loglevel.upper())
# Register the console handler with the logger.
logger.addHandler(ch)

# Setup.
user = todoist.login_with_api_token(API_TOKEN)
logger.info("Logged in to Todoist.")
q = JobQueue(logger=logger)

# Load the config.
with open(CONFIG_DIR / "config.yml") as f:
    conf = yaml.load(f, Loader=yaml.SafeLoader)
# Add the environment variables to the config dict.
conf["email_addr"] = EMAIL_ADDR
conf["email_pw"] = EMAIL_PW
conf["api_token"] = API_TOKEN
logger.debug("Loaded config file.")

###############################################################################
# Add jobs from the jobs.py file.
###############################################################################
Example #16
0
from pytodoist import todoist

from todoisthelper.template import TemplateFactory


TEMPLATE_FILE = "C:\\Users\\TDARSEY\\Desktop\\Personal Projects\\" \
                "TodoistHelper\\templates\\template.txt"

parent_project_NAME = "Test"

API_KEY = "c37ac7d6aaf139372705b239f73855c29728e088"

if __name__ == '__main__':

    params = {}
    params['icode'] = raw_input("Inventory Code: ")
    params['program_name'] = raw_input("Program Name: ")
    params['crnum'] = raw_input("Change Request Number: ")
    params['desc'] = raw_input("Change Description: ")

    my_template = TemplateFactory.loadFile(TEMPLATE_FILE, **params)

    my_template.formatAttributes()

    user = todoist.login_with_api_token(API_KEY)
    parent_project = user.get_project(parent_project_NAME)
    my_template.createProject(user = user,
                              parent_project = parent_project)

    print "Project Created"
Example #17
0
from pytodoist import todoist

user = todoist.login_with_api_token('b646e8b461ef6be694d697ccba93da90674f4fcf')
print(user.email)
Example #18
0
 def test_login_with_api_token_failure(self):
     with self.assertRaises(todoist.RequestError):
         todoist.login_with_api_token('')
Example #19
0
from pytodoist import todoist
import os
import sys

# to make this work: add the token api from todoist in ~/.todoistToken

defaultProject = "Inbox"

with open(os.path.expanduser("~/.todoistToken"), "r") as f:
    token = f.readlines()[0].replace("\n", "")

user = todoist.login_with_api_token(token)

project = user.get_project(defaultProject)

taskName = " ".join(sys.argv[1:])
task = project.add_task(taskName)
Example #20
0
 def test_login_with_api_token_success(self):
     user = todoist.login_with_api_token(self.user.api_token)
     self.assertTrue(user.is_logged_in())