mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-05-07 06:23:26 +08:00
* remove old logging references * cli as logging subapp option * changing the subapp to the cli on init
35 lines
1.0 KiB
Python
35 lines
1.0 KiB
Python
"""OpenBB Platform CLI utilities."""
|
|
|
|
import json
|
|
from pathlib import Path
|
|
|
|
HOME_DIRECTORY = Path.home()
|
|
OPENBB_PLATFORM_DIRECTORY = Path(HOME_DIRECTORY, ".openbb_platform")
|
|
SYSTEM_SETTINGS_PATH = Path(OPENBB_PLATFORM_DIRECTORY, "system_settings.json")
|
|
|
|
|
|
def change_logging_sub_app() -> str:
|
|
"""Build OpenBB Platform setting files."""
|
|
with open(SYSTEM_SETTINGS_PATH) as file:
|
|
system_settings = json.load(file)
|
|
|
|
initial_logging_sub_app = system_settings.get("logging_sub_app", "")
|
|
|
|
system_settings["logging_sub_app"] = "cli"
|
|
|
|
with open(SYSTEM_SETTINGS_PATH, "w") as file:
|
|
json.dump(system_settings, file, indent=4)
|
|
|
|
return initial_logging_sub_app
|
|
|
|
|
|
def reset_logging_sub_app(initial_logging_sub_app: str):
|
|
"""Reset OpenBB Platform setting files."""
|
|
with open(SYSTEM_SETTINGS_PATH) as file:
|
|
system_settings = json.load(file)
|
|
|
|
system_settings["logging_sub_app"] = initial_logging_sub_app
|
|
|
|
with open(SYSTEM_SETTINGS_PATH, "w") as file:
|
|
json.dump(system_settings, file, indent=4)
|