def __init__(self, target=None):
     # counter for bulk_history:
     self.counter = None
     # counter for history stats:
     self.counter_stats = None
     self.timestamp = None
     self.dish_id = None
     self.context = starlink_grpc.ChannelContext(target=target)
     self.poll_count = 0
     self.prev_history = None
def main():
    # This part is optional. The `starlink_grpc` functions can work without a
    # `starlink_grpc.ChannelContext` object passed in, but they will open a
    # new channel for each RPC call (so twice for each loop iteration) without
    # it.
    context = starlink_grpc.ChannelContext()

    try:
        run_loop(context)
    finally:
        context.close()
def print_header(opts):
    header = ["datetimestamp_utc"]

    def header_add(names):
        for name in names:
            name, start, end = dish_common.BRACKETS_RE.match(name).group(
                1, 4, 5)
            if start:
                header.extend(name + "_" + str(x)
                              for x in range(int(start), int(end)))
            elif end:
                header.extend(name + "_" + str(x) for x in range(int(end)))
            else:
                header.append(name)

    if opts.satus_mode:
        context = starlink_grpc.ChannelContext(target=opts.target)
        try:
            name_groups = starlink_grpc.status_field_names(context=context)
        except starlink_grpc.GrpcError as e:
            dish_common.conn_error(
                opts, "Failure reflecting status field names: %s", str(e))
            return 1
        if "status" in opts.mode:
            header_add(name_groups[0])
        if "obstruction_detail" in opts.mode:
            header_add(name_groups[1])
        if "alert_detail" in opts.mode:
            header_add(name_groups[2])

    if opts.bulk_mode:
        general, bulk = starlink_grpc.history_bulk_field_names()
        header_add(general)
        header_add(bulk)

    if opts.history_stats_mode:
        groups = starlink_grpc.history_stats_field_names()
        general, ping, runlen, latency, loaded, usage = groups[0:6]
        header_add(general)
        if "ping_drop" in opts.mode:
            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 "usage" in opts.mode:
            header_add(usage)

    print(",".join(header))
    return 0
def main():
    opts = parse_args()

    logging.basicConfig(format="%(levelname)s: %(message)s")

    context = starlink_grpc.ChannelContext(target=opts.target)

    try:
        next_loop = time.monotonic()
        while True:
            rc = loop_body(opts, context)
            if opts.loop_interval > 0.0:
                now = time.monotonic()
                next_loop = max(next_loop + opts.loop_interval, now)
                time.sleep(next_loop - now)
            else:
                break
    finally:
        context.close()

    sys.exit(rc)
 def __init__(self):
     self.counter = None
     self.timestamp = None
     self.dish_id = None
     self.context = starlink_grpc.ChannelContext()