-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserverManager.py
More file actions
62 lines (59 loc) · 1.89 KB
/
serverManager.py
File metadata and controls
62 lines (59 loc) · 1.89 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
#Last Updated: 12/7/17
import CSVExporter
import DataModel
import firebaseCommunicator
import os
import time
import traceback
PBC = firebaseCommunicator.PyrebaseCommunicator()
fb = PBC.firebase
comp = DataModel.Competition(PBC)
while(True):
comp.updateTeamsAndMatchesFromFirebase()
cmd = raw_input('>>> ').split()
if cmd[0] == 'exp':
try:
if cmd[1] == 'all':
CSVExporter.CSVExportGeneral(comp, 'ALL')
comp.PBC.sendExport('EXPORT-ALL.csv')
elif cmd[1] == 'min':
CSVExportMini(comp)
except Exception as e:
print(traceback.format_exc())
elif cmd[0] == 'sns':
#idea for faster method- under TempTIMDs, have data organized by match, and under that, the data, so we don't have to iterate through every TIMD
scoutSentData = []
scoutNotSentData = []
tempTIMDs = fb.child('TempTeamInMatchDatas').get().val()
curMatch = str(fb.child('currentMatchNum').get().val())
for TIMD in tempTIMDs:
name = fb.child('TempTeamInMatchDatas').child(TIMD).get().key()
scout = name[-2:]
if '-' in scout:
scout = scout[1:]
match = name.split('-')[0]
match = match[-2:]
if 'Q' in match:
match = match[-1:]
if str(match) == curMatch:
scoutSentData.append(scout)
control = [str(x) for x in range(1, 19)]
for item in control:
if item not in scoutSentData:
scoutNotSentData.append(item)
scoutNotSent = ''
for scout in scoutNotSentData:
scoutNotSentUpdated += scout
if scoutNotSent != scoutNotSentData:
print('Scouts that have not inputted data in match', str(curMatch), '-', scoutNotSentUpdated)
else:
print('All scouts have sent data.')
elif cmd[0] == 'test':
print('Test completed.')
elif cmd[0] == 'help':
print('exp [all/min] - Tries to export')
print('sns - Prints scout not sent for current match')
print('test - prints Test Completed.')
else:
print("'" + str(cmd[0]) + "'" + ' is not a valid function. Type help for help.')
time.sleep(1)