Skip to content

Commit

Permalink
fix help message format
Browse files Browse the repository at this point in the history
  • Loading branch information
zacharyburnett committed Mar 21, 2021
1 parent b165e07 commit 8c30af7
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 29 deletions.
18 changes: 11 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,35 +62,39 @@ packetraven --callsigns W3EAX-8,W3EAX-14 --apikey <api_key> --gui
## Usage:

```text
usage: packetraven [-h] [--callsigns CALLSIGNS] [--aprsfi-key APRSFI_KEY] [--tnc TNC] [--database DATABASE] [--tunnel TUNNEL]
[--igate] [--start START] [--end END] [--log LOG] [--output OUTPUT] [--prediction PREDICTION]
usage: packetraven [-h] [--callsigns CALLSIGNS] [--aprsfi-key APRSFI_KEY] [--tnc TNC] [--database DATABASE] [--tunnel TUNNEL] [--igate]
[--start START] [--end END] [--log LOG] [--output OUTPUT] [--prediction-output PREDICTION_OUTPUT]
[--prediction-ascent-rate PREDICTION_ASCENT_RATE] [--prediction-burst-altitude PREDICTION_BURST_ALTITUDE]
[--prediction-descent-rate PREDICTION_DESCENT_RATE] [--prediction-api PREDICTION_API] [--interval INTERVAL]
[--gui]
[--prediction-descent-rate PREDICTION_DESCENT_RATE] [--prediction-float-altitude PREDICTION_FLOAT_ALTITUDE]
[--prediction-float-end-time PREDICTION_FLOAT_END_TIME] [--prediction-api PREDICTION_API] [--interval INTERVAL] [--gui]
optional arguments:
-h, --help show this help message and exit
--callsigns CALLSIGNS
comma-separated list of callsigns to track
--aprsfi-key APRSFI_KEY
APRS.fi API key (from https://aprs.fi/page/api)
--tnc TNC comma-separated list of serial ports / text files of a TNC parsing APRS packets from analog audio to
ASCII (set to `auto` to use the first open serial port)
--tnc TNC comma-separated list of serial ports / text files of a TNC parsing APRS packets from analog audio to ASCII (set to
`auto` to use the first open serial port)
--database DATABASE PostGres database table `user@hostname:port/database/table`
--tunnel TUNNEL SSH tunnel `user@hostname:port`
--igate send new packets to APRS-IS
--start START start date / time, in any common date format
--end END end date / time, in any common date format
--log LOG path to log file to save log messages
--output OUTPUT path to output file to save packets
--prediction PREDICTION
--prediction-output PREDICTION_OUTPUT
path to output file to save most up-to-date predicted trajectory
--prediction-ascent-rate PREDICTION_ASCENT_RATE
ascent rate to use for prediction (m/s)
--prediction-burst-altitude PREDICTION_BURST_ALTITUDE
burst altitude to use for prediction (m)
--prediction-descent-rate PREDICTION_DESCENT_RATE
descent rate to use for prediction (m/s)
--prediction-float-altitude PREDICTION_FLOAT_ALTITUDE
float altitude to use for prediction (m)
--prediction-float-end-time PREDICTION_FLOAT_END_TIME
float end time to use for prediction
--prediction-api PREDICTION_API
API URL to use for prediction (one of ['https://predict.cusf.co.uk/api/v1/',
'https://predict.lukerenegar.com/api/v1.1/'])
Expand Down
6 changes: 3 additions & 3 deletions client/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def main():
'--prediction-float-altitude', help='float altitude to use for prediction (m)'
)
args_parser.add_argument(
'--prediction-float-stop-time', help='descent rate to use for prediction (`%Y-%m-%dT%H:%M:%S`)'
'--prediction-float-end-time', help='float end time to use for prediction'
)
args_parser.add_argument(
'--prediction-api',
Expand Down Expand Up @@ -181,8 +181,8 @@ def main():
if args.prediction_float_altitude is not None:
kwargs['prediction_float_altitude'] = float(args.prediction_descent_rate)

if args.prediction_float_stop_time is not None:
kwargs['prediction_float_stop_time'] = parse_date(args.prediction_float_stop_time)
if args.prediction_float_end_time is not None:
kwargs['prediction_float_end_time'] = parse_date(args.prediction_float_end_time)

if args.prediction_api is not None:
kwargs['prediction_api_url'] = args.prediction_api
Expand Down
2 changes: 1 addition & 1 deletion client/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def __init__(
'prediction_burst_altitude': None,
'prediction_sea_level_descent_rate': None,
'prediction_float_altitude': None,
'prediction_float_stop_time': None,
'prediction_float_end_time': None,
'prediction_api_url': None,
},
}
Expand Down
34 changes: 17 additions & 17 deletions packetraven/predicts.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def __init__(
burst_altitude: float,
sea_level_descent_rate: float,
float_altitude: float = None,
float_stop_time: datetime = None,
float_end_time: datetime = None,
name: str = None,
):
"""
Expand All @@ -50,7 +50,7 @@ def __init__(
:param burst_altitude: altitude at which balloon will burst
:param sea_level_descent_rate: descent rate at sea level (m/s)
:param float_altitude: altitude of float (m)
:param float_stop_time: date and time of float end
:param float_end_time: date and time of float end
:param name: name of prediction track
"""

Expand All @@ -64,9 +64,9 @@ def __init__(
if launch_time.tzinfo is None or launch_time.tzinfo.utcoffset(launch_time) is None:
launch_time = UTC_TIMEZONE.localize(launch_time)

if float_stop_time is not None:
if float_stop_time.tzinfo is None or float_stop_time.tzinfo.utcoffset(float_stop_time) is None:
float_stop_time = UTC_TIMEZONE.localize(float_stop_time)
if float_end_time is not None:
if float_end_time.tzinfo is None or float_end_time.tzinfo.utcoffset(float_end_time) is None:
float_end_time = UTC_TIMEZONE.localize(float_end_time)

self.api_url = api_url
self.launch_site = launch_site
Expand All @@ -75,7 +75,7 @@ def __init__(
self.burst_altitude = burst_altitude
self.sea_level_descent_rate = sea_level_descent_rate
self.float_altitude = float_altitude
self.float_stop_time = float_stop_time
self.float_end_time = float_end_time
self.name = name

@property
Expand Down Expand Up @@ -112,12 +112,12 @@ def __init__(
version: float = None,
dataset_time: datetime = None,
float_altitude: float = None,
float_stop_time: datetime = None,
float_end_time: datetime = None,
api_url: PredictionAPIURL = None,
name: str = None,
):
if profile is None:
if float_altitude is not None or float_stop_time is not None:
if float_altitude is not None or float_end_time is not None:
profile = FlightProfile.float
else:
profile = FlightProfile.standard
Expand All @@ -143,7 +143,7 @@ def __init__(
burst_altitude,
sea_level_descent_rate,
float_altitude,
float_stop_time,
float_end_time,
name,
)

Expand Down Expand Up @@ -181,10 +181,10 @@ def query(self) -> {str: Any}:
if self.profile == FlightProfile.float:
if self.float_altitude is None:
self.float_altitude = self.burst_altitude
if self.float_stop_time is None:
raise PredictionError('float stop time `float_stop_time` not provided')
if self.float_end_time is None:
raise PredictionError('float stop time `float_end_time` not provided')
query['float_altitude'] = self.float_altitude
query['stop_datetime'] = self.float_stop_time.isoformat()
query['stop_datetime'] = self.float_end_time.isoformat()

return query

Expand Down Expand Up @@ -219,7 +219,7 @@ def get(self) -> {str: Any}:
version=self.version,
dataset_time=self.dataset_time,
float_altitude=None,
float_stop_time=None,
float_end_time=None,
api_url=self.api_url,
name=self.name,
)
Expand Down Expand Up @@ -284,7 +284,7 @@ def __init__(
version: float = None,
dataset_time: datetime = None,
float_altitude: float = None,
float_stop_time: datetime = None,
float_end_time: datetime = None,
api_url: str = None,
name: str = None,
):
Expand All @@ -304,7 +304,7 @@ def __init__(
version,
dataset_time,
float_altitude,
float_stop_time,
float_end_time,
api_url,
name,
)
Expand Down Expand Up @@ -342,7 +342,7 @@ def get_predictions(
burst_altitude: float = None,
sea_level_descent_rate: float = None,
float_altitude: float = None,
float_stop_time: datetime = None,
float_end_time: datetime = None,
api_url: str = None,
) -> [PredictedTrajectory]:
if api_url is None:
Expand Down Expand Up @@ -372,7 +372,7 @@ def get_predictions(
burst_altitude=burst_altitude,
sea_level_descent_rate=sea_level_descent_rate,
float_altitude=float_altitude,
float_stop_time=float_stop_time,
float_end_time=float_end_time,
api_url=api_url,
name=name,
)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_predicts.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def test_float_prediction():

cusf_api = CUSFBalloonPredictionQuery(
launch_site, launch_datetime, ascent_rate, burst_altitude, descent_rate,
float_stop_time=datetime.now() + timedelta(seconds=burst_altitude / ascent_rate) + timedelta(hours=1)
float_end_time=datetime.now() + timedelta(seconds=burst_altitude / ascent_rate) + timedelta(hours=1)
)

response_json = cusf_api.get()
Expand Down

0 comments on commit 8c30af7

Please sign in to comment.