mirror of
https://gitlab.com/manzerbredes/clusterman.git
synced 2025-04-06 03:56:27 +02:00
Minor changes
This commit is contained in:
parent
bdd896b87b
commit
c035f62a49
2 changed files with 15 additions and 5 deletions
|
@ -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")
|
||||
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Add table
Reference in a new issue