Last active
August 29, 2015 14:07
-
-
Save jtallieu/fa5870f3663de13476d6 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 requests | |
import datetime | |
import calendar | |
import json | |
token = "------------" | |
project_id= "--------------" | |
iron_host = "worker-aws-us-east-1.iron.io/2/projects/%s" % project_id | |
if __name__ == "__main__": | |
start = datetime.datetime(2014,10,19,20,0,0) | |
end = datetime.datetime(2014,10,20,2,0,0) | |
print start | |
print end | |
stime = calendar.timegm(start.utctimetuple()) | |
etime = calendar.timegm(end.utctimetuple()) | |
f = open("s.log", "w") | |
count = 1 | |
page = 0 | |
while count and page < 100: | |
count = 0 | |
print "Page", page | |
resp = requests.get("https://%s/tasks?code_name=Sync&from_time=%d&to_time=%d&per_page=100&page=%d" % (iron_host, stime, etime, page), headers={"Accept": "application/json", "Content-Type": "application/json", "Authorization": "OAuth %s" % token}) | |
#resp = requests.get("https://%s/tasks?code_name=Sync&per_page=100&page=%d" % (iron_host, page), headers={"Accept": "application/json", "Content-Type": "application/json", "Authorization": "OAuth %s" % token}) | |
page += 1 | |
data = resp.json() | |
for task in data["tasks"]: | |
count += 1 | |
payload = json.loads(task["payload"]) | |
#print task["id"], payload["username"] | |
try: | |
if payload["username"] == "[email protected]": | |
print task["id"], task["start_time"] | |
f.write("Start Time: %s" % task["start_time"]) | |
r = requests.get("https://%s/tasks/%s/log" % (iron_host, task["id"]), headers={"Accept": "application/json", "Content-Type": "application/json", "Authorization": "OAuth %s" % token}) | |
log = r.text | |
f.write("%s\n\n" % log) | |
except: | |
pass | |
f.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment