Exemple #1
0
def update(name, value):
    """set the passed key by the corresponding toml value."""
    try:
        config, obj, prop = traverse_config(name)
        if not isinstance(obj, dict) or prop not in obj:
            raise KeyError()
        value = decode_toml_value(value)
        validate_type(obj[prop], value)
        obj[prop] = value
        update_config(config)
    except KeyError:
        click.echo('Key doens\'t exist. Type "jsctl config list-all" to see all valid configurations.')
    except TypeError as e:
        click.echo(str(e))
    else:
        click.echo("Updated.")
Exemple #2
0
 def set_default(self, name):
     config = get_config()
     config["threebot"]["default"] = name
     update_config(config)
     self.__class__._me = None
Exemple #3
0
DEFAULT_LOGGING_CONFIG = {
    "handlers": [
        # {"sink": "sys.stdout", "format": "{time} - {message}", "colorize":True, "enqueue":True},
        {
            "sink": os.path.join(logs_dir, "file_jumpscale.log"),
            "serialize": True,
            "enqueue": True
        }
    ]
}

js_config = get_config()
if not "logging" in js_config or js_config["logging"]["handlers"] == [{}]:
    # FIXME: doesn't work as expected..
    js_config["logging"] = DEFAULT_LOGGING_CONFIG
    update_config(js_config)

js_config = get_config()
assert js_config["logging"] and js_config["logging"]["handlers"] != [{}]
# js_config = get_jumpscale_config()
# loguruconfig = js_config.get("logging")
logging_config = js_config["logging"]

# QUESTION: how to pass sink sys.stdout in json config?
logging_config["handlers"].append({
    "sink": sys.stdout,
    "format": "{time} - {message}",
    "colorize": True,
    "enqueue": True
})
logger.configure(**logging_config)
Exemple #4
0
def update(name, value):
    config = get_config()
    config[name] = value
    update_config(config)

    click.echo("Updated.")