Created
May 16, 2015 06:04
-
-
Save jgdovin/811d54681442380dce93 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
import os, os.path, time, urllib, urllib2, json, datetime | |
base = os.getcwd() + '/packages/' | |
apiUrl = 'https://atmospherejs.com/a/packages/findByNames' | |
for dirname in os.listdir(base): | |
max_mtime = 0 | |
if os.path.isdir(base + dirname): | |
packageName = dirname.replace('-', ':', 1) | |
for fname in os.listdir(base + dirname): | |
full_path = base + dirname + '/' + fname | |
mtime = os.path.getmtime(full_path) | |
if mtime > max_mtime: | |
max_mtime = mtime | |
max_dir = dirname | |
max_file = fname | |
data = urllib.urlencode({'names' : packageName}) | |
headers = {'Accept' : 'application/json'} | |
fullUrl = apiUrl + '?' + data | |
req = urllib2.Request(fullUrl) | |
req.add_header('Accept', 'application/json') | |
try: | |
packageInfo = urllib2.urlopen(req) | |
except urllib2.HTTPError as e: | |
print e.code | |
print e.read() | |
response = json.loads(packageInfo.read()) | |
if response == []: | |
print 'NO ATMOSPHERE PACKAGE FOUND: ' + dirname | |
else: | |
timestamp = str(response[0]["latestVersion"]["published"]["$date"]) | |
if int(timestamp[:-3]) < max_mtime: | |
print 'modified - ' + packageName |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment