Created
December 13, 2013 00:51
-
-
Save pspeter3/7938322 to your computer and use it in GitHub Desktop.
Print out the tasks you mark today from asana
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import base64 | |
import json | |
import os | |
import urllib | |
import urllib2 | |
AUTHORIZATION = base64.encodestring( | |
"%s:" %(os.environ["ASANA_API_KEY"])).replace("\n", "") | |
def request(url): | |
req = urllib2.Request(url) | |
req.add_header("Authorization", "Basic %s" %(AUTHORIZATION)) | |
res = urllib2.urlopen(req).read() | |
return json.loads(res).get("data") | |
user = request("https://app.asana.com/api/1.0/users/me") | |
data = {} | |
for workspace in user["workspaces"]: | |
query = urllib.urlencode({ | |
"assignee": user["id"], | |
"workspace": workspace["id"], | |
"opt_fields": "name,assignee_status,completed" | |
}) | |
tasks = request("https://app.asana.com/api/1.0/tasks?" + query) | |
print "%s:" %(workspace["name"]) | |
for task in tasks: | |
if not task["completed"] and task["assignee_status"] == "today": | |
print " %s" %(task["name"]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment