Skip to content

Commit

Permalink
🚧 update, uuid load from file
Browse files Browse the repository at this point in the history
  • Loading branch information
MeditationDuck committed Nov 28, 2024
1 parent d1da3a4 commit e29c31f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
12 changes: 4 additions & 8 deletions wake/cli/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,17 +277,13 @@ def run_init(

if "wake_remote" not in config.api_keys:
import uuid
# import toml
wake_remote_key = str(uuid.uuid4())
config.update({"api_keys": {"wake_remote": wake_remote_key}}, [])
# global config path already made when WakeConfig was created
if not config.global_config_path.exists():
with config.global_config_path.open("w") as f:
f.write("[api_keys]\n")
f.write(f'wake_remote = "{config.api_keys["wake_remote"]}"\n')
else:
with config.global_config_path.open("a") as f:
f.write("\n")
f.write(f'wake_remote = "{config.api_keys["wake_remote"]}"\n')
wake_remote_file = config.global_config_path.parent / "wake_remote.txt"
with wake_remote_file.open("w") as f:
f.write(config.api_keys["wake_remote"])

if not config.local_config_path.exists() or force:
write_config(config)
Expand Down
5 changes: 5 additions & 0 deletions wake/config/wake_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,11 @@ def load_configs(self) -> None:
self.load(self.global_config_path)
self.load(self.local_config_path)

wake_remote_path = self.global_config_path.parent / "wake_remote.txt"
if wake_remote_path.exists():
with wake_remote_path.open("r") as f:
self.__config.api_keys["wake_remote"] = f.read()

def load(self, path: Path) -> None:
"""
Load config from the provided file path. Any already loaded config options are overridden by the options loaded
Expand Down

0 comments on commit e29c31f

Please sign in to comment.