Periodic git commit

This commit is contained in:
RussellChamp committed 2015-10-13 08:23:17 -05:00
1 parent 0b5a4fcfb8
commit 94127052c9
15 files changed
+169 -85

No files matched your search

+8 -2
View File
@@ -8,8 +8,10 @@ import shutil
logfile = "/home/jumblesale/Code/irc/log"
outfile = "/home/krowbar/logs/userData.json"
userData = {} #hash keyed by "user" that contains an array of timestamps
#we only care about recent chats, let's say for the past two weeks
timeCutoff = calendar.timegm(time.gmtime()) - (2 * 7 * 24 * 60 * 60)
#we only care about recent chats, let's say for the past couple weeks
oneWeek = 7 * 24 * 60 * 60
fiveMinutes = 5 * 60
timeCutoff = calendar.timegm(time.gmtime()) - (2 * oneWeek)
with open(logfile, "r") as log:
for line in log:
@@ -19,8 +21,12 @@ with open(logfile, "r") as log:
except ValueError:
continue #There are some bad lines in the log file that we'll ignore if we can't parse
if time > timeCutoff:
#standardize all times into a single "week"
#time %= oneWeek
#if the user already exists in the list
if user in userData:
if time < userData[user][-1] + fiveMinutes:
continue #only record times that are at least five minutes apart
userData[user].append(time) #append the new time
else: #if they are new
userData[user] = [time] #create a new list