mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-09-30 23:33:42 +08:00
[sunnylink] Swaglogs to cloudwatch Enable log_handler in sunnylinkd.py
This commit is contained in:
@@ -1,5 +1,12 @@
|
||||
import os
|
||||
import errno
|
||||
import platform
|
||||
|
||||
if platform.system() == 'Darwin': # macOS
|
||||
from xattr import getxattr as _getxattr
|
||||
from xattr import setxattr as _setxattr
|
||||
else:
|
||||
from os import getxattr as _getxattr
|
||||
from os import setxattr as _setxattr
|
||||
|
||||
_cached_attributes: dict[tuple, bytes | None] = {}
|
||||
|
||||
@@ -7,10 +14,10 @@ def getxattr(path: str, attr_name: str) -> bytes | None:
|
||||
key = (path, attr_name)
|
||||
if key not in _cached_attributes:
|
||||
try:
|
||||
response = os.getxattr(path, attr_name)
|
||||
response = _getxattr(path, attr_name)
|
||||
except OSError as e:
|
||||
# ENODATA means attribute hasn't been set
|
||||
if e.errno == errno.ENODATA:
|
||||
if e.errno == errno.ENODATA or e.errno == errno.ENOATTR:
|
||||
response = None
|
||||
else:
|
||||
raise
|
||||
@@ -19,4 +26,4 @@ def getxattr(path: str, attr_name: str) -> bytes | None:
|
||||
|
||||
def setxattr(path: str, attr_name: str, attr_value: bytes) -> None:
|
||||
_cached_attributes.pop((path, attr_name), None)
|
||||
return os.setxattr(path, attr_name, attr_value)
|
||||
return _setxattr(path, attr_name, attr_value)
|
||||
Reference in New Issue
Block a user