Created
February 11, 2011 10:43
-
-
Save meehow/822196 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/env python | |
import sys | |
import hashlib | |
import urllib | |
import time | |
import commands | |
from datetime import datetime | |
def get_url_md5(url): | |
md5 = hashlib.md5(urllib.urlopen(url).read()).hexdigest() | |
print datetime.now().strftime('%Y-%m-%d %H:%M:%S'), url, md5 | |
return md5 | |
def main(url, sleep): | |
md5_start = get_url_md5(url) | |
md5_tmp = md5_start | |
while md5_start == md5_tmp: | |
time.sleep(sleep) | |
md5_tmp = get_url_md5(url) | |
commands.getoutput('say file has been changed') | |
if __name__ == '__main__': | |
main(sys.argv[1], int(sys.argv[2]) if len(sys.argv) == 3 else 30) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment