コード例 #1
0
def fetch(session, auth_string):
    s = base64.b64decode(auth_string)
    u, p = s.split(':')
    w = Wunderlist()
    w.login(u, p)
    w.update_lists()

    for wunderlist, listinfo in w.lists.iteritems():
        try:
            wl = WunderList()
            wl.id = listinfo['id']
            wl.title = listinfo['title']
            session.add(wl)
        except:
            continue

        for taskname, task in listinfo['tasks'].iteritems():
            try:
                wt = WunderTask()
                wt.id = task['id']
                wt.title = task['title']

                wt.completed_at = dateutil.parser.parse(task['completed_at'])
                wt.note = task['note']
                # TODO: add parsing and line linking here!
                session.add(wt)
                wl.tasks.append(wt)
            except:
                continue
    session.commit()
コード例 #2
0
ファイル: export.py プロジェクト: nathanleiby/experiments
def connect_to_wunderlist(username, password):
    """ Returns a Wunderlist connection
  param: username - WL username
  param: password - WL password
  """
    print "Connecting to Wunderlist..."
    w = Wunderlist()
    w.login(username, password)
    w.update_lists()  # you have to run this first, before you do anything else
    return w
コード例 #3
0
ファイル: main.py プロジェクト: sadk/wunderpy
    def get_wunderlist(self):
        try:
            token = get_token()
        except IOError:  # first run
            setup()
            token = get_token()

        wunderlist = Wunderlist()
        wunderlist.set_token(token)
        wunderlist.update_lists()
        self.wunderlist = wunderlist
コード例 #4
0
    def setUp(self):
        self.wl = Wunderlist()

        # not calling update_lists, because it sends requests
        inbox_info = {
            "title": "inbox",
            "id": "inbox",
            "created_on": None,
            "updated_on": None
        }
        self.inbox = TaskList(info=inbox_info)
        self.wl.lists.append(self.inbox)
コード例 #5
0
ファイル: storage.py プロジェクト: sadk/wunderpy
    def prompt_login():
        '''Ask the user for login info.
        Returns a tuple with email, password'''

        email = input("Input your Wunderlist username (email): ")
        password = getpass.getpass(prompt="Input your Wunderlist password: "******"Logging in...")
        wunderlist = Wunderlist()
        try:
            wunderlist.login(email, password)
        except:
            again = input("Login failed, try again? (y/n) ")
            if again == "y" or again == "Y":
                prompt_login()
            else:
                exit()

        return wunderlist
コード例 #6
0
def main():

    # get the arguments from the command line
    args = parseargs()
    username = args.username
    password = args.password
    list_name = args.list_name
    wait1 = args.wait1  # time between updates (sec)
    wait2 = args.wait2  # time between reattempting a failed update (sec)

    # require all arguments
    if (username == None) or (password == None) or (list_name == None) or (
            wait1 == None) or (wait2 == None):
        print(usage)
        return -1

# run forever as a background process
    while 1:

        # ping google to see if we have an internet connection
        # ping code copied from this stack overflow thread:
        # http://stackoverflow.com/questions/316866/ping-a-site-in-python
        ping = subprocess.Popen(["ping", "-c", "4", "www.google.com"],
                                stdout=subprocess.PIPE,
                                stderr=subprocess.PIPE)

        out, error = ping.communicate()

        # if there is no error then proceed to get tasks from wunderlist
        if (len(error) == 0):

            w = Wunderlist()
            w.login(username, password)
            w.update_lists(
            )  # you have to run this first, before you do anything else
            tasks = w.tasks_for_list(list_name)
            simple_task_list = []

            # step through tasks, crop the name to an appropriate length,
            # put uncompleted tasks into a simple_task object which is actually sortable on date
            for task in tasks:

                task_name = task.title
                if (len(task_name) > 35):
                    task_name = task_name[0:32] + '...'
                due_date = task.due_date
                if not task.completed:
                    simple_task_list.append(simple_task(task_name, due_date))

            # sort the tasks, open up output file where synced list goes
            simple_task_list.sort()
            home = expanduser("~")
            output_file = open(home + '/.conky_wunderlist/task_list', 'w')

            # print out the tasks in conky format
            for task in simple_task_list:

                if (task.due_date != None):
                    day = str(task.due_date.day
                              ) if task.due_date.day > 9 else '0' + str(
                                  task.due_date.day
                              )  # pad the day string with a zero if needed
                    year = (str(task.due_date.year)
                            )[2:4]  # get just the last two digits of the year
                    print('{}{}{} / {} / {}'.format(task.task_name,
                                                    '${alignr}',
                                                    task.due_date.month, day,
                                                    year),
                          file=output_file)  # print conky-style

                else:
                    # if due date is None then just print task name
                    print(task.task_name, file=output_file)

            output_file.close()

            # have successfully written tasks to file, sleep for wait1 seconds
            time.sleep(wait1)

        # if there was an error then sleep for wait2 seconds and then try again
        else:
            time.sleep(wait2)
コード例 #7
0
from datetime import datetime
from wunderpy import Wunderlist
import argparse
import sys

parser = argparse.ArgumentParser(description='Process some integers.')
parser.add_argument('--username', dest='username')
parser.add_argument('--password', dest='password')

args = parser.parse_args()
username = args.username
password = args.password

w = Wunderlist()
w.login(username, password)
w.update_lists()  # you have to run this first, before you do anything else

# print w
print w.__dict__

raw_input("About to create list 'test'...")
w.add_list("test")  # make a new list called "test"
raw_input("About to add task 'test wunderpy'...")
due = datetime.now().isoformat()
w.add_task("test wunderpy", list_title="test", note="a note",
           due_date=due, starred=True)  # add a task to it
raw_input("About to complete task 'test wunderpy'...")
w.complete_task("test wunderpy", "test")  # complete it
raw_input("About to delete task 'test wunderpy'...")
w.delete_task("test wunderpy", "test")  # and delete it
raw_input("About to delete list 'test'...")
コード例 #8
0
 def setUpClass(cls):
     cls.wunderlist = Wunderlist()
     cls.wunderlist.login(EMAIL, PASSWORD)
コード例 #9
0
 def _wlogin():
     w = Wunderlist()
     w.login(self.wunder_user, self.wunder_password)
     w.update_lists()
     return w