|
@@ -1298,49 +1298,6 @@ def hermes_is_connected(config: PlatformConfig) -> bool:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-# ---------------------------------------------------------------------------
|
|
|
|
|
-# YAML → env config bridge
|
|
|
|
|
-# ---------------------------------------------------------------------------
|
|
|
|
|
-
|
|
|
|
|
-@DeprecationWarning
|
|
|
|
|
-def hermes_apply_yaml_config_fn(yaml_dict: dict, platform_dict: dict) -> Optional[dict]:
|
|
|
|
|
- """Translate config.yaml chatto.extra keys into CHATTO_* env vars.
|
|
|
|
|
- I don't actually get why Hermes wants us to modify OS environment variables.
|
|
|
|
|
- Bad behavior in my book.
|
|
|
|
|
-
|
|
|
|
|
- Also .. I don't think we need this"""
|
|
|
|
|
-
|
|
|
|
|
- if not isinstance(platform_dict, dict):
|
|
|
|
|
- platform_dict = {}
|
|
|
|
|
- extra = platform_dict.get("extra", {}) or {}
|
|
|
|
|
- if not isinstance(extra, dict):
|
|
|
|
|
- extra = {}
|
|
|
|
|
-
|
|
|
|
|
- for yaml_key, env_key in ChattoConstants.EXTRA_ENV_MAPPING.items():
|
|
|
|
|
- val = extra.get(yaml_key)
|
|
|
|
|
- if val is not None and not os.getenv(env_key):
|
|
|
|
|
- if isinstance(val, bool):
|
|
|
|
|
- env_val = str(val).lower()
|
|
|
|
|
- elif isinstance(val, list):
|
|
|
|
|
- env_val = ",".join(str(v) for v in val)
|
|
|
|
|
- else:
|
|
|
|
|
- env_val = str(val)
|
|
|
|
|
- os.environ[env_key] = env_val
|
|
|
|
|
-
|
|
|
|
|
- channels = extra.get(ChattoConfiguration.channels.field_name)
|
|
|
|
|
- if isinstance(channels, list) and not os.getenv(ChattoConfiguration.channels.env_name):
|
|
|
|
|
- os.environ[ChattoConfiguration.channels.env_name] = ",".join(str(c) for c in channels)
|
|
|
|
|
-
|
|
|
|
|
- allowed = extra.get(ChattoConfiguration.allowed_users.field_name)
|
|
|
|
|
- if isinstance(allowed, list) and not os.getenv(ChattoConfiguration.allowed_users.env_name):
|
|
|
|
|
- os.environ[ChattoConfiguration.allowed_users.env_name] = ",".join(str(u) for u in allowed)
|
|
|
|
|
-
|
|
|
|
|
- if ChattoConfiguration.allow_all_users.field_name in extra and not os.getenv(ChattoConfiguration.allow_all_users.env_name):
|
|
|
|
|
- os.environ[ChattoConfiguration.allow_all_users.env_name] = str(extra[ChattoConfiguration.allow_all_users.field_name]).lower()
|
|
|
|
|
-
|
|
|
|
|
- return None
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
def hermes_setup_fn() -> None:
|
|
def hermes_setup_fn() -> None:
|
|
|
"""Interactive setup wizard for Chatto. Is called by and only works in Hermes CLI context.
|
|
"""Interactive setup wizard for Chatto. Is called by and only works in Hermes CLI context.
|
|
|
Function name should be the same as register argument name with "hermes_" prefix, so we
|
|
Function name should be the same as register argument name with "hermes_" prefix, so we
|
|
@@ -1442,7 +1399,6 @@ def register(ctx) -> None:
|
|
|
install_hint=ChattoConstants.INSTALL_HINT,
|
|
install_hint=ChattoConstants.INSTALL_HINT,
|
|
|
env_enablement_fn=hermes_env_enablement_fn,
|
|
env_enablement_fn=hermes_env_enablement_fn,
|
|
|
setup_fn=hermes_setup_fn,
|
|
setup_fn=hermes_setup_fn,
|
|
|
- apply_yaml_config_fn=hermes_apply_yaml_config_fn,
|
|
|
|
|
cron_deliver_env_var=ChattoConfiguration.home_channel.env_name,
|
|
cron_deliver_env_var=ChattoConfiguration.home_channel.env_name,
|
|
|
standalone_sender_fn=hermes_standalone_sender_fn,
|
|
standalone_sender_fn=hermes_standalone_sender_fn,
|
|
|
allowed_users_env=ChattoConfiguration.allowed_users.env_name,
|
|
allowed_users_env=ChattoConfiguration.allowed_users.env_name,
|