|
@@ -52,29 +52,35 @@ from gateway.config import Platform, PlatformConfig
|
|
|
# Using vendored chattolib from vendor/chattolib/
|
|
# Using vendored chattolib from vendor/chattolib/
|
|
|
# See vendor_chattolib.sh for how to update the vendored copy
|
|
# See vendor_chattolib.sh for how to update the vendored copy
|
|
|
|
|
|
|
|
|
|
+# Absolute imports — vendor/ is on sys.path (see above) and chattolib's own
|
|
|
|
|
+# modules import each other absolutely. Mixing in relative ".vendor.chattolib"
|
|
|
|
|
+# imports would load a second, distinct copy of every module, so isinstance()
|
|
|
|
|
+# checks across the two copies would silently fail.
|
|
|
try:
|
|
try:
|
|
|
- # Try vendored chattolib first
|
|
|
|
|
- from .vendor.chattolib.client import (
|
|
|
|
|
|
|
+ from chattolib.client import (
|
|
|
ChattoClient,
|
|
ChattoClient,
|
|
|
)
|
|
)
|
|
|
- from .vendor.chattolib.exceptions import (
|
|
|
|
|
|
|
+ from chattolib.exceptions import (
|
|
|
ChattoAuthError,
|
|
ChattoAuthError,
|
|
|
ChattoError,
|
|
ChattoError,
|
|
|
)
|
|
)
|
|
|
- from .vendor.chattolib.realtime import (
|
|
|
|
|
|
|
+ from chattolib.realtime import (
|
|
|
ChattoRealtimeError,
|
|
ChattoRealtimeError,
|
|
|
ChattoRealtimeCloseError, RealtimeEvent,
|
|
ChattoRealtimeCloseError, RealtimeEvent,
|
|
|
stream_events
|
|
stream_events
|
|
|
)
|
|
)
|
|
|
- from .vendor.chattolib.realtime_types import (
|
|
|
|
|
|
|
+ from chattolib.realtime_types import (
|
|
|
MessagePostedPayload
|
|
MessagePostedPayload
|
|
|
)
|
|
)
|
|
|
- from .vendor.chattolib.types import (
|
|
|
|
|
|
|
+ from chattolib.types import (
|
|
|
PresenceStatus, RoomKind, User
|
|
PresenceStatus, RoomKind, User
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
except ImportError as e:
|
|
except ImportError as e:
|
|
|
|
|
+ # Fail loudly: continuing here only defers the failure to a confusing
|
|
|
|
|
+ # NameError somewhere deep in the adapter.
|
|
|
logger.error("Chatto: failed to import vendored chattolib: %s", e)
|
|
logger.error("Chatto: failed to import vendored chattolib: %s", e)
|
|
|
|
|
+ raise
|
|
|
|
|
|
|
|
|
|
|
|
|
from .platform_config import (
|
|
from .platform_config import (
|
|
@@ -1254,11 +1260,10 @@ def hermes_check_fn() -> bool:
|
|
|
"""Check if Chatto is configured and dependencies are available.
|
|
"""Check if Chatto is configured and dependencies are available.
|
|
|
Add real logic?! Or just .. there are no dependencies.. always return true. Really. Docs suck."""
|
|
Add real logic?! Or just .. there are no dependencies.. always return true. Really. Docs suck."""
|
|
|
try:
|
|
try:
|
|
|
- from .vendor.chattolib.client import ChattoClient
|
|
|
|
|
|
|
+ import chattolib.client # noqa: F401 — vendored dependency probe
|
|
|
return True
|
|
return True
|
|
|
except ImportError:
|
|
except ImportError:
|
|
|
return False
|
|
return False
|
|
|
- return True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# ---------------------------------------------------------------------------
|