mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-02-18 17:43:54 +08:00
logreader: support filesystem DATA_ENDPOINT (#34340)
* Check if DATA_ENDPOINT is a dir * Change url resolution to support joining dirs
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import os
|
import os
|
||||||
|
import posixpath
|
||||||
import socket
|
import socket
|
||||||
from urllib.parse import urlparse
|
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):
|
def internal_source_available(url=DATA_ENDPOINT):
|
||||||
|
if os.path.isdir(url):
|
||||||
|
return True
|
||||||
|
|
||||||
try:
|
try:
|
||||||
hostname = urlparse(url).hostname
|
hostname = urlparse(url).hostname
|
||||||
port = urlparse(url).port or 80
|
port = urlparse(url).port or 80
|
||||||
@@ -22,7 +26,7 @@ def internal_source_available(url=DATA_ENDPOINT):
|
|||||||
|
|
||||||
def resolve_name(fn):
|
def resolve_name(fn):
|
||||||
if fn.startswith("cd:/"):
|
if fn.startswith("cd:/"):
|
||||||
return fn.replace("cd:/", DATA_ENDPOINT)
|
return posixpath.join(DATA_ENDPOINT, fn[4:])
|
||||||
return fn
|
return fn
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user