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()