Passed
Pull Request — master (#974)
by Konstantin
02:57
created

ocrd.cli.processing_server   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 21
dl 0
loc 42
rs 10
c 0
b 0
f 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A processing_server_cli() 0 25 1
1
"""
2
OCR-D CLI: start the processing server
3
4
.. click:: ocrd.cli.processing_server:processing_server_cli
5
    :prog: ocrd processing-server
6
    :nested: full
7
"""
8
import click
9
import logging
10
from ocrd_utils import initLogging
11
from ocrd_network import (
12
    ProcessingServer,
13
    ProcessingServerParamType
14
)
15
16
17
@click.command('processing-server')
18
@click.argument('path_to_config', required=True, type=click.STRING)
19
@click.option('-a', '--address',
20
              default="localhost:8080",
21
              help='The URL of the Processing server, format: host:port',
22
              type=ProcessingServerParamType(),
23
              required=True)
24
def processing_server_cli(path_to_config, address: str):
25
    """
26
    Start and manage processing workers with the processing server
27
28
    PATH_TO_CONFIG is a yaml file to configure the server and the workers. See
29
    https://github.com/OCR-D/spec/pull/222/files#diff-a71bf71cbc7d9ce94fded977f7544aba4df9e7bdb8fc0cf1014e14eb67a9b273
30
    for further information (TODO: update path when spec is available/merged)
31
32
    """
33
    initLogging()
34
    # TODO: Remove before the release
35
    logging.getLogger('paramiko.transport').setLevel(logging.INFO)
36
    logging.getLogger('ocrd.network').setLevel(logging.DEBUG)
37
38
    # Note, the address is already validated with the type field
39
    host, port = address.split(':')
40
    processing_server = ProcessingServer(path_to_config, host, port)
41
    processing_server.start()
42