Beispiel #1
0
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
Beispiel #2
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)
Beispiel #3
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)
Beispiel #4
0
    def prompt_login():
        '''Ask the user for login info.
        Returns a tuple with email, password'''

        email = raw_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 = raw_input("Login failed, try again? (y/n) ")
            if again == "y" or again == "Y":
                prompt_login(wunderlist)
            else:
                exit()

        return wunderlist
Beispiel #5
0
    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
Beispiel #6
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()
Beispiel #7
0
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
Beispiel #8
0
    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
Beispiel #9
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'...")
Beispiel #10
0
 def setUpClass(cls):
     cls.wunderlist = Wunderlist()
     cls.wunderlist.login(EMAIL, PASSWORD)
Beispiel #11
0
from datetime import datetime
from wunderpy import Wunderlist
from github import Github
import base64
import time

WL_USER = '******'
WL_PASS = base64.b64decode('base64-of-your-wunderlist-password')
WL_LIST_NAME = 'Github Starred'  # name of list to add stars to. Must exist ahead of time.
GH_TOKEN = 'see https://github.com/settings/tokens/new'

# get wunderlist stuff
print ">>>>> WUNDER-STAR STARTED {} <<<<<".format(time.asctime( time.localtime(time.time()) ))
print "Getting list from Wunderlist..."
w = Wunderlist()
w.login(WL_USER, WL_PASS)
w.update_lists()
tasks = w.tasks_for_list(WL_LIST_NAME)

# get github stuff
print "Getting stars from GitHub (this may take a bit)"
gh = Github(login_or_token=GH_TOKEN)
me = gh.get_user()
repos = [repo for repo in me.get_starred()]

# get what projects are already in Wunderlist by splitting on :
print "Comparing stars to Wunderlist items..."
task_title_list = [task.title.split(':')[0].encode('ISO-8859-1', 'ignore') for task in w.tasks_for_list(WL_LIST_NAME)]
added = 0
skipped = 0
notes = 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)
Beispiel #13
0
 def _wlogin():
     w = Wunderlist()
     w.login(self.wunder_user, self.wunder_password)
     w.update_lists()
     return w
Beispiel #14
0
class TestClient(unittest.TestCase):
    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)

    def test_list_filter(self):
        list_one = TaskList(info={"title": "one", "id": "one"})
        self.wl.lists.append(list_one)

        list_two = TaskList(info={"title": "one", "id": "two"})
        self.wl.lists.append(list_two)

        self.assertEqual(self.wl.list_with_title("inbox"), self.inbox)
        self.assertEqual(self.wl.lists_with_title("one"),
                         [list_one, list_two])

        self.wl.lists.remove(list_one)
        self.wl.lists.remove(list_two)

    def test_get_tasks(self):
        task = Task({"title": "title", "id": "id"})
        self.inbox.add_task(task)
        self.assertEqual(self.wl.tasks_for_list("inbox"), [task])
        self.assertEqual(self.wl.get_task("title", "inbox"), task)
        self.assertEqual(self.wl.id_for_task("title", "inbox"), "id")

    def test_lists(self):
        one = TaskList({"title": "one", "id": "one"})
        self.wl.lists.append(one)
        two = TaskList({"title": "one", "id": "two"})
        self.wl.lists.append(two)

        self.assertEqual(self.wl.list_with_title("inbox"), self.inbox)
        self.assertEqual(self.wl.lists_with_title("one"), [one, two])
        self.assertEqual(self.wl.id_for_list("inbox"), "inbox")

    def test_due_before(self):
        one = TaskList({"title": "one", "id": "one"})
        task_one = Task({"title": "task1", "id": "one",
                        "due_date": (date.today() -
                                     timedelta(days=1)).isoformat()})
        one.add_task(task_one)
        self.wl.lists.append(one)

        two = TaskList({"title": "two", "id": "two"})
        task_two = Task({"title": "two", "id": "two",
                        "due_date": (date.today() +
                                     timedelta(days=1)).isoformat()})
        two.add_task(task_two)
        self.wl.lists.append(two)

        task_three = Task({"title": "three", "id": "three",
                          "due_date": (date.today() +
                                       timedelta(days=1)).isoformat()})
        self.inbox.add_task(task_three)

        self.assertEqual(self.wl.tasks_due_before(date.today()), [task_one])
        self.assertEqual(self.wl.tasks_due_before(date.today() +
                                                  timedelta(days=2)),
                         [task_one, task_two, task_three])

    def test_due_on(self):
        one = TaskList({"title": "one", "id": "one"})
        task_one = Task({"title": "task1", "id": "one",
                        "due_date": (date.today() -
                                     timedelta(days=1)).isoformat()})
        one.add_task(task_one)
        self.wl.lists.append(one)

        two = TaskList({"title": "two", "id": "two"})
        task_two = Task({"title": "two", "id": "two",
                        "due_date": (date.today().isoformat())})
        two.add_task(task_two)
        self.wl.lists.append(two)

        task_three = Task({"title": "three", "id": "three",
                          "due_date": (date.today() +
                                       timedelta(days=1)).isoformat()})
        self.inbox.add_task(task_three)

        self.assertEqual(self.wl.tasks_due_on(date.today()), [task_two])
        self.assertEqual(self.wl.tasks_due_on(date.today() +
                                              timedelta(days=1)),
                         [task_three])
