Repository navigation
Expand file tree
/
Copy pathautomation.py
More file actions
65 lines (55 loc) · 2.75 KB
/
Copy pathautomation.py
File metadata and controls
65 lines (55 loc) · 2.75 KB
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
#!/usr/bin/python
# this will automate everything to be ran in one quick command daily
import os
import constants
from Scrapers import generateDates, playerReferenceScraper, positionScraper, teamReferenceScraper, generateBoxScoreUrls, teamPerformanceScraper, performanceScraper, fanDuelScraper
from Extrapilators import dailyPerformanceExtrapilator, teamPerformanceExtrapilator, teamVsDefenseExtrapilator
from Optimization import sumPoints, featuresFiller, Optimizer, projectMagic, train
from WnbaEngine import WnbaEngine
import mysql.connector
import datetime
def main():
now = datetime.datetime.now()
yesterday = now - datetime.timedelta(days=1)
cnx = mysql.connector.connect(user=constants.testUser,
host=constants.testHost,
database=constants.testName,
password=constants.testPassword)
cursor = cnx.cursor()
dates = generateBoxScoreUrls.generateDates(yesterday.day, yesterday.month, yesterday.year, now.day, now.month, now.year)
print dates
generateBoxScoreUrls.generateUrls(cursor, cnx, dates)
performanceScraper.updateAndInsertPlayerRef(yesterday.day, yesterday.month, yesterday.year, now.day, now.month, now.year, cursor, cnx)
try:
cursor.clos()
cnx.commit()
cnx.close()
except:
pass
cnx = mysql.connector.connect(user=constants.testUser,
host=constants.testHost,
database=constants.testName,
password=constants.testPassword)
cursor = cnx.cursor()
teamPerformanceScraper.updateAndInsertPlayerRef(yesterday.day, yesterday.month, yesterday.year, now.day, now.month, now.year, cursor, cnx)
today = generateBoxScoreUrls.findDate(now.year, now.month, now.day, cursor)
dailyPerformanceExtrapilator.extrapolate(today, today, cursor, cnx)
teamPerformanceExtrapilator.extrapolate(today, today, cursor, cnx)
teamVsDefenseExtrapilator.extrapolate(today, today, cursor, cnx)
sumPoints.auto(today, cursor)
cursor.execute("update performance set projMinutes=minutesPlayed where projMinutes is null")
cnx.commit()
today = generateBoxScoreUrls.findDate(now.year, now.month, now.day, cursor)
status = fanDuelScraper.insert_into_performance(cursor, cnx, today)
if status == 0:
featuresFiller.fill(now.year, now.month, now.day, 1, cursor, cnx)
train.train(today-1, cursor, cnx)
projectMagic.actualProjMagic(today, cursor, cnx)
Optimizer.optimize(now.day, now.month, now.year, cursor, "simmonsProj")
os.chdir("WnbaEngine")
WnbaEngine.getWsaLineups()
cursor.close()
cnx.commit()
cnx.close()
if __name__=='__main__':
main()