def checkJsonStatus(j): data = "" status = -1 try: data = json.loads(j) except: WARNING("can't read JSON") try: if ("status" in data): status = int(data["status"]) except: WARNING("can't parse status") return status
def putTextFile(f, t): try: fid = open(f, "w") fid.write(t) fid.close() except Exception as e: WARNING(e) return False return True
def checkJsonData(j, field): data = "" status = -1 retval = "" DEBUG("Json string " + j) try: data = json.loads(j) except: WARNING("can't read JSON") return retval if ("data" in data): d = data["data"] if (field in d): retval = d[field] else: DEBUG("no field " + field + " in data") else: WARNING("No data in JSON") return retval
def getTextFile(f): result = "" if not os.path.exists(f): DEBUG(f + " not found") return result try: fid = open(f, "r") result = fid.read() fid.close() except Exception as e: WARNING(e) return result
def reset(): # Cannot reset if database is running if CONFIG.status == 1 or CONFIG.status == 2: WARNING("Cannot RESET while database is starting or running") return ping() # Reset to default settings for deployment etc. d = buildinstancedir(CONFIG.id) CONFIG.data["hoststring"] = "" instance.data["deployment"] = getDefaultDeployment() CONFIG.status = k_status_none CONFIG.pid = 0 # overrite existing deployment file etc. putIntFile(CONFIG.dataroot + instance.dataroot + "/STATUS", instance.status) putTextFile(CONFIG.dataroot + instance.dataroot + "/deployment.xml", instance.data["deployment"]) return ping()
def set(data): # Cannot set if database is running if CONFIG.status == 1 or CONFIG.status == 2: WARNING("Cannot SET while database is starting or running") return ping() # set the specified data (received as JSON) d = json.loads(data) DEBUG("SET(): " + str(d)) hostcount = 1 if "hoststring" in d: CONFIG.data["hoststring"] = d["hoststring"] hosts = d["hoststring"].split(",") hostcount = len(hosts) if "deployment" in d: CONFIG.data["deployment"] = d["deployment"] if "args" in d: CONFIG.data["args"] = d["args"] # and then return the resulting instance and/or error CONFIG.timestamp = CONFIG.timestamp + 1 return currentResponse()
from tab5.init_tab5 import init_tab5 # Custom parser from custom_config_parser import custom_config_parser from tooltip_label import tooltip_label # Utils from utils import check_corrupt, check_running, ERROR, WARNING # read user and create config location user = os.environ.get('USER') config_path = os.environ.get('QUANDENSER_CONFIG_PATH') print("Config", config_path) if (config_path is None) or config_path == "": config_path = f"/home/{user}/.quandenser_pipeline" WARNING(f"QUANDENSER_CONFIG_PATH not set. Defaulting to {config_path}") #print(Style.BRIGHT, end='\r') # Set style class Main(QMainWindow): def __init__(self): super().__init__() self.title = 'Quandenser-pipeline' self.setWindowIcon(QIcon('images/logo.png')) QFontDatabase.addApplicationFont("fonts/rockwell.ttf") self.resize(1000, 800) # Check file integrity check_corrupt(config_path) self.paths = {} self.paths['config'] = f"{config_path}"