Beispiel #15
0
 def _wlogin():
     w = Wunderlist()
     w.login(self.wunder_user, self.wunder_password)
     w.update_lists()
     return w
from datetime import datetime
from wunderpy import Wunderlist

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

w.add_list("test") # make a new list called "test"

print w.lists
Beispiel #17
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)
Beispiel #18
0
class TestClient(unittest.TestCase):
    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)

    def test_list_filter(self):
        list_one = TaskList(info={"title": "one", "id": "one"})
        self.wl.lists.append(list_one)

        list_two = TaskList(info={"title": "one", "id": "two"})
        self.wl.lists.append(list_two)

        self.assertEqual(self.wl.list_with_title("inbox"), self.inbox)
        self.assertEqual(self.wl.lists_with_title("one"), [list_one, list_two])

        self.wl.lists.remove(list_one)
        self.wl.lists.remove(list_two)

    def test_get_tasks(self):
        task = Task({"title": "title", "id": "id"})
        self.inbox.add_task(task)
        self.assertEqual(self.wl.tasks_for_list("inbox"), [task])
        self.assertEqual(self.wl.get_task("title", "inbox"), task)
        self.assertEqual(self.wl.id_for_task("title", "inbox"), "id")

    def test_lists(self):
        one = TaskList({"title": "one", "id": "one"})
        self.wl.lists.append(one)
        two = TaskList({"title": "one", "id": "two"})
        self.wl.lists.append(two)

        self.assertEqual(self.wl.list_with_title("inbox"), self.inbox)
        self.assertEqual(self.wl.lists_with_title("one"), [one, two])
        self.assertEqual(self.wl.id_for_list("inbox"), "inbox")

    def test_due_before(self):
        one = TaskList({"title": "one", "id": "one"})
        task_one = Task({
            "title":
            "task1",
            "id":
            "one",
            "due_date": (date.today() - timedelta(days=1)).isoformat()
        })
        one.add_task(task_one)
        self.wl.lists.append(one)

        two = TaskList({"title": "two", "id": "two"})
        task_two = Task({
            "title":
            "two",
            "id":
            "two",
            "due_date": (date.today() + timedelta(days=1)).isoformat()
        })
        two.add_task(task_two)
        self.wl.lists.append(two)

        task_three = Task({
            "title":
            "three",
            "id":
            "three",
            "due_date": (date.today() + timedelta(days=1)).isoformat()
        })
        self.inbox.add_task(task_three)

        self.assertEqual(self.wl.tasks_due_before(date.today()), [task_one])
        self.assertEqual(
            self.wl.tasks_due_before(date.today() + timedelta(days=2)),
            [task_one, task_two, task_three])

    def test_due_on(self):
        one = TaskList({"title": "one", "id": "one"})
        task_one = Task({
            "title":
            "task1",
            "id":
            "one",
            "due_date": (date.today() - timedelta(days=1)).isoformat()
        })
        one.add_task(task_one)
        self.wl.lists.append(one)

        two = TaskList({"title": "two", "id": "two"})
        task_two = Task({
            "title": "two",
            "id": "two",
            "due_date": (date.today().isoformat())
        })
        two.add_task(task_two)
        self.wl.lists.append(two)

        task_three = Task({
            "title":
            "three",
            "id":
            "three",
            "due_date": (date.today() + timedelta(days=1)).isoformat()
        })
        self.inbox.add_task(task_three)

        self.assertEqual(self.wl.tasks_due_on(date.today()), [task_two])
        self.assertEqual(
            self.wl.tasks_due_on(date.today() + timedelta(days=1)),
            [task_three])