Utility

class sitchlib.Utility[source]

General utility class.

classmethod calculate_distance(lon_1, lat_1, lon_2, lat_2)[source]

Wrap the LocationTool.get_distance_between_points() fn.

classmethod construct_feed_file_name(feed_dir, prefix)[source]

Construct full path for feed file.

classmethod create_file_if_nonexistent(path, lfile)[source]

Create file and path, if it doesn’t already exist.

classmethod create_path_if_nonexistent(path)[source]

Create filesystem directory path.

classmethod dt_delta_in_minutes(dt_1, dt_2)[source]

Calculate the delta between two datetime objects, in minutes.

classmethod dt_from_iso(iso_time)[source]

Exchange an ISO8601-formatted string for a datetime object.

classmethod epoch_to_iso8601(unix_time)[source]

Transform epoch time to ISO8601 format.

classmethod get_now_string()[source]

Get ISO8601 timestamp for now.

classmethod get_performance_metrics(application_uptime_s, queue_sizes={})[source]

Get sensor hardware and os performance statistics.

classmethod get_platform_info()[source]

Get information on platform and hardware.

classmethod get_platform_name()[source]

Get platform name from lshw output.

classmethod get_public_ip()[source]

Get public IP.

classmethod heartbeat(service_name)[source]

Generate heartbeat message.

classmethod hex_to_dec(hx)[source]

Change hex to decimal.

classmethod is_valid_json(in_str)[source]

Test string for json validity.

classmethod pretty_string(structure)[source]

Pretty-print lines.

classmethod start_component(runcmd)[source]

Start a thing.

classmethod str_to_float(s)[source]

Change string to float.

classmethod strip_list(raw_struct)[source]

Strip contents from single-item list.

classmethod validate_geojson(geojson)[source]

Ensure that geojson contains the right fields

classmethod write_file(location, contents)[source]

Write string to file.