Correct CSV and sqlite support for location group
Add CSV header and sqlite schema support for the newly added location group, along with the necessary functions in the starlink_grpc module to expose the field names and types for that group. This really should have gone in with the prior change. Also, correct the order of the ping_latency and ping_loaded_latency groups in the CSV header, which was backwards. This would have resulted in an incorrect CSV header if both those groups were selected.
This commit is contained in:
parent
29699f0f59
commit
8650687f69
3 changed files with 42 additions and 17 deletions
|
@ -46,7 +46,7 @@ import time
|
|||
import dish_common
|
||||
import starlink_grpc
|
||||
|
||||
SCHEMA_VERSION = 3
|
||||
SCHEMA_VERSION = 4
|
||||
|
||||
|
||||
class Terminated(Exception):
|
||||
|
@ -208,8 +208,10 @@ def ensure_schema(opts, conn, context):
|
|||
|
||||
def create_tables(conn, context, suffix):
|
||||
tables = {}
|
||||
name_groups = starlink_grpc.status_field_names(context=context)
|
||||
type_groups = starlink_grpc.status_field_types(context=context)
|
||||
name_groups = (starlink_grpc.status_field_names(context=context) +
|
||||
(starlink_grpc.location_field_names(),))
|
||||
type_groups = (starlink_grpc.status_field_types(context=context) +
|
||||
(starlink_grpc.location_field_types(),))
|
||||
tables["status"] = zip(name_groups, type_groups)
|
||||
|
||||
name_groups = starlink_grpc.history_stats_field_names()
|
||||
|
|
|
@ -128,6 +128,7 @@ def print_header(opts, print_file):
|
|||
header.append(name)
|
||||
|
||||
if opts.status_mode:
|
||||
if opts.pure_status_mode:
|
||||
context = starlink_grpc.ChannelContext(target=opts.target)
|
||||
try:
|
||||
name_groups = starlink_grpc.status_field_names(context=context)
|
||||
|
@ -140,6 +141,8 @@ def print_header(opts, print_file):
|
|||
header_add(name_groups[1])
|
||||
if "alert_detail" in opts.mode:
|
||||
header_add(name_groups[2])
|
||||
if "location" in opts.mode:
|
||||
header_add(starlink_grpc.location_field_names())
|
||||
|
||||
if opts.bulk_mode:
|
||||
general, bulk = starlink_grpc.history_bulk_field_names()
|
||||
|
@ -153,10 +156,10 @@ def print_header(opts, print_file):
|
|||
header_add(ping)
|
||||
if "ping_run_length" in opts.mode:
|
||||
header_add(runlen)
|
||||
if "ping_loaded_latency" in opts.mode:
|
||||
header_add(loaded)
|
||||
if "ping_latency" in opts.mode:
|
||||
header_add(latency)
|
||||
if "ping_loaded_latency" in opts.mode:
|
||||
header_add(loaded)
|
||||
if "usage" in opts.mode:
|
||||
header_add(usage)
|
||||
|
||||
|
|
|
@ -776,6 +776,26 @@ def status_data(
|
|||
}, alerts
|
||||
|
||||
|
||||
def location_field_names():
|
||||
"""Return the field names of the location data.
|
||||
|
||||
Returns:
|
||||
A list with location data field names.
|
||||
"""
|
||||
return _field_names(LocationDict)
|
||||
|
||||
|
||||
def location_field_types():
|
||||
"""Return the field types of the location data.
|
||||
|
||||
Return the type classes for each field.
|
||||
|
||||
Returns:
|
||||
A list with location data field types.
|
||||
"""
|
||||
return _field_types(LocationDict)
|
||||
|
||||
|
||||
def get_location(context: Optional[ChannelContext] = None):
|
||||
"""Fetch location data and return it in grpc structure format.
|
||||
|
||||
|
|
Loading…
Reference in a new issue