logreader: support filesystem DATA_ENDPOINT (#34340)

* Check if DATA_ENDPOINT is a dir

* Change url resolution to support joining dirs
pull/34341/head
Kacper Rączy 4 months ago committed by GitHub
parent 89204b5464
commit 5dd1972f96
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 6
      tools/lib/filereader.py

@ -1,4 +1,5 @@
import os
import posixpath
import socket
from urllib.parse import urlparse
@ -8,6 +9,9 @@ DATA_ENDPOINT = os.getenv("DATA_ENDPOINT", "http://data-raw.comma.internal/")
def internal_source_available(url=DATA_ENDPOINT):
if os.path.isdir(url):
return True
try:
hostname = urlparse(url).hostname
port = urlparse(url).port or 80
@ -22,7 +26,7 @@ def internal_source_available(url=DATA_ENDPOINT):
def resolve_name(fn):
if fn.startswith("cd:/"):
return fn.replace("cd:/", DATA_ENDPOINT)
return posixpath.join(DATA_ENDPOINT, fn[4:])
return fn

Loading…
Cancel
Save