ocrd.mets_server module

# METS server functionality

class ocrd.mets_server.OcrdFileModel(*, file_grp: str, file_id: str, mimetype: str, page_id: str | None = None, url: str | None = None, local_filename: str | None = None)[source]

Bases: BaseModel

Create a new model by parsing and validating input data from keyword arguments.

Raises ValidationError if the input data cannot be parsed to form a valid model.

file_grp: str
file_id: str
mimetype: str
page_id: str | None
url: str | None
local_filename: str | None
static create(file_grp: str, file_id: str, page_id: str | None, url: str | None, local_filename: str | Path | None, mimetype: str)[source]
class ocrd.mets_server.OcrdAgentModel(*, name: str, type: str, role: str, otherrole: str | None = None, othertype: str, notes: List[Tuple[Dict[str, str], str | None]] | None = None)[source]

Bases: BaseModel

Create a new model by parsing and validating input data from keyword arguments.

Raises ValidationError if the input data cannot be parsed to form a valid model.

name: str
type: str
role: str
otherrole: str | None
othertype: str
notes: List[Tuple[Dict[str, str], str | None]] | None
static create(name: str, _type: str, role: str, otherrole: str, othertype: str, notes: List[Tuple[Dict[str, str], str | None]])[source]
class ocrd.mets_server.OcrdFileListModel(*, files: List[OcrdFileModel])[source]

Bases: BaseModel

Create a new model by parsing and validating input data from keyword arguments.

Raises ValidationError if the input data cannot be parsed to form a valid model.

files: List[OcrdFileModel]
static create(files: List[OcrdFile])[source]
class ocrd.mets_server.OcrdFileGroupListModel(*, file_groups: List[str])[source]

Bases: BaseModel

Create a new model by parsing and validating input data from keyword arguments.

Raises ValidationError if the input data cannot be parsed to form a valid model.

file_groups: List[str]
static create(file_groups: List[str])[source]
class ocrd.mets_server.OcrdAgentListModel(*, agents: List[OcrdAgentModel])[source]

Bases: BaseModel

Create a new model by parsing and validating input data from keyword arguments.

Raises ValidationError if the input data cannot be parsed to form a valid model.

agents: List[OcrdAgentModel]
static create(agents: List[OcrdAgent])[source]
class ocrd.mets_server.ClientSideOcrdMets(url, workspace_path: str | None = None)[source]

Bases: object

Partial substitute for ocrd_models.ocrd_mets.OcrdMets which provides for ocrd_models.ocrd_mets.OcrdMets.find_files(), ocrd_models.ocrd_mets.OcrdMets.find_all_files(), and ocrd_models.ocrd_mets.OcrdMets.add_agent(), ocrd_models.ocrd_mets.OcrdMets.agents(), ocrd_models.ocrd_mets.OcrdMets.add_file() to query via HTTP a ocrd.mets_server.OcrdMetsServer.

property session: Session | Session
save()[source]

Request writing the changes to the file system

stop()[source]

Request stopping the mets server

reload()[source]

Request reloading of the mets file from the file system

property unique_identifier
property workspace_path
property file_groups
property agents
add_agent(*args, **kwargs)[source]
find_files(**kwargs)[source]
find_all_files(*args, **kwargs)[source]
add_file(file_grp, content=None, file_id=None, url=None, local_filename=None, mimetype=None, page_id=None, **kwargs)[source]
class ocrd.mets_server.MpxReq[source]

Bases: object

This class wrapps the request bodies needed for the tcp forwarding

For every mets-server-call like find_files or workspace_path a special request_body is needed to call MetsServerProxy.forward_tcp_request. These are created by this functions.

Reason to put this to a separate class is to allow easier testing

static save(ws_dir_path: str) Dict[source]
static stop(ws_dir_path: str) Dict[source]
static reload(ws_dir_path: str) Dict[source]
static unique_identifier(ws_dir_path: str) Dict[source]
static workspace_path(ws_dir_path: str) Dict[source]
static file_groups(ws_dir_path: str) Dict[source]
static agents(ws_dir_path: str) Dict[source]
static add_agent(ws_dir_path: str, agent_model: Dict) Dict[source]
static find_files(ws_dir_path: str, params: Dict) Dict[source]
static add_file(ws_dir_path: str, data: Dict) Dict[source]
class ocrd.mets_server.OcrdMetsServer(workspace, url)[source]

Bases: object

static create_process(mets_server_url: str, ws_dir_path: str, log_file: str) int[source]
static kill_process(mets_server_pid: int)[source]
shutdown()[source]
startup()[source]
ocrd.mets_server.is_socket_in_use(socket_path)[source]