diff options
| author | Loic Guegan <loic.guegan@mailbox.org> | 2023-10-25 17:11:07 +0200 |
|---|---|---|
| committer | Loic Guegan <loic.guegan@mailbox.org> | 2023-10-25 17:11:07 +0200 |
| commit | c035f62a4972a5255b2621d24c604d21da76d3d3 (patch) | |
| tree | 534e722de99a6b6a27dcf758738ae48f7e47f8b3 | |
| parent | bdd896b87bf14d8630175247d7db8603c60609e5 (diff) | |
Minor changes
| -rw-r--r-- | clusterman/__main__.py | 6 | ||||
| -rw-r--r-- | clusterman/config.py | 14 |
2 files changed, 15 insertions, 5 deletions
diff --git a/clusterman/__main__.py b/clusterman/__main__.py index 13f4cbd..56c9f60 100644 --- a/clusterman/__main__.py +++ b/clusterman/__main__.py @@ -1,5 +1,5 @@ import argparse,sys -from clusterman.config import Config +from clusterman.config import * from clusterman.commands import node def main(): @@ -15,12 +15,10 @@ def main(): # Parse arguments: args = parser.parse_args() - a=Config() - # Run the proper handler if args.command == "node": print("Do node related stuff") - + if args.command == "frontend": print("Do frontend related stuff") diff --git a/clusterman/config.py b/clusterman/config.py index b4547de..fefd753 100644 --- a/clusterman/config.py +++ b/clusterman/config.py @@ -1,16 +1,22 @@ from pathlib import Path import os, json + class Config: CONF_DIR=os.path.join(os.environ['HOME'],".clusterman/") CONF_FILE=os.path.join(CONF_DIR,"clusterman.json") + DEFAULT_CONFIG = { + "paths": { + "nodes": os.path.join(CONF_DIR,"nodeslist.json") + } + } def __init__(self): Path(self.CONF_DIR).mkdir(parents=True, exist_ok=True) + self.config=self.DEFAULT_CONFIG self.load() def load(self): - self.config={"example":None} if os.path.exists(self.CONF_FILE): with open(self.CONF_FILE) as f: self.config=json.load(f) @@ -23,3 +29,9 @@ class Config: def __getitem__(self, key): return self.config[key] + + def __setitem__(self, key, value): + self.config[key]=value + + +CONF=Config() |
