Changeset - 697f99bacb55
[Not reviewed]
version_5
0 1 0
Dennis Fink - 9 years ago 2015-10-15 01:55:15
dennis.fink@c3l.lu
Also remove the json file in the data dir if a server is removed
1 file changed with 6 insertions and 0 deletions:
0 comments (0 inline, 0 general)
ennstatus/cli/commands/config.py
Show inline comments
 
@@ -71,24 +71,30 @@ def add(obj, name, ips, password, bridge
 
        json.dump(config, f, indent=4, sort_keys=True)
 

	
 

	
 
@server.command('delete', short_help='Remove server')
 
@click.argument('name')
 
@click.pass_obj
 
def delete(obj, name):
 

	
 
    with obj['config_file'].open() as f:
 
        config = json.load(f)
 
    name = name.lower()
 

	
 
    try:
 
        del config['ENNSTATUS_SERVERS'][name]
 
    except KeyError:
 
        raise SystemExit('{} does not exists!'.format(name))
 

	
 
    try:
 
        config['ENNSTATUS_BRIDGE_PROGRAM'].remove(name)
 
    except KeyError:
 
        pass
 

	
 
    with obj['config_file'].open(mode='w', encoding='utf-8') as f:
 
        json.dump(config, f, indent=4, sort_keys=True)
 

	
 
    filename = obj['data_dir'] / (name + '.json')
 
    try:
 
        filename.unlink()
 
    except FileNotFoundError:
 
        pass
0 comments (0 inline, 0 general)