Passed
Push — master ( 96c9ad...2330e7 )
by Konstantin
03:04
created

ocrd_network.cli.resmgr_server   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 17
dl 0
loc 24
rs 10
c 0
b 0
f 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A resource_manager_server_cli() 0 19 2
1
import click
2
from ocrd_network import ResourceManagerServer, ServerAddressParamType
3
4
5
@click.command('resmgr-server')
6
@click.option('-a', '--address',
7
              help='The URL of the OCR-D resource manager server, format: host:port',
8
              type=ServerAddressParamType(),
9
              required=True)
10
def resource_manager_server_cli(address: str):
11
    """
12
    Start standalone REST API OCR-D Resource Manager Server
13
    """
14
    try:
15
        # Note, the address is already validated with the type field
16
        host, port = address.split(':')
17
        resource_manager_server = ResourceManagerServer(
18
            host = host,
19
            port = int(port)
20
        )
21
        resource_manager_server.start()
22
    except Exception as e:
23
        raise Exception("OCR-D Resource Manager Server has failed with error") from e
24