def add_default_options(): existing_option = Options.query.filter(Options.name == PolyLogyxServerDefaults.plgx_config_all_options).first() data = { "schedule_splay_percent": 10} for k, v in data.items(): option = Options.query.filter(Options.name == k).first() if option: option.option = v option.update(option) else: Options.create(name=k, option=v) if existing_option: existing_option.option = json.dumps(data) existing_option.update(option) else: Options.create(name=PolyLogyxServerDefaults.plgx_config_all_options, option=json.dumps(data)) exit(0)
def add_default_options(): existing_option = Options.query.filter( Options.name == PolyLogyxServerDefaults.plgx_config_all_options).first() for k, v in PolyLogyxConstants.DEFAULT_OPTIONS.items(): option = Options.query.filter(Options.name == k).first() if option: option.option = v option.update(option) else: Options.create(name=k, option=v) if existing_option: existing_option.option = json.dumps(PolyLogyxConstants.DEFAULT_OPTIONS) existing_option.update(option) else: Options.create(name=PolyLogyxServerDefaults.plgx_config_all_options, option=json.dumps(PolyLogyxConstants.DEFAULT_OPTIONS)) exit(0)
def create_option_by_option(option): return Options.create(name=PolyLogyxServerDefaults.plgx_config_all_options, option=option)
def create_option(k, v): return Options.create(name=k, option=v)