Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@jgdovin
Created May 16, 2015 06:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jgdovin/811d54681442380dce93 to your computer and use it in GitHub Desktop.
Save jgdovin/811d54681442380dce93 to your computer and use it in GitHub Desktop.
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