Exemple #1
0
def verifyTaskAdded():
    # Login with the Any.Do credentials
    anyDoUsername = os.environ.get( 'ANY_DO_USERNAME', '' )
    anyDoPassword = os.environ.get( 'ANY_DO_PASSWORD', '' )
    api = AnyDoAPI( username=anyDoUsername, password=anyDoPassword )

    # Cycle through all tasks and verify that the required task exists
    for task in api.get_all_tasks():
        if task[ 'title' ] == ideal_payload[ 'task_name' ]:
            return True
    return False
Exemple #2
0
    def __init__(self):
        ANYDO_CREDENTIALS_PATH = 'data/anydo_credentials.json'
        with open(ANYDO_CREDENTIALS_PATH) as f:
            anydo_credentials = json.loads(f.read())
            
        user_ = anydo_credentials['user']
        pass_ = anydo_credentials['pass']

        anydo_api = AnyDoAPI(username=user_,password=pass_)

        self.tasks = anydo_api.get_all_tasks()
        self.unchecked_tasks = [task for task in self.tasks if task['status'] == 'UNCHECKED']  
        self.unchecked_task_names = [task['title'] for task in self.unchecked_tasks]
        self.unchecked_task_count = len(self.unchecked_tasks)
Exemple #3
0
def cleanupDummyTask():
    # Login with the Any.Do credentials
    anyDoUsername = os.environ.get( 'ANY_DO_USERNAME', '' )
    anyDoPassword = os.environ.get( 'ANY_DO_PASSWORD', '' )
    api = AnyDoAPI( username=anyDoUsername, password=anyDoPassword )

    # Cycle through all tasks and find the dummy task
    task_id = None
    for task in api.get_all_tasks():
        if task[ 'title' ] == ideal_payload[ 'task_name' ]:
            task_id = task[ 'id' ]
            break

    if task_id:
        api.delete_task_by_id( task_id )
Exemple #4
0
def addTask():
    assert request.method == 'POST'

    # Verify that key arguments were provided
    if not request.json.get( "key" ):
        return DisplayStrings.KEY_NOT_PROVIDED_ERROR
    if not validLogin( request.json.get( "key" ) ):
        return DisplayStrings.INVALID_KEY_ERROR
    if not request.json.get( "task_name" ):
        return DisplayStrings.NO_TASK_NAME_ERROR

    # Login with the Any.Do credentials
    anyDoUsername = os.environ.get( "ANY_DO_USERNAME", "" )
    anyDoPassword = os.environ.get( "ANY_DO_PASSWORD", "" )
    api = AnyDoAPI( username=anyDoUsername, password=anyDoPassword )

    if not request.json.get( "due_date" ):
        # Assume a default due date of tomorrow, if nothing is provided.
        due_day = datetime.datetime.today() + datetime.timedelta( hours=+24 )
    else:
        # Expected to be in a certain format. Eg: November 21, 2006 at 04:30PM
        dateFormat = "%B %d, %Y at %I:%M%p"
        # Convert to struct_time
        try:
            date_struct_time = time.strptime( request.json[ "due_date" ], dateFormat )
        except ValueError:
            return DisplayStrings.INVALID_DATE_FORMAT_ERROR
        # Convert from struct_time to datetime
        due_day = datetime.datetime.fromtimestamp( time.mktime( date_struct_time ) )

    # Create the task
    try:
        api.create_new_task( request.json.get( "task_name" ), due_day=due_day )
        return DisplayStrings.TASK_ADD_SUCCESSFUL
    except:
        # Failed for some reason
        return DisplayStrings.TASK_ADD_FAILED
Exemple #5
0
"""
Created on 5 May 2015

@author: shahankit
"""
import sys
from anydo.api import AnyDoAPI
from CreateOnTrello import CreateOnTrello

anydo_username = raw_input('Enter username for any.do : ')
anydo_password = raw_input('Enter password for any.do : ')

api = AnyDoAPI(username=anydo_username, password=anydo_password)

try:
    api.get_user_info()
except:
    print('Invalid username or password')
    sys.exit(1)

categories = api.get_all_categories()
category_data = {}
for category in categories:
    category_data[category['id']] = {'name': category['name'], 'tasks': []}

tasks = api.get_all_tasks()
task_dict = {}
for task in tasks:
    task_dict[task['id']] = task

for task in tasks:
Exemple #6
0
 def connect(self) -> AnyDoAPI:
     return AnyDoAPI(username=self.username, password=self.password)
"""
Created on 5 May 2015

@author: shahankit
"""
import sys
from anydo.api import AnyDoAPI
from CreateOnTrello import CreateOnTrello

anydo_username = raw_input('Enter username for any.do : ')
anydo_password = raw_input('Enter password for any.do : ')

api = AnyDoAPI(username = anydo_username, password = anydo_password)

try:
	api.get_user_info()
except:
	print ('Invalid username or password')
	sys.exit(1)

categories = api.get_all_categories()
category_data = {}
for category in categories:
    category_data[category['id']] = {'name':category['name'], 'tasks':[]}

tasks = api.get_all_tasks()
task_dict = {}
for task in tasks:
	task_dict[task['id']] = task

for task in tasks: