1
0
Fork 0

Add command line parsing for token and url

main
Jeff Moe 2023-06-25 15:44:22 -06:00
parent 767ef0ac73
commit aff6c8f018
2 changed files with 25 additions and 36 deletions

View File

@ -65,23 +65,13 @@ pip install -r requirements.txt
# Configure
Configure thusly.
In the `upload` script, set the URL of the DB server to use.
Examples:
Running your own local server:
```
URL_API_BASE = "http://localhost:8000/api"
echo "no configuration ? :)"
```
Using the LSF DB development server:
```
URL_API_BASE = "https://db-dev.satnogs.org/api"
```
Using the LSF DB live production server:
```
URL_API_BASE = "https://db.satnogs.org/api"
```
# Run
Run thusly.
Gently use the development (testing) server to confirm scripts are behaving
correctly, before uploading to the SatNOGS DB production server.
@ -90,31 +80,33 @@ Also, before uploading to the production server, it is probably a good
idea to let the LSF admins know via the #satnogs-optical matrix channel.
Set the token to the API token from the server to use:
```
TOKEN = "d111111111111112222222222222233333333345"
```
Note, the API `TOKEN` is different on the development `db-dev` server
Note, the API token is different on the development `db-dev` server
and the production `db` server.
Set the filepaths to the location of the files to import.
URL for running your own local server:
```
JSON_FILEPATH = "examples/2023-06-25T03-56-23.189_data.json"
PLOT_FILEPATH = "examples/2023-06-25T03-56-23.189_0.png"
http://localhost:8000/api
```
Using the LSF DB development server:
```
https://db-dev.satnogs.org/api
```
# Run
Run thusly.
Using the LSF DB live production server:
```
https://db.satnogs.org/api
```
```
cd satnogs-optical-scripts/
source env/bin/activate
./satnogs-optical-upload --json=examples/2023-06-25T03-56-23.189_data.json \
--plot=examples/2023-06-25T03-56-23.189_0.png
./satnogs-optical-upload \
--json=examples/2023-06-25T03-56-23.189_data.json \
--plot=examples/2023-06-25T03-56-23.189_0.png \
--token="d111111111111112222222222222233333333345" \
--url="http://localhost:8000/api"
```

View File

@ -26,22 +26,19 @@ import json
import requests
import argparse
# Local SatNOGS DB server
URL_API_BASE = "http://localhost:8000/api"
# Libre Space Foundation SatNOGS DB development test server
#URL_API_BASE = "https://db-dev.satnogs.org/"
# Libre Space Foundation SatNOGS DB production server
#URL_API_BASE = "https://db.satnogs.org/"
TIMEOUT = 3
TOKEN = ""
# Parse command line options
parser = argparse.ArgumentParser()
parser.add_argument("-j", "--json", type=str, required=True)
parser.add_argument("-p", "--plot", type=str, required=True)
parser.add_argument("-j", "--json", help="JSON file from stvid", type=str, required=True)
parser.add_argument("-p", "--plot", help="PNG plot from stvid", type=str, required=True)
parser.add_argument("-t", "--token", help="DB API token", type=str, required=True)
parser.add_argument("-u", "--url", help="DB base URL", type=str, required=True)
args = parser.parse_args()
JSON_FILEPATH = args.json
PLOT_FILEPATH = args.plot
TOKEN = args.token
URL_API_BASE = args.url
def print_json(jsn):