forked from applepi-2067/PiScout-2016
-
Notifications
You must be signed in to change notification settings - Fork 6
/
import.py
36 lines (33 loc) · 1.06 KB
/
import.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
import csv
import os
import sys
import requests
import serverinfo
import gamespecific as game
from event import CURRENT_EVENT
if len(sys.argv) < 1:
print("No file provided. Please try again.")
print("Attempting upload to server")
skip = 0
try: # post it to piscout's ip address
if os.path.isfile(sys.argv[1]):
with open(sys.argv[1], "r") as file:
reader = csv.reader(file)
for row in reader:
matchData = dict(game.SCOUT_FIELDS)
if skip == 0:
skip = 1
continue
for num, key in enumerate(game.SCOUT_FIELDS):
if row[num]:
matchData[key] = row[num]
requests.post(
"http://127.0.0.1:8000/submit",
data={
"event": CURRENT_EVENT,
"data": str(matchData),
"auth": serverinfo.AUTH,
},
)
except:
print("Upload Failed. Check connectivity and try again.")