Created
May 24, 2010 16:43
-
-
Save sanbornm/412112 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
# Add "alias tadd='python /path/to/agile.py'" to your | |
# .bashrc or .bash_profile. I put my agile.py in dropbox | |
# so I have access to it on every computer. | |
"""Agile Task Adder""" | |
__author__ = '[email protected] (Mark Sanborn)' | |
VERSION = '0.0.1' | |
import urllib2 | |
import urllib | |
import sys | |
# Config Variables | |
# ------------------------------------------------------------ | |
creds = 'YOURAPIKEY' # Agile Tasks API Key | |
#agileUrl = 'http://localhost:3000/tasks?user_credentials=%s' % (creds) # URL for Agile Tasks | |
agileUrl = 'http://tasks.jaderobbins.com/tasks?user_credentials=%s' % (creds) | |
# ------------------------------------------------------------ | |
def send_data(url, query): | |
"""Sends data to specified url and returns response""" | |
req = urllib2.Request(url) | |
# urlencode the query dictionary | |
req.data = urllib.urlencode(query) | |
try: | |
r = urllib2.urlopen(req) | |
result = r.read() | |
except: | |
result = 'The url: %s is not responding.' % (url) | |
return result | |
def main(): | |
# Get all args and put them into one string | |
# so we dont have to put single quotes every | |
# time we add a task. | |
args = sys.argv[1:] | |
task = '' | |
for x in args: | |
task = task + str(x) + ' ' | |
# Strip off the leading and trailing spaces of string | |
task = task.strip() | |
# Send urlencoded params to agile tasks | |
query = {'task[name]':task} | |
send_data(agileUrl, query) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is AgileTask win