windborne 1.1.0__py3-none-any.whl → 1.1.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- windborne/cli.py +3 -2
- windborne/data_api.py +42 -26
- {windborne-1.1.0.dist-info → windborne-1.1.1.dist-info}/METADATA +1 -1
- {windborne-1.1.0.dist-info → windborne-1.1.1.dist-info}/RECORD +7 -7
- {windborne-1.1.0.dist-info → windborne-1.1.1.dist-info}/WHEEL +0 -0
- {windborne-1.1.0.dist-info → windborne-1.1.1.dist-info}/entry_points.txt +0 -0
- {windborne-1.1.0.dist-info → windborne-1.1.1.dist-info}/top_level.txt +0 -0
windborne/cli.py
CHANGED
@@ -365,12 +365,13 @@ def main():
|
|
365
365
|
)
|
366
366
|
|
367
367
|
elif args.command == 'flying-missions':
|
368
|
-
get_flying_missions(
|
368
|
+
get_flying_missions(output_file=args.output, print_results=(not args.output))
|
369
369
|
|
370
370
|
elif args.command == 'launch-site':
|
371
371
|
get_mission_launch_site(
|
372
372
|
mission_id=args.mission_id,
|
373
|
-
output_file=args.output
|
373
|
+
output_file=args.output,
|
374
|
+
print_result=(not args.output)
|
374
375
|
)
|
375
376
|
|
376
377
|
elif args.command == 'predict-path':
|
windborne/data_api.py
CHANGED
@@ -257,6 +257,9 @@ def get_observations_core(api_args, csv_headers, get_page, start_time=None, end_
|
|
257
257
|
For example, for 6-hour buckets centered on 00 UTC, the start time should be 21 UTC of the previous day.
|
258
258
|
|
259
259
|
Args:
|
260
|
+
api_args (dict): Arguments to pass to the API endpoint.
|
261
|
+
csv_headers (list): Headers for CSV files.
|
262
|
+
get_page (callable): Function to fetch a page of observations.
|
260
263
|
start_time (str): A date string, supporting formats YYYY-MM-DD HH:MM:SS, YYYY-MM-DD_HH:MM and ISO strings,
|
261
264
|
representing the starting time of fetching data.
|
262
265
|
end_time (str): Optional. A date string, supporting formats YYYY-MM-DD HH:MM:SS, YYYY-MM-DD_HH:MM and ISO strings,
|
@@ -531,7 +534,7 @@ def poll_super_observations(**kwargs):
|
|
531
534
|
# ------------
|
532
535
|
# METADATA
|
533
536
|
# ------------
|
534
|
-
def get_flying_missions(
|
537
|
+
def get_flying_missions(output_file=None, print_results=False):
|
535
538
|
"""
|
536
539
|
Retrieves a list of currently flying missions.
|
537
540
|
In CLI mode, displays missions in a formatted table.
|
@@ -539,6 +542,7 @@ def get_flying_missions(from_cli=None, output_file=None):
|
|
539
542
|
Args:
|
540
543
|
output_file (str): Optional path to save the response data.
|
541
544
|
If provided, saves the data in CSV or JSON format.
|
545
|
+
print_results (bool): Whether to print the results in the CLI.
|
542
546
|
|
543
547
|
Returns:
|
544
548
|
dict: The API response containing list of flying missions.
|
@@ -549,35 +553,47 @@ def get_flying_missions(from_cli=None, output_file=None):
|
|
549
553
|
flying_missions = flying_missions_response.get("missions", [])
|
550
554
|
|
551
555
|
# Display currently flying missions only if we are in cli and we don't save info in file
|
552
|
-
if
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
556
|
+
if print_results:
|
557
|
+
if flying_missions:
|
558
|
+
print("Currently flying missions:\n")
|
559
|
+
|
560
|
+
# Define headers and data
|
561
|
+
headers = ["Index", "Mission ID", "Mission Name"]
|
562
|
+
rows = [
|
563
|
+
[str(i), mission.get("id", "N/A"), mission.get("name", "Unnamed Mission")]
|
564
|
+
for i, mission in enumerate(flying_missions, start=1)
|
565
|
+
]
|
566
|
+
|
567
|
+
# Kinda overkill | but it's a good practice if we ever change missions naming convention
|
568
|
+
# Calculate column widths
|
569
|
+
col_widths = [max(len(cell) for cell in col) + 2 for col in zip(headers, *rows)]
|
570
|
+
|
571
|
+
# Display table
|
572
|
+
print("".join(f"{headers[i]:<{col_widths[i]}}" for i in range(len(headers))))
|
573
|
+
print("".join("-" * col_width for col_width in col_widths))
|
574
|
+
for row in rows:
|
575
|
+
print("".join(f"{row[i]:<{col_widths[i]}}" for i in range(len(row))))
|
576
|
+
else:
|
577
|
+
print("No missions are currently flying.")
|
571
578
|
|
572
579
|
if output_file:
|
573
580
|
save_arbitrary_response(output_file, flying_missions_response, csv_data_key='missions')
|
574
581
|
|
575
|
-
return
|
582
|
+
return flying_missions
|
576
583
|
|
577
584
|
|
578
|
-
def get_mission_launch_site(mission_id=None, output_file=None):
|
585
|
+
def get_mission_launch_site(mission_id=None, output_file=None, print_result=False):
|
579
586
|
"""
|
580
587
|
Retrieves launch site information for a specified mission.
|
588
|
+
|
589
|
+
Args:
|
590
|
+
mission_id (str): The ID of the mission to fetch the launch site for.
|
591
|
+
output_file (str): Optional path to save the response data.
|
592
|
+
If provided, saves the data in CSV format.
|
593
|
+
print_result (bool): Whether to print the results in the CLI.
|
594
|
+
|
595
|
+
Returns:
|
596
|
+
dict: The API response containing the launch site information.
|
581
597
|
"""
|
582
598
|
if not mission_id:
|
583
599
|
print("Must provide mission ID")
|
@@ -586,7 +602,7 @@ def get_mission_launch_site(mission_id=None, output_file=None):
|
|
586
602
|
url = f"{DATA_API_BASE_URL}/missions/{mission_id}/launch_site.json"
|
587
603
|
response = make_api_request(url)
|
588
604
|
|
589
|
-
if response and
|
605
|
+
if response and print_result:
|
590
606
|
launch_site = response.get('launch_site')
|
591
607
|
if isinstance(launch_site, dict):
|
592
608
|
print("Mission launch site\n")
|
@@ -599,7 +615,7 @@ def get_mission_launch_site(mission_id=None, output_file=None):
|
|
599
615
|
if output_file:
|
600
616
|
save_arbitrary_response(output_file, response, csv_data_key='launch_site')
|
601
617
|
|
602
|
-
return response
|
618
|
+
return response.get('launch_site')
|
603
619
|
|
604
620
|
def get_predicted_path(mission_id=None, output_file=None):
|
605
621
|
"""
|
@@ -612,7 +628,7 @@ def get_predicted_path(mission_id=None, output_file=None):
|
|
612
628
|
If provided, saves the data in CSV format.
|
613
629
|
|
614
630
|
Returns:
|
615
|
-
|
631
|
+
list: The API response containing the predicted flight path data.
|
616
632
|
"""
|
617
633
|
if not mission_id:
|
618
634
|
print("To get the predicted flight path for a given mission you must provide a mission ID.")
|
@@ -655,4 +671,4 @@ def get_predicted_path(mission_id=None, output_file=None):
|
|
655
671
|
if output_file:
|
656
672
|
save_arbitrary_response(output_file, response, csv_data_key='prediction')
|
657
673
|
|
658
|
-
return response
|
674
|
+
return response.get('prediction')
|
@@ -1,13 +1,13 @@
|
|
1
1
|
windborne/__init__.py,sha256=0bPtPzBG3djZMVfyUNhapiEqCSyN8SSDsm_eCZ4kwhc,1783
|
2
2
|
windborne/api_request.py,sha256=J7kcCC3xiISHnrTLxMkFQCEu8rg8UntYvFfP5wkLabQ,11117
|
3
|
-
windborne/cli.py,sha256=
|
3
|
+
windborne/cli.py,sha256=hAnG1n6ZDICqj3nvjS8Xkc3psLeL-Hxewkmy-FABSCU,35807
|
4
4
|
windborne/cyclone_formatting.py,sha256=0S8S_PflRGm6ftUlyR2aGGyX6IRn0hbUTEWptu7f8Q8,7886
|
5
|
-
windborne/data_api.py,sha256=
|
5
|
+
windborne/data_api.py,sha256=JBdedKWdx3eXKz0wGKqDLkR-QYl8O2SjutPL3LPx4l8,30457
|
6
6
|
windborne/forecasts_api.py,sha256=-IM78Dr10rV-CKVqRWXpptJPe7Hh64DNMO3P3zVgvuQ,13790
|
7
7
|
windborne/observation_formatting.py,sha256=c739aaun6aaYhXl5VI-SRGR-TDS355_0Bfu1t6McoiM,14993
|
8
8
|
windborne/utils.py,sha256=AJhvdwtfDrV0NQyN_I5JxXr6K3UgFlPCwUGqApe-c2E,6431
|
9
|
-
windborne-1.1.
|
10
|
-
windborne-1.1.
|
11
|
-
windborne-1.1.
|
12
|
-
windborne-1.1.
|
13
|
-
windborne-1.1.
|
9
|
+
windborne-1.1.1.dist-info/METADATA,sha256=W5ZRFOnDBarbmqo8Wr4Ix8NWC47VqpsYaQYLVo3W5Vk,1235
|
10
|
+
windborne-1.1.1.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
11
|
+
windborne-1.1.1.dist-info/entry_points.txt,sha256=j_YrqdCDrCd7p5MIwQ2BYwNXEi95VNANzLRJmcXEg1U,49
|
12
|
+
windborne-1.1.1.dist-info/top_level.txt,sha256=PE9Lauriu5S5REf7JKhXprufZ_V5RiZ_TnfnrLGJrmE,10
|
13
|
+
windborne-1.1.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|