Changeset - 3d53c627707a
[Not reviewed]
feature-cli
0 1 0
Dennis Fink - 9 years ago 2015-10-25 22:25:25
dennis.fink@c3l.lu
Disable logging when using the cli tool
1 file changed with 2 insertions and 2 deletions:
0 comments (0 inline, 0 general)
ennstatus/cli/commands/stats.py
Show inline comments
 
@@ -26,25 +26,25 @@ def count(obj, by_type):
 
            hosts = set()
 

	
 
            for values in config['ENNSTATUS_SERVERS'].values():
 
                ips = frozenset(values['IPS'])
 
                hosts.add(ips)
 

	
 
            return len(hosts)
 

	
 

	
 
    app = create_app()
 

	
 
    with app.app_context():
 
        app.logger.removeHandler(app.logger.handlers[1])
 
        app.logger.disabled = True
 
        servers = split_all_servers_to_types()
 

	
 
    if not by_type:
 

	
 
        click.echo(
 
            'We have %s servers in total!' % (
 
                click.style(
 
                    str(sum(len(x) for x in servers.values())),
 
                    fg='blue'
 
                )
 
            )
 
        )
 
@@ -57,25 +57,25 @@ def count(obj, by_type):
 
                )
 
            )
 
        )
 

	
 

	
 
@stats.command('countries')
 
@click.option('--by-type', 'by_type', is_flag=True, default=False)
 
@click.pass_obj
 
def countries(obj, by_type):
 
    app = create_app()
 

	
 
    with app.app_context():
 
        app.logger.removeHandler(app.logger.handlers[1])
 
        app.logger.disabled = True
 
        servers = split_all_servers_to_types()
 

	
 
    if not by_type:
 
        countries = defaultdict(int)
 

	
 
        for key, value in servers.items():
 
            for server in value:
 
                countries[server.country] += 1
 

	
 
        for key, value in sorted(countries.items(), key=lambda x: x[1]):
 
            click.echo(
 
                '%s: %s' % (
0 comments (0 inline, 0 general)