Commits

Ada Young committed 66a05dd

Cleaned up the output to be more informative and spitting much less debugging info :D

Comments (0)

Files changed (1)

 	http_open(link) -> JSON object
 	This function fetches the given link and returns a json object
 	"""
-	print("Fetching: %s" % link)
+	#print("Fetching: %s" % link)
 	try:
 		data = browser.open(link)
 		data = data.read()
 	except urllib2.HTTPError:
-		print("Encountered HTTPError for %s" % link, sys.exc_info())
-		print("Setting empty json object -> []")
+		#print("Encountered HTTPError for %s" % link, sys.exc_info())
+		#print("Setting empty json object -> []")
 		data = "[]"
 	except:
 		print("Error while opening %s" % link, sys.exc_info())
-		exit()
+		exit(-1)
 
 	try:
 		data = json.loads(data)
 	except:
 		print("Error decoding JSON object from %s" % link, sys.exc_info())
 		print("Setting empty JSON object -> []")
-		data = "[]"
-		data = json.loads(data)
+		data = []
+
 	return data
 
 def orglogs_summary(character, password, days=0):
 			"password" : password,
 			"day" : days
 		})
+
 	orglogs = "%s%s" % (api_server, orglogs_endpoint)
 	dataset = http_open("%s?%s" % (orglogs, param_string))
 
 		dataset = http_open(uri_set[i])
 
 		lognotes = []
-		for i in dataset:
-			timestamp = i.get('date', 0)
+		timestamp = ""
+		for j in dataset:
+			timestamp = j.get('date', 0)
 			timestamp = datetime.utcfromtimestamp(int(timestamp)).strftime("%Y-%m-%d %H:%M:%S")
 
-			lognote = i.get('event', '')
+			lognote = j.get('event', '')
 			lognotes.append("%s - %s" % (timestamp, lognote))
 
+		loglength = len(lognotes)
+		timestamp = timestamp.split(" ")[0]
+		if loglength > 0:
+			print("Fetched logs for %s (%d) for %s." % (orgname, loglength, timestamp))
 		ProcessLogs(lognotes, orgid)
 
 def ValidateOrgname(orgname):