-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclasscheck.py
69 lines (57 loc) · 1.58 KB
/
classcheck.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import sys
import json
import feedparser
import re
import datetime
import smtplib
def check(title, timecheck):
regex = re.compile("(\d+)")
r= regex.findall(title)
t = datetime.date.today()
if int(timecheck) == 0:
t = t -datetime.timedelta(0)
else:
t = t -datetime.timedelta(1)
classday = int(t.strftime("%d"))
if r:
day = int(r[0])
if day == classday:
return True
else:
return False
else:
return False
if __name__ == "__main__":
fromaddr = "coursecapture@fiu.edu"
sname = "smtpout.fiu.edu"
date = datetime.datetime.now().strftime( "%d/%m/%Y %H:%M" )
whichday = 0
r = []
if len(sys.argv) == 2:
print "Opening " + sys.argv[1]
elif len(sys.argv) == 3:
whichday = 1
print "Opening " + sys.argv[1]
else:
print "error with parameters"
sys.exit(0)
print sys.argv
f = open(sys.argv[1])
data = json.load(f)
result = ""
for k in data:
d = feedparser.parse(k[1].replace(" ", "%20"))
index = len(d.entries) - 1
test = check(d.entries[index].title, whichday)
if test == False :
r.append( "Problem with class " + k[0])
print "problem with class " + k[0]
else:
print k[0] + " recorded just fine."
r.append( k[0] + " recorded just fine." )
for txt in r:
result = result + "\n " + txt
msg = "From: %s\nTo: %s\nSubject: %s\nDate: %s\n\n%s" % ( fromaddr, "coursecapture@fiu.edu", "Report of class recordings ", date, result )
server = smtplib.SMTP(sname)
server.sendmail(fromaddr, "coursecapture@fiu.edu", msg)
#server.sendmail(fromaddr, "sbromfi@fiu.edu", msg)