-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun.py
61 lines (47 loc) · 1.68 KB
/
run.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
from urllib.request import urlopen
from bs4 import BeautifulSoup
import time
from datetime import datetime
import smtplib
#Overcrowd Max is 675
#Max = 675
#oldPC = input("%?")
#newPC = int(oldPC) * .01
#logging
while True:
Max = 675
oldPC = input("%?")
newPC = int(oldPC) * .01
url = "http://livecount.hacknyu.org/"
html = urlopen(url)
soup = BeautifulSoup(html, "html.parser")
current = int("".join(soup.find("div", {"id": "currentcount"}).strings))
with open("newhrs", "a") as myfile:
myfile.write("TimeStamp: " + str(datetime.now().time())+"\t" + "Person Count:" + str(current) + "\n")
if current > (Max * newPC):
text_file = open("newhrs", "r")
lines = text_file.read().split(':')
newlines = [s for s in lines if len(s) > 3]
newnewlines = [s for s in newlines if len(s) < 16]
#Nulines = ([s.strip(' \nTimeStamp ') for s in newnewlines])
#Nulines.pop(0)
#Nulines = list(map(int, Nulines))
#Nulines = [x + 94 for x in Nulines]
s1 = [];
number = 0
#while number <= len(Nulines):
#number = number + 1
#s1.append(number)
#new1 = (Nulines[len(Nulines) - 1])
#new2 = (Nulines[len(Nulines)- 6])
#x1 = int(new1) - 1
#x2 = int(new2) - 1
#y1 = Nulines[int(new1) - 1]
#y2 = Nulines[int(new2) - 1]
server = smtplib.SMTP('smtp.gmail.com', 587)
server.starttls()
server.login("[email protected]", " ")
msg = "Your venue is at " + oldPC + "% capacity."
server.sendmail("[email protected]", "[email protected]", msg)
server.quit()
time.sleep(60)