-
-
Save loke-dev/2e380023ed0a5bac91f0da41401684d9 to your computer and use it in GitHub Desktop.
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/env python | |
import sys, os, re | |
from subprocess import check_output | |
from contextlib import closing | |
import urllib2 | |
import json | |
commit_msg_filepath = sys.argv[1] | |
joke = "" | |
with closing(urllib2.urlopen('http://api.icndb.com/jokes/random')) as sf: | |
response = json.loads(sf.read()) | |
joke = response['value']['joke'] | |
with open(commit_msg_filepath, 'w') as f: | |
f.write(joke) | |
sys.exit(0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment