Service webgui
webgui.py
The web-based graphical user interface of mercure.
- class webgui.CSPMiddleware(app: Callable[[MutableMapping[str, Any], Callable[[], Awaitable[MutableMapping[str, Any]]], Callable[[MutableMapping[str, Any]], Awaitable[None]]], Awaitable[None]], dispatch: Optional[Callable[[Request, Callable[[Request], Awaitable[Response]]], Awaitable[Response]]] = None)[source]
Bases:
BaseHTTPMiddleware
- webgui.DEBUG_MODE: bool
- class webgui.ExtendedUser(username: str, is_admin: bool = False)[source]
Bases:
SimpleUser
- property is_admin: bool
- webgui.SECRET_KEY: Secret
- webgui.WEBGUI_HOST: str
- webgui.WEBGUI_PORT: int
- async webgui.configuration(request) Response [source]
Shows the current configuration of the mercure appliance.
- async webgui.configuration_edit_post(request) Response [source]
Updates the configuration after post from editor
- async webgui.emergency_response(request) Response [source]
Shows emergency message about invalid configuration.
- async webgui.error(request)[source]
An example error. Switch the debug setting to see either tracebacks or 500 pages.
- webgui.get_nomad_logs(service, log_size: int) bytes [source]
Reads the service log when running a nomad-type installation.
- async webgui.homepage(request) Response [source]
Renders the index page that shows information about the system status.
- webgui.launch_emergency_app() None [source]
Launches a minimal application to inform the user about the incorrect configuration
- async webgui.login_post(request) Response [source]
Evaluate the submitted login information. Redirects to index page if login information valid, otherwise back to login. On the first login, the user will be directed to the settings page and asked to change the password.
- async webgui.self_test_cleanup(test_id: str, delay: int = 60) None [source]
Delete the rules and targets for this test after a delay
- async webgui.settings_edit(request) Response [source]
Shows the settings for the current user. Renders the same template as the normal user edit, but with parameter own_settings=True.
- async webgui.show_first_log(request) Response [source]
Get the first service entry and forward to corresponding log entry point.
api.py
API backend functions for AJAX querying from the web frontend.
common.py
Helper functions for the graphical user interface of mercure.
- async webinterface.common.async_run(cmd, **params) Tuple[Optional[int], bytes, bytes] [source]
Executes the given command in a way compatible with ayncio.
- async webinterface.common.async_run_exec(*args, **params) Tuple[Optional[int], bytes, bytes] [source]
Executes the given command in a way compatible with ayncio.
- webinterface.common.get_csp_nonce(request=None) dict [source]
Returns the CSP nonce for the current request.
- class webinterface.dicom_client.SimpleDicomClient(host, port, called_aet, calling_aet, out_dir)[source]
Bases:
object
- called_aet: str
- host: str
- output_dir: str
- port: int
modules.py
Modules page for the graphical user interface of mercure.
- async webinterface.modules.add_module(request)[source]
Creates a new module and forwards the user to the module edit page.
- async webinterface.modules.delete_module(request)[source]
Deletes the module with the given module name.
- async webinterface.modules.edit_module(request)[source]
Show the module edit page for the given module name.
- async webinterface.modules.edit_module_POST(request)[source]
Save the settings for the given module name.
queue.py
Queue page for the graphical user interface of mercure.
- class webinterface.queue.RestartTaskErrors(value)[source]
Bases:
str
,Enum
An enumeration.
- CURRENTLY_PROCESSING = 'currently_processing'
- FAILED_TO_ADD_PROCESSING = 'failed_to_add_processing'
- NO_AS_RECEIVED = 'no_as_received'
- NO_DISPATCH_STATUS = 'no_dispatch_status'
- NO_RULE_APPLIED = 'no_rule_applied'
- NO_TASK_FILE = 'no_task_file'
- TASK_NOT_READY = 'not_ready'
- WRONG_JOB_TYPE = 'wrong_type'
- webinterface.queue.is_dispatch_failure(taskfile_folder: Path) bool [source]
Determines if a task in the error folder is a dispatch failure.
- async webinterface.queue.restart_job(request)[source]
Restarts a failed job. This endpoint handles both dispatch and processing failures.
- webinterface.queue.restart_processing_task(task_id: str, source_folder: Path, is_error: bool = False) Dict [source]
Restarts a processing task by moving it from the source folder (error or success) to the processing folder.
- Args:
task_id: The ID of the task to restart source_folder: Path to the task folder in the source directory (error or success) is_error: Whether the source folder is the error folder (True) or success folder (False)
- Returns:
Dict with success or error information
rules.py
Rules page for the graphical user interface of mercure.
- async webinterface.rules.add_rule(request) Response [source]
Creates a new routing rule and forwards the user to the rule edit page.
- async webinterface.rules.duplicate_rule(request) Response [source]
Duplicates an existing routing rule.
- async webinterface.rules.rules(request) Response [source]
Show all defined routing rules. Can be executed by all logged-in users.
- async webinterface.rules.rules_delete_post(request) Response [source]
Deletes the given routing rule
- async webinterface.rules.rules_edit(request) Response [source]
Shows the edit page for the given routing rule.
- async webinterface.rules.rules_edit_post(request) Response [source]
Updates the settings for the given routing rule.
services.py
Helper functions for controlling the services from the graphical user interface of mercure.
targets.py
Targets page for the graphical user interface of mercure.
- async webinterface.targets.targets_delete_post(request) Response [source]
Deletes the given target.
- async webinterface.targets.targets_edit(request) Response [source]
Shows the edit page for the given target.
users.py
Users page and user support functions for the graphical user interface of mercure.
- class webinterface.users.User(*args, **kwargs)[source]
Bases:
dict
- change_password: Literal['True', 'False']
- email: str
- is_admin: Literal['True', 'False']
- password: str
- permissions: Any
- async webinterface.users.add_new_user(request) Response [source]
Creates a new user and redirects to the user-edit page.
- webinterface.users.create_users() Dict[str, User] [source]
Create new users file and create seed admin account with name “admin” and password “router”.
- webinterface.users.evaluate_password(username, password) bool [source]
Check if the given password for the given user is correct. Hashed passwords are stored with salt.
- webinterface.users.hash_password(password) str [source]
Hash the password using the passlib library.
- webinterface.users.is_admin(username) bool [source]
Check in the user list if the given user has admin rights.
- webinterface.users.needs_change_password(username) bool [source]
Check if the given user has to change his password after login.
- webinterface.users.read_users() Dict[str, User] [source]
Reads the user list from the configuration file. The file will only be read if it has been updated since the last function call. If the file does not exist, create a new user file.
Dashboards
common.py
- class webinterface.dashboards.common.ClassBasedRQTask(parent: Optional[str] = None, type: str = 'unknown', _job: Optional[rq.job.Job] = None, _queue: str = '')[source]
Bases:
object
- static move_to_destination(path: str, destination: Optional[str], job_id: str, node: Union[DicomTarget, DicomWebTarget], force_rule: Optional[str] = None) None [source]
- parent: Optional[str] = None
- type: str = 'unknown'
- class webinterface.dashboards.common.JSONErrorResponse(message: str, status_code: int = 500)[source]
Bases:
JSONResponse
- webinterface.dashboards.common.invoke_getdcmtags(file: Path, node: Optional[Union[DicomTarget, DicomWebTarget]], force_rule: Optional[str] = None)[source]
dicomweb.py
DICOMweb interface for handling DICOM uploads via STOW-RS protocol.
- class webinterface.dashboards.dicomweb.MultipartData(dicoms, zips, form_data)[source]
Bases:
object
- dicoms: List[bytes]
- form_data: List[bytes]
- zips: List[bytes]
- webinterface.dashboards.dicomweb.extract_zip(zip_file: ZipFile, extract_to: str, force_rule: Optional[str]) int [source]
- async webinterface.dashboards.dicomweb.parse_multipart_data(request: Request) MultipartData [source]