Esempio n. 1
0
def delete_pages(config):
    """Delete data pages from robot"""

    bosdyn.client.util.setup_logging(config.verbose)
    sdk = bosdyn.client.create_standard_sdk('DeletePagesClient')
    robot = sdk.create_robot(config.hostname)
    robot.authenticate(config.username, config.password)
    service_client = robot.ensure_client(
        DataServiceClient.default_service_name)

    start_timestamp = None
    end_timestamp = None
    time_range = None

    time_sync_endpoint = None
    if not config.robot_time:
        # Establish time sync with robot to obtain skew.
        time_sync_client = robot.ensure_client(
            TimeSyncClient.default_service_name)
        time_sync_endpoint = TimeSyncEndpoint(time_sync_client)
        if not time_sync_endpoint.establish_timesync():
            raise NotEstablishedError("time sync not established")

    if config.timespan:
        time_range = timespec_to_robot_timespan(config.timespan,
                                                time_sync_endpoint)

    print(service_client.delete_data_pages(time_range, config.id))
Esempio n. 2
0
def run_query(options, query):
    """Get data index from robot"""

    bosdyn.client.util.setup_logging(options.verbose)
    sdk = bosdyn.client.create_standard_sdk('GetIndexClient')
    robot = sdk.create_robot(options.hostname)
    robot.authenticate(options.username, options.password)
    service_client = robot.ensure_client(
        DataServiceClient.default_service_name)

    time_sync_endpoint = None
    if not options.robot_time:
        # Establish time sync with robot to obtain skew.
        time_sync_client = robot.ensure_client(
            TimeSyncClient.default_service_name)
        time_sync_endpoint = TimeSyncEndpoint(time_sync_client)
        if not time_sync_endpoint.establish_timesync():
            raise NotEstablishedError("time sync not established")

    # Now assemble the query to obtain a bddf file.

    # Get the parameters for limiting the timespan of the response.
    # pylint: disable=no-member
    query.time_range.CopyFrom(
        timespec_to_robot_timespan(options.timespan, time_sync_endpoint))
    return service_client.get_data_index(query)
Esempio n. 3
0
def get_pages(options):
    """Get data pages from robot"""

    bosdyn.client.util.setup_logging(options.verbose)
    sdk = bosdyn.client.create_standard_sdk('GetPagesClient')
    robot = sdk.create_robot(options.hostname)
    robot.authenticate(options.username, options.password)
    service_client = robot.ensure_client(
        DataServiceClient.default_service_name)

    time_sync_endpoint = None
    if not options.robot_time:
        # Establish time sync with robot to obtain skew.
        time_sync_client = robot.ensure_client(
            TimeSyncClient.default_service_name)
        time_sync_endpoint = TimeSyncEndpoint(time_sync_client)
        if not time_sync_endpoint.establish_timesync():
            raise NotEstablishedError("time sync not established")

    resp = service_client.get_data_pages(
        timespec_to_robot_timespan(options.timespan, time_sync_endpoint))
    print("-------- {} pages --------\n".format(len(resp.pages)))
    for page in resp.pages:
        _show_page(page)
Esempio n. 4
0
def _request_timespan_from_spec(timespec, time_sync_endpoint):
    return _request_timespan_from_time_range(
        timespec_to_robot_timespan(timespec, time_sync_endpoint))