/canedge_http

Access the CANedge via HTTP

Primary LanguagePython

CANedge HTTP

Python module for accessing the CANedge via HTTP. The CANedge HTTP interface can e.g. be used to automatically poll and then delete log files stored on the CANedge.

The module supports download, deletion, and listing of files on the CANedge.

Installation

pip install canedge_http

Tools

  • ce_http_downloader: Download log files filtered by start and end-time. Run ce_http_downloader --help for information on usage.

Usage

Import

from canedge_http import CANedgeHTTP

Construct

http = CANedgeHTTP("http://192.168.1.100")

Device ID

http.device_id

Result example:

'AABBCCDD'

Permission

http.permission

Result example:

'OPTIONS, GET, HEAD, PUT, DELETE'

List files

for elm in http.list(path="/", recursive=True):
   ...

Result example (elm):

{'path': '/device.json', 'is_dir': False, 'lastWritten': datetime.datetime(2024, 7, 12, 5, 3, 12, tzinfo=datetime.timezone.utc), 'size': 601}

Download

Download takes a file-like object, e.g.

f = io.BytesIO()
http.download("/device.json", f)

or

with open("00000001.MF4", "wb") as f:
    http.download("/LOG/AABBCCDD/00000001/00000001.MF4", f)

Delete

http.delete("/LOG/AABBCCDD/00000001/00000001.MF4")