| Total Complexity | 2 |
| Total Lines | 24 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 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 |