main()   A
last analyzed

Complexity

Conditions 4

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 4.1755

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 4
c 1
b 0
f 0
dl 0
loc 10
ccs 7
cts 9
cp 0.7778
crap 4.1755
rs 9.2
1
#!/usr/bin/env python
2 1
import click
3
4 1
from redis import Redis
5 1
from rq import Connection, Worker
6
7
8 1
@click.command(help='''
9
Start an impulsare worker
10
11
In case of error, try ``queue-listener --debug -c my_config.yml``
12
''', name='queue-listener')
13 1
@click.option('--debug/--no-debug', '-d', default=False)
14 1
@click.option('--host', '-h', required=True, help='Host')
15 1
@click.option('--port', '-p', default=6379, help='Redis Port')
16 1
@click.option('--queue', '-q', required=True, help='Queue to listen')
17 1
def cli(debug: bool, host: str, port: int, queue: str):
0 ignored issues
show
Unused Code introduced by
The argument debug seems to be unused.
Loading history...
18 1
    with Connection(Redis(host, port)):
19 1
        Worker(queue).work()
20
21
22 1
def main():
23 1
    try:
24 1
        cli()
25 1
    except Exception as e:
26 1
        import sys
27 1
        if '--debug' in sys.argv or '-d' in sys.argv:
28 1
            raise e
29
30
        print(click.style(str(e), fg='red'), file=sys.stderr)
31
        sys.exit(1)
32
33
34 1
if __name__ == '__main__':
35
    main()
36