Skip to content
This repository has been archived by the owner on May 11, 2022. It is now read-only.

Commit

Permalink
Merge pull request #19 from hammerhead226/emmercm/2018-scouting-forms
Browse files Browse the repository at this point in the history
2018 Scouting Forms / Stats Updates
  • Loading branch information
emmercm committed Mar 24, 2018
2 parents 16075b0 + 27299f7 commit e115d4f
Show file tree
Hide file tree
Showing 10 changed files with 283 additions and 119 deletions.
1 change: 1 addition & 0 deletions build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ if %errorlevel% neq 0 (
)

rmdir /S /Q mongo
rmdir /S /Q sessions
cd ..
rmdir /S /Q venv

Expand Down
3 changes: 2 additions & 1 deletion scripts/odroid-c.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ cd "$(dirname "$0")"
sudo rm /etc/localtime
sudo ln -s /usr/share/zoneinfo/US/Eastern /etc/localtime

# Turn off fstab fsck (potentially dangerous)
# Turn off startup fsck (potentially dangerous)
sudo sed -i 's/1$/0/g' /etc/fstab
sudo tune2fs -c 0 -i 0 -l /dev/mmcblk0p2

# ODROID C1/C2 LCD
if [ "$(systemctl | grep odroid-lcd35)" == "" ]; then
Expand Down
4 changes: 2 additions & 2 deletions sharkscout/mongo.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ def events_update(self, year):

# TBA update an individual event
def event_update(self, event_key):
event = self.tba_api.event(event_key)
event = self.tba_api.event(event_key, True)
if event:
# Info that can be known before an event starts
event.update({k:v for k, v in {
Expand Down Expand Up @@ -601,7 +601,7 @@ def team(self, team_key, year=None):

# TBA update an individual team
def team_update(self, team_key):
team = self.tba_api.team(team_key)
team = self.tba_api.team(team_key, True)
if team:
team.update({k:v for k, v in {
'awards': self.tba_api.team_history_awards(team_key),
Expand Down
13 changes: 8 additions & 5 deletions sharkscout/thebluealliance.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ def _get(self, endpoint, ignore_cache=False):
if response.status_code == 304:
return {}

content = response.json()
try:
content = response.json()
except json.JSONDecodeError as e:
print(endpoint, response.status_code, response.text)
raise e
content = self._tba3_clean(content)
content = self._tba3_to_tba2(content)

Expand Down Expand Up @@ -211,9 +215,7 @@ def event_rankings_raw(self, event_key, ignore_cache=False):

def event_rankings_v2(self, event_key, ignore_cache=False):
rankings = self.event_rankings_raw(event_key, ignore_cache)
if rankings is None:
return rankings
if 'rankings' in rankings and rankings['rankings']:
if rankings and 'rankings' in rankings and rankings['rankings']:
for idx, ranking in enumerate(rankings['rankings']):
rankings['rankings'][idx] = [
ranking['rank'],
Expand All @@ -223,7 +225,8 @@ def event_rankings_v2(self, event_key, ignore_cache=False):
ranking['matches_played']
]
rankings['rankings'].insert(0, ['Rank', 'Team'] + [i['name'] for i in rankings['sort_order_info']] + ['Record (W-L-T)', 'Played'])
return rankings['rankings']
return rankings['rankings']
return []

def event_rankings(self, event_key, ignore_cache=False):
rankings = self.event_rankings_v2(event_key, ignore_cache)
Expand Down
10 changes: 5 additions & 5 deletions sharkscout/webserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ def _csv(self, prefix, items):
filename = tempfile.gettempdir() + '/' + prefix + datetime.now().strftime('%Y%m%d-%H%M%S') + '.csv'
with open(filename, 'w', newline='') as temp:
writer = csv.DictWriter(temp, fieldnames=keys)
writer.writerow({k: re.sub(r'^[0-9]+_+', '', k) for k in keys})
writer.writerow({k: k.lstrip('0123456789').strip(' _') for k in keys})
# Write each row
for item in items:
row = {}
Expand Down Expand Up @@ -543,14 +543,14 @@ def received_message(self, message):
self.send({
'dequeue': {'scouting_match': data},
'toast': {
'message': 'You Match Scouted ' + data['match_key'] + ' ' + data['team_key'],
'message': 'You match scouted ' + data['match_key'] + ' ' + data['team_key'],
'type': 'success'
}
})
self.broadcast({'show': '.match-listing .' + data['match_key'] + ' .' + data['team_key'] + ' .fa-check'})
self.broadcast_others({
'toast': {
'message': data['scouter'] + ' Match Scouted ' + data['match_key'] + ' ' + data['team_key'],
'message': data['scouter'] + ' match scouted ' + data['match_key'] + ' ' + data['team_key'],
'type': 'success',
'mobile': False
}
Expand All @@ -563,14 +563,14 @@ def received_message(self, message):
self.send({
'dequeue': {'scouting_pit': data},
'toast': {
'message': 'You Pit Scouted ' + data['event_key'] + ' ' + data['team_key'],
'message': 'You pit scouted ' + data['event_key'] + ' ' + data['team_key'],
'type': 'success'
}
})
self.broadcast({'show': '.team-listing .' + data['team_key'] + ' .fa-check'})
self.broadcast_others({
'toast': {
'message': data['scouter'] + ' Pit Scouted ' + data['event_key'] + ' ' + data['team_key'],
'message': data['scouter'] + ' pit scouted ' + data['event_key'] + ' ' + data['team_key'],
'type': 'success',
'mobile': False
}
Expand Down
Loading

0 comments on commit e115d4f

Please sign in to comment.