Scouting App Code for the 2024 FRC Season
to install and store the Pypi packages, you need to download miniconda
miniconda
NOTE: if you're on an apple M1 computer, downloadMiniconda3 macOS Apple M1 64-bit bash
and if you're not, downloadMiniconda3 macOS Intel x86 64-bit bash
- open up your terminal
- search: F4 > terminal
- use the following in order (case sensitive)
cd downloads
ls -l
- then go and find where your miniconda install is located EX: Miniconda3-latest-MacOSX-arm64.sh
./Miniconda-latest(filename)
- If you don't have permissions to download it, do the command
chmod +x ./Miniconda…
- If you don't have permissions to download it, do the command
- read through the user agreement, READ IT, and THEN type
yes
in the terminal eval "(/Users/(name)/miniconda3/bin/conda shell.(name) hook)"
conda init
- install and initialize the pypi packages by making a conda environment in VSCode
- now that ypu've initialized the download for miniconda, move into VSCode and open a new terminal (ctrl + shift + `)
conda create -n (environment name) python=3.11
we are using python 3.11.3, so be sure to state what python version we're usingconda activate (environment name)
this should've moved you into the environment you've created
- below this are all of the pypi packages you will need to download, install all of them with the Linux/Apple command (
python3 -m pip install --upgrade Flask google-api-python-client google-auth-httplib2 google-auth-oauthlib waitress
). after you've done that, run the app usingpython3 main.py
. - after that go into any browser and type
localhost:80
and thats it
if the app gives you an error about a token being missing when you run the python3 command, that means you dont have the apikeys.json file or api token. follow from step 2 to 2b to get that problem resolved.
(hey, this is max. for now (as in as im still on the team) don't generate a new token. If you need the token just @ me on the discord or in dm's and ill give it to you. if you do end up generating a token, PLEASE send it to me so I can share it to others. if you're not on the discord or know me on discord at all, email me at maxmaginnis@yahoo.com
. thanks for the cooperation.)
Install With
- Windows:
py -m pip install --upgrade Flask google-api-python-client google-auth-httplib2 google-auth-oauthlib waitress
- Linux/Apple:
python3 -m pip install --upgrade Flask google-api-python-client google-auth-httplib2 google-auth-oauthlib waitress
-
git pull https://github.com/cavineers/ScoutingApp-GEN
-
Follow (most of) this tutorial to help get everything set up: https://developers.google.com/sheets/api/quickstart/python
2a. Setup OAuth for your Google Cloud Project and put the generated JSON in in file
ScoutingApp-GEN/token.json
Diagram:
{ "Sheets OAuth": ... }
- Sheets OAuth
- The OAuth JSON generated by Google Cloud
- type:
dict[str, str]
2b. During first runtime, click the OAuth concent link printed to the console
- If you already did so and have generated the
ScoutingApp-GEN/token.json
file, this file can be moved into other instances of the app to use the same token. - Note: The token will eventually expire, so the
token.json
file must be deleted and regenerated with the OAuth concent link, and any copies must be replaced with the new token.
- Sheets OAuth
The following commands must be ran in the repository directory.
Quickly run the flask app on 0.0.0.0:80
with
- Windows:
py main.py
- Linux/Apple:
python3 main.py
For specific IP and port hosting, follow these steps:
- run the instance
- open command prompt
- type in
ssh -i [key.pem file] ubuntu@[ip]
- type y (if it asks to confirm the ip, which it shouldn't) then you should be in the ubuntu server (it should say
ubuntu@ip-172-31-17-157:~$
to the left of where you're typing) - im splitting this step up because its a lot, so here you go:
a. you need to create a projects and scoutingapp2024 directory, so you'll use
mkdir
. domkdir projects
to create a directory called "projects" b. dosudo apt update
to update the apt and then dosudo apt install python3
(must have pythong 3.10 or higher, you can dopython3 --version
to check) c. dosudo apt-get install python3-pip
to install pip (you can also check what version you're using withpython3 -m pip --version
) d. ok now you gotta install all of the pip packages (you can find this on the github in the readme for furture reference) using this scriptpython3 -m pip install --upgrade Flask google-api-python-client google-auth-httplib2 google-auth-oauthlib waitress
e. then docd projects
to relocate into the project folder, then clone the scoutingapp2024 repo usinggit clone [put repo url here] [whatever you put after the url is what the folder will be called]
f. then docd [whatever you called the folder]
to relocate into the scoutingapp2024 folder - open up another terminal and do
cd [where your scoutingapp2024 folder is located]
- put in the script
scp -i [where your key.pem file is located] config.json token.json ubuntu@[ip]:~/projects/[whatever you called the scoutingapp2024 folder in the ubuntu server]/
(think back to step 5 part e) if that all worked, you can go back to the original terminal with you being in the ubuntu server - do
ls
to ensure theconfig.json
andtoken.json
are in the scoutingapp2024 folder, as well as everything else thats in the scoutingapp2024 repo (make sure you are in the ubuntu server) - you should now be ready to run the ip and host the scouting app. to do this, you must enter in
python3 main.py --port[port number]
(i use 2048 but you must have it above 1023 and below 49151? not sure the exact number of how high you can go, but i know you must be above 1023) - if it says its running on
serving 0.0.0.0 on port [port number]
then go into your local browser, and type in[ip]:[port number]
to run the app. - and that's it
- if you wanna run it with nohup, which gets rid of a servers hang up so it can still run with the laptop in sleep mode or just off, you must run
nohup python3 main.py --port[port number] &
.serving 0.0.0.0 on port [port number]
will not appear if you run it with nohup, you can still runtop
though. you can also press enter and if it basically dupes the last line no problem, its running. if it ever doesn't do that, the server is rather slow or has stopped running, which you should then have to stop the instance and start it up again (wait for its status to be STOPPED to start it up again) - if you get an error that says something like
nohup: ignoring input and appending output to 'nohup.out'
runcat nohup.out
- you dont have to repeat all of these steps every single time you want to host the ip btw, you only need to do it once (unless you change the
config.json
ortoken.json
) you have to do a. runssh -i [key.pem file] ubuntu@[ip]
b. type incd projects
thencd [what you called the scoutingapp2024 folder in the ubuntu server
c. (OPTIONAL) only do this if you pushed anything to the repo: dogit fetch
and thengit pull
d. runpython3 main.py --port[port number]
or the nohup version - if you want to edit the
config.json
ortoken.json
you would typevim token.js
, then copy local contents, then paste into remote, and to exit you would pressesc
and then:wq
If you ever want to stress test the server for testing, you can use siege
which is used for load testing and server benchmarking servers (not rainbow 6 siege you troglodytes). if you wanna test it, you would:
- do step 14 except dont do the last part yet
- do
sudo apt-get update
,sudo apt-get install apache2-utils
,sudo apt-get install sysbench
,sudo apt-get install stress-ng
,sudo apt install siege
- open up another terminal and also do step 14 except the last part
- go back to the first terminal and then host the ip using
python3 main.py --port[port number]
or the nohup version - go to the second terminal and run
siege -c [concurrent users] -r [number of repetitions] [url]
- this should simulate however many users however many times you want where you're hosting the ip, causing stress (which is what you want for stress testing)
hey, you, yes you, whoever you may be in the future, if you want to contact us or have any questions about the scouting app, do so by emailing us!
Max Maginnis : maxmaginnis@yahoo.com
or luigikid76@gmail.com
Charles Hecker : thecheckerbro2007@gmail.com
Aiden Mcmanus : aidenjohnmcmanus@gmail.com
Jonah Abellano : jonahabellano@gmail.com
Peter D’Amico : wpeterdiv@gmail.com
Do not delete the coconut -Maginnis and Goodyear