Beispiel #1
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 #2
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 #3
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])
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 #5
0
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
error = 0
for repo in repos: