API reference
This reference is generated from source docstrings via Sphinx autodoc.
mirror
mirror.command
mirror.config
- mirror.config.load(conf_path)[source]
Loads the main config file, derives other paths from it, synchronizes with the persistent stat file, and loads the state into the application.
- Parameters:
conf_path (Path)
- mirror.config.reload()[source]
Reloads all configurations.
This is now a thin wrapper around
_perform_reload; see that function for the orchestration details.- Return type:
mirror.event
- mirror.event.on(event_name, listener=None, priority=50)[source]
Register a listener for an event, or return a decorator if listener is omitted.
- mirror.event.once(event_name, listener, priority=50)[source]
Register a one-shot listener via the global manager.
- mirror.event.off(event_name, listener)[source]
Unregister a listener via the global manager.
- Parameters:
event_name (str) – Event name the listener is registered under.
listener (Callable) – Listener to remove.
- Return type:
None
- mirror.event.post_event(event_name, *args, wait=False, **kwargs)[source]
Fire an event via the global manager.
- mirror.event.listener(event_name, priority=50)[source]
Decorator to register a function as an event listener.
- class mirror.event.EventManager(max_workers=20)[source]
Bases:
objectCentral event management system using Pub/Sub pattern. Supports synchronous and asynchronous (threaded) listeners.
- Parameters:
max_workers (int)
- on(event_name, listener, priority=50)[source]
Register a listener for a specific event.
Lower priority number means higher precedence (executes earlier).
- once(event_name, listener, priority=50)[source]
Register a one-shot listener that auto-removes itself after first invocation.
- off(event_name, listener)[source]
Unregister a previously registered listener.
- Parameters:
event_name (str) – Event name the listener is registered under.
listener (Callable) – Listener to remove.
- Return type:
None
mirror.logger
- class mirror.logger.PromptHandler(stream=None)[source]
Bases:
StreamHandlerLog handler that prints via prompt_toolkit ANSI when the terminal supports it, and falls back to plain text otherwise.
- emit(record)[source]
Emit a record.
If a formatter is specified, it is used to format the record. The record is then written to the stream with a trailing newline. If exception information is present, it is formatted using traceback.print_exception and appended to the stream. If the stream has an ‘encoding’ attribute, it is used to determine how to do the output to the stream.
- Parameters:
record (LogRecord)
- Return type:
None
- class mirror.logger.DynamicGzipRotatingFileHandler(base_path, folder_template, filename_template, gzip_enabled=True, encoding='utf-8', delay=False)[source]
Bases:
FileHandlerFileHandler that rotates when the formatted path changes. Supports dynamic folders and filenames based on time templates.
- Parameters:
- mirror.logger.input(message=None, *, editing_mode=None, refresh_interval=None, vi_mode=None, lexer=None, completer=None, complete_in_thread=None, is_password=None, key_bindings=None, bottom_toolbar=None, style=None, color_depth=None, cursor=None, include_default_pygments_style=None, style_transformation=None, swap_light_and_dark_colors=None, rprompt=None, multiline=None, prompt_continuation=None, wrap_lines=None, enable_history_search=None, search_ignore_case=None, complete_while_typing=None, validate_while_typing=None, complete_style=None, auto_suggest=None, validator=None, clipboard=None, mouse_support=None, input_processors=None, placeholder=None, reserve_space_for_menu=None, enable_system_prompt=None, enable_suspend=None, enable_open_in_editor=None, tempfile_suffix=None, tempfile=None, show_frame=None, default='', accept_default=False, pre_run=None, set_exception_handler=True, handle_sigint=True, in_thread=False, inputhook=None)
Display the prompt.
The first set of arguments is a subset of the
PromptSessionclass itself. For these, passing inNonewill keep the current values that are active in the session. Passing in a value will set the attribute for the session, which means that it applies to the current, but also to the next prompts.Note that in order to erase a
Completer,ValidatororAutoSuggest, you can’t useNone. Instead pass in aDummyCompleter,DummyValidatororDummyAutoSuggestinstance respectively. For aLexeryou can pass in an emptySimpleLexer.Additional arguments, specific for this prompt:
- Parameters:
default (str | Document) – The default input text to be shown. (This can be edited by the user).
accept_default (bool) – When True, automatically accept the default value without allowing the user to edit the input.
pre_run (Callable[[], None] | None) – Callable, called at the start of Application.run.
in_thread (bool) – Run the prompt in a background thread; block the current thread. This avoids interference with an event loop in the current thread. Like Application.run(in_thread=True).
message (AnyFormattedText | None)
editing_mode (EditingMode | None)
refresh_interval (float | None)
vi_mode (bool | None)
lexer (Lexer | None)
completer (Completer | None)
complete_in_thread (bool | None)
is_password (bool | None)
key_bindings (KeyBindingsBase | None)
bottom_toolbar (AnyFormattedText | None)
style (BaseStyle | None)
color_depth (ColorDepth | None)
cursor (AnyCursorShapeConfig | None)
include_default_pygments_style (FilterOrBool | None)
style_transformation (StyleTransformation | None)
swap_light_and_dark_colors (FilterOrBool | None)
rprompt (AnyFormattedText | None)
multiline (FilterOrBool | None)
prompt_continuation (PromptContinuationText | None)
wrap_lines (FilterOrBool | None)
enable_history_search (FilterOrBool | None)
search_ignore_case (FilterOrBool | None)
complete_while_typing (FilterOrBool | None)
validate_while_typing (FilterOrBool | None)
complete_style (CompleteStyle | None)
auto_suggest (AutoSuggest | None)
validator (Validator | None)
clipboard (Clipboard | None)
mouse_support (FilterOrBool | None)
input_processors (list[Processor] | None)
placeholder (AnyFormattedText | None)
reserve_space_for_menu (int | None)
enable_system_prompt (FilterOrBool | None)
enable_suspend (FilterOrBool | None)
enable_open_in_editor (FilterOrBool | None)
show_frame (FilterOrBool | None)
set_exception_handler (bool)
handle_sigint (bool)
inputhook (InputHook | None)
- Return type:
_T
This method will raise
KeyboardInterruptwhen control-c has been pressed (for abort) andEOFErrorwhen control-d has been pressed (for exit).
- mirror.logger.compress_file(filepath)[source]
Compress a file with gzip and remove the original.
- Parameters:
filepath (str | Path) – Path to the file to compress.
- Returns:
Path to the .gz file, or None if compression failed.
- Return type:
gz_path(Path | None)
- mirror.logger.create_logger(name, start_time)[source]
Create a per-package logger for a sync session.
- Parameters:
- Returns:
Configured logger with file and prompt handlers.
- Return type:
pkg_logger(logging.Logger)
- mirror.logger.close_logger(pkg_logger, compress=None)[source]
Close a package logger and optionally compress the log file.
- Parameters:
pkg_logger (logging.Logger) – The logger to close.
compress (bool, optional) – Override gzip setting. Uses config value if None.
- Returns:
Path to the (compressed) log file, or None if no file handler.
- Return type:
log_path(Path | None)
- mirror.logger.setup_logger()[source]
Configure the main application logger with file and console handlers.
- Return type:
None
- mirror.logger.get_log_path(pkg_logger)[source]
Return the file path used by the logger’s FileHandler, or None.
- Parameters:
pkg_logger (logging.Logger) – Package logger to inspect.
- Returns:
Log file path, or None if no FileHandler is attached.
- Return type:
path(Path | None)
- mirror.logger.get(pkgid)[source]
Return the logger for the given package ID.
- Parameters:
pkgid (str) – Package identifier.
- Returns:
Logger scoped to this package.
- Return type:
- mirror.logger.exists(pkgid)[source]
Return True if the package logger has at least one FileHandler attached.
- mirror.logger.reattach_logger(pkg_logger, log_file_path, pkgid)[source]
Reattach a FileHandler to an existing in-base log file.
Used by on_sync_done after master restart. Performs strict validation: - path resolves inside the configured package log base - opens with O_NOFOLLOW (refuses symlinks atomically) - fstat on the SAME fd confirms regular file with st_nlink == 1 - that same fd is then adopted by SafeAppendFileHandler — no reopen Returns True if a handler was attached, False otherwise.
- Parameters:
pkg_logger (logging.Logger) – Logger to attach a FileHandler to.
log_file_path (Path) – Path to the log file (from stat.json runninglog).
pkgid (str) – Package identifier (used in warning messages).
- Returns:
True if a handler was successfully attached.
- Return type:
attached(bool)
mirror.plugin
Entry-points based plug-in framework for mirror.py.
- Loading splits into two phases:
- Phase A (load_builtin_plugins): imports and registers the five built-in sync
modules at package-import time so mirror.sync.methods is populated before package validation runs.
- Phase B (load_external_plugins): called from mirror.config.load() after the
config dict has been parsed; disables config-disabled built-ins and discovers + registers third-party plug-ins via importlib.metadata.
Per-plugin configuration is read from a JSON file in the same directory as the
main config.json. The default filename is <plugin-name>.json. Operators
can override the filename per-plugin by setting config_filename on the
PluginRecord. The config file is read lazily by get_config() and is never
cached, so changes take effect on the next call.
The plugins block in config.json uses an enable-only shape:
{
"<name>": {"enabled": true}
}
The config sub-key previously accepted in that block is no longer
supported; move any per-plugin settings to <config_dir>/<name>.json.
Versioning
PLUGIN_API_VERSION is a (major, minor) tuple that describes the
plug-in contract implemented by this core release.
major increments on breaking changes (calling convention, factory surface, entry-point groups, plug-in types). A plug-in whose declared major differs from the core major is skipped at load time.
minor increments on additive, backward-compatible changes (new optional hook, new optional field). A plug-in whose declared minor is greater than the core minor is also skipped (it was built against features the core does not yet provide). An older plug-in (declared minor <= core minor) continues to load.
Plug-ins declare their target version via the api_version parameter of the
factory helpers (sync_plugin, event_plugin, status_plugin). The
gate is applied only to external plug-ins loaded in Phase B; built-ins are
loaded ungated in Phase A because they ship in lockstep with the core. A plug-in
that omits api_version (None) still loads but emits a deprecation warning.
- class mirror.plugin.StatusOutput(name, default_path, build, config_path_key=None)[source]
Bases:
objectDeclarative description of an additional status output file written by a status plug-in.
- Parameters:
name (str) – Globally unique output name (across all plug-ins).
default_path (str) – Filesystem path to write the output to. Operator can override via plug-in config if config_path_key is set.
build (Callable) – Callable producing the JSON payload from an iterable of packages.
config_path_key (Optional[str]) – If set, the plug-in’s config dict key whose value (when present) overrides default_path.
- class mirror.plugin.ConfigCreateResult(path, created)[source]
Bases:
objectOutcome of a plug-in’s create_config() call.
- Parameters:
- class mirror.plugin.PluginRecord(name, type, execute=None, on_sync_done=None, setup=None, extend_stat_fields=None, extend_web_status_fields=None, transform_stat_payload=None, transform_web_status_payload=None, outputs=None, create_config=None, config_filename=None, api_version=None)[source]
Bases:
objectTyped descriptor for a registered plug-in.
- Parameters:
name (str) – Globally unique plug-in name.
type (str) – One of “sync”, “event”, or “status”.
execute (Callable, optional) – Sync execute callable. Sync plug-ins only.
on_sync_done (Callable, optional) – Post-sync hook. Sync plug-ins only.
setup (Callable, optional) – Setup callable (required for event plug-ins).
extend_stat_fields (Callable, optional) – Returns extra stat.json fields for a package.
extend_web_status_fields (Callable, optional) – Returns extra web status fields for a package.
transform_stat_payload (Callable, optional) – Transforms the full stat.json payload dict. Single-owner: only one plug-in may register this per daemon instance.
transform_web_status_payload (Callable, optional) – Transforms the full web status payload dict. Single-owner: only one plug-in may register this per daemon instance.
outputs (list, optional) – List of StatusOutput instances describing additional output files this plug-in writes on every status update.
create_config (Callable, optional) – On-demand config-file creation callable. Signature create_config(force: bool) -> ConfigCreateResult. The plug-in writes its own config file at a path/name it owns, reading any global settings from mirror.conf and its own per-plug-in config via mirror.plugin.get_config(<name>); when the file already exists and force is False it skips and returns created=False.
config_filename (str, optional) – Optional override for the per-plugin config filename. Defaults to
<name>.jsonwhen absent. The file is resolved relative to the directory that contains the main config.json.api_version (tuple, optional) –
(major, minor)API version this plug-in was built against. Compared againstPLUGIN_API_VERSIONat load time for external plug-ins.Nonemeans undeclared (loads with a deprecation warning).
- mirror.plugin.sync_plugin(name, execute, on_sync_done=None, setup=None, create_config=None, config_filename=None, api_version=None)[source]
Build a PluginRecord for a sync plug-in with contract validation.
- Parameters:
name (str) – Unique plug-in name.
execute (Callable) – Sync execute callable — must be provided and callable.
on_sync_done (Callable, optional) – Post-sync hook callable.
setup (Callable, optional) – Optional setup callable.
create_config (Callable, optional) – On-demand config-file creation callable.
config_filename (str, optional) – Override for the per-plugin config filename. Defaults to
<name>.jsonwhen absent.api_version (tuple, optional) –
(major, minor)API version this plug-in targets. Validated and stored on the returned PluginRecord.
- Returns:
Validated sync PluginRecord.
- Return type:
record(PluginRecord)
- Raises:
TypeError – If execute is missing or not callable, or api_version has wrong type/shape.
ValueError – If api_version has out-of-range major or minor.
- mirror.plugin.event_plugin(name, setup, create_config=None, config_filename=None, api_version=None)[source]
Build a PluginRecord for an event plug-in with contract validation.
- Parameters:
name (str) – Unique plug-in name.
setup (Callable) – Required setup callable that registers event listeners.
create_config (Callable, optional) – On-demand config-file creation callable.
config_filename (str, optional) – Override for the per-plugin config filename. Defaults to
<name>.jsonwhen absent.api_version (tuple, optional) –
(major, minor)API version this plug-in targets. Validated and stored on the returned PluginRecord.
- Returns:
Validated event PluginRecord.
- Return type:
record(PluginRecord)
- Raises:
TypeError – If setup is missing or not callable, or api_version has wrong type/shape.
ValueError – If api_version has out-of-range major or minor.
- mirror.plugin.status_plugin(name, extend_stat_fields=None, extend_web_status_fields=None, transform_stat_payload=None, transform_web_status_payload=None, outputs=None, setup=None, create_config=None, config_filename=None, api_version=None)[source]
Build a PluginRecord for a status plug-in with contract validation.
- Parameters:
name (str) – Unique plug-in name.
extend_stat_fields (Callable, optional) – Returns extra stat.json fields for a package.
extend_web_status_fields (Callable, optional) – Returns extra web status fields for a package.
transform_stat_payload (Callable, optional) – Transforms the full stat.json payload dict.
transform_web_status_payload (Callable, optional) – Transforms the full web status payload dict.
outputs (list, optional) – List of StatusOutput instances for additional output files.
setup (Callable, optional) – Optional setup callable.
create_config (Callable, optional) – On-demand config-file creation callable.
config_filename (str, optional) – Override for the per-plugin config filename. Defaults to
<name>.jsonwhen absent.api_version (tuple, optional) –
(major, minor)API version this plug-in targets. Validated and stored on the returned PluginRecord.
- Returns:
Validated status PluginRecord.
- Return type:
record(PluginRecord)
- Raises:
TypeError – If none of extend_*, transform_*, or outputs is provided, or if any callable argument is not actually callable, or if outputs items are not StatusOutput instances, or if api_version has wrong type/shape.
ValueError – If api_version has out-of-range major or minor.
- mirror.plugin.load_builtin_plugins()[source]
Phase A: import and register all five built-in sync plug-ins.
Hard-codes the five canonical sync module references so that mirror.sync.methods is fully populated before package validation runs. ImportError for any individual module is logged as a warning and skipped; a successful import that yields a malformed PluginRecord raises immediately (that is a programmer error, not a deployment error).
- Return type:
None
- mirror.plugin.load_external_plugins(plugin_settings)[source]
Phase B: disable built-ins per config and load third-party plug-ins.
Must be called after mirror.conf is populated (i.e., from mirror.config.load()) and before mirror.packages is constructed.
- Parameters:
plugin_settings (dict) – Mapping of plug-in name to PluginSettings (or equivalent with an .enabled bool). Each entry uses the shape
{"<name>": {"enabled": true}}. If this is a plain list (legacy format) a deprecation warning is logged and the function returns without doing anything.- Return type:
None
- mirror.plugin.get_record(name)[source]
Return the registered PluginRecord for the given plug-in name, or None.
- Parameters:
name (str) – Plug-in name to look up.
- Returns:
The registered record, or None if absent.
- Return type:
record(PluginRecord | None)
- mirror.plugin.get_config(name)[source]
Return the per-plug-in config dict for a registered plug-in.
Config is read from a JSON file in the same directory as the main config.json. The filename defaults to
<name>.jsonand can be overridden per-plugin via PluginRecord.config_filename. The file is read on every call (no caching).
mirror.socket
Mirror.py Socket Communication Module
Provides Unix socket IPC between master daemon and worker processes with automatic handshake protocol for version and role exchange.
- class mirror.socket.BaseServer(socket_path, role, socket_uid=None, socket_gid=None, socket_mode=None)[source]
Bases:
objectBase server for Unix socket IPC with handshake and command dispatch
- Parameters:
socket_path (Path | str) – Path to the Unix domain socket file
role (str) – Server role identifier for handshake
socket_uid (int, optional) – UID for chown on the socket file
socket_gid (int, optional) – GID for chown on the socket file
socket_mode (int, optional) – Permission mode for the socket file
- set_version(version)[source]
Set application version for handshake
- Parameters:
version (str) – Version string
- Return type:
None
- register_handler(command, handler)[source]
Register a command handler
- Parameters:
command (str) – Command name
handler (Callable) – Handler function
- Return type:
None
- class mirror.socket.BaseClient(socket_path, role)[source]
Bases:
objectBase client for Unix socket IPC with handshake and async listener
- Parameters:
- set_version(version)[source]
Set application version for handshake
- Parameters:
version (str) – Version string
- Return type:
None
- handle_notification(data)[source]
Handle server notification. Override in subclasses.
- Parameters:
data (dict) – Notification payload
- Return type:
None
- connect()[source]
Connect to server and perform handshake
- Returns:
Server’s handshake information
- Return type:
- send_command(command, recv_timeout=None, **kwargs)[source]
Send a command to server and wait for the response.
- Parameters:
command (str) – Command name.
recv_timeout (float, optional) – How many seconds to wait for the server’s response before raising TimeoutError. Defaults to 30s. NOTE: this parameter is consumed client-side and is NOT forwarded to the server. Any server-side kwarg named
recv_timeoutwould be silently shadowed — callers must rename such kwargs before calling this method.**kwargs – Command arguments forwarded to the server.
- Returns:
Response payload from the server.
- Return type:
data(Any)
- property server_info: HandshakeInfo | None
Server’s handshake info (available after connect)
- class mirror.socket.HandshakeInfo(app_name, app_version, protocol_version, is_server, role)[source]
Bases:
objectInformation exchanged during connection handshake
- Parameters:
- to_dict()[source]
Serialize to dictionary
- Returns:
Dataclass fields as dictionary
- Return type:
data(dict)
- static from_dict(data)[source]
Deserialize from dictionary
- Parameters:
data (dict) – Dictionary with HandshakeInfo fields
- Returns:
Deserialized instance
- Return type:
info(HandshakeInfo)
- mirror.socket.expose(cmd_name=None)[source]
Mark a method as an exposed socket command handler
- Parameters:
cmd_name (str, optional) – Command name. Defaults to method name.
- Returns:
Decorator that tags the method
- Return type:
decorator(Callable)
- mirror.socket.init(role, **kwargs)[source]
Initialize a socket server or client by role
- Parameters:
role (str) – “master” or “worker” for servers, “client”/”master_client” for MasterClient, “worker_client” for WorkerClient
**kwargs – Arguments passed to the constructor
- Returns:
Initialized server or connected client
- Return type:
instance(Any)
mirror.structure
- class mirror.structure.Options[source]
Bases:
object
- class mirror.structure.PackageSettings(hidden: bool, src: str, dst: str, options: dict = <factory>)[source]
Bases:
Options
- class mirror.structure.Package(pkgid: str, name: str, status: str, href: str, synctype: str, syncrate: int, link: list[mirror.structure.Package.Link], settings: mirror.structure.PackageSettings, lastsync: float = 0.0, disabled: bool = False, timestamp: float = 0.0, statusinfo: mirror.structure.Package.StatusInfo = <factory>)[source]
Bases:
object- Parameters:
- class StatusInfo(lasterrorlog: str | None = None, lastsuccesslog: str | None = None, runninglog: str | None = None, errorcount: int = 0, lastsuccesstime: float = 0.0, lasterrortime: float = 0.0)[source]
Bases:
Options- Parameters:
- settings: PackageSettings
- statusinfo: StatusInfo
- class mirror.structure.Packages(pkgs)[source]
Bases:
Options- Parameters:
pkgs (dict)
- class mirror.structure.PluginSettings(enabled: bool = True)[source]
Bases:
Options- Parameters:
enabled (bool)
- class mirror.structure.Config(name: str, hostname: str, lastsettingmodified: int, errorcontinuetime: int, logfolder: pathlib._local.Path, webroot: pathlib._local.Path, statusfile: pathlib._local.Path, ftpsync: mirror.structure.Config.FTPSync, uid: int, gid: int, maintainer: dict, localtimezone: str, logger: dict, max_runtime_seconds: int = 0, plugins: dict[str, mirror.structure.PluginSettings]=<factory>, socket: 'Config.SocketSettings' = <factory>)[source]
Bases:
object- Parameters:
name (str)
hostname (str)
lastsettingmodified (int)
errorcontinuetime (int)
logfolder (Path)
webroot (Path)
statusfile (Path)
ftpsync (FTPSync)
uid (int)
gid (int)
maintainer (dict)
localtimezone (str)
logger (dict)
max_runtime_seconds (int)
plugins (dict[str, PluginSettings])
socket (SocketSettings)
- class FTPSync(maintainer: str = '', sponsor: str = '', country: str = '', location: str = '', throughput: str = '', include: str = '', exclude: str = '')[source]
Bases:
Options- Parameters:
- class SocketSettings(uid: int | None = None, gid: int | None = None, mode: int = 384)[source]
Bases:
Options- classmethod from_dict(data)[source]
Build SocketSettings from the settings.socket config dict.
- Parameters:
data (dict) – Raw socket settings ({“uid”, “gid”, “mode”}).
- Returns:
- Parsed instance. uid/gid stay None
when absent (no chown). mode defaults to 0o600 and is parsed from an octal string (e.g. “0770”) via parse_file_mode.
- Return type:
- plugins: dict[str, PluginSettings]
- socket: SocketSettings
mirror.sync
- mirror.sync.set_standalone_mode(enabled)[source]
Enable or disable standalone execution mode.
In standalone mode, on_sync_done records the result but does NOT write stat.json, status.json, or mutate package status. execute_command runs the subprocess in the foreground without a worker socket.
Enabling standalone mode clears any previously recorded results so a reused pkgid cannot read a stale result from an earlier in-process run (e.g. a run that raises before on_sync_done would otherwise see the prior success).
- Parameters:
enabled (bool) – True to activate standalone mode, False to deactivate.
- Return type:
None
- mirror.sync.get_standalone_result(pkgid)[source]
Return the recorded standalone sync result for a package, if any.
- mirror.sync.get_module(method)[source]
Return the loaded sync module for the given method name.
- Parameters:
method (str) – Sync method name (e.g. “rsync”, “ftpsync”).
- Returns:
The loaded sync module object.
- Return type:
module(Callable)
- mirror.sync.release_watchdog_fired(pkgid)[source]
Release a previously-claimed watchdog marker (e.g., on stop_command failure).
- Parameters:
pkgid (str) – Package identifier.
- Return type:
None
- mirror.sync.should_kill_for_max_runtime(uptime, max_runtime_seconds)[source]
Decide whether the watchdog should kill a sync for exceeding max_runtime.
- Parameters:
- Returns:
True if uptime is known and exceeds the cap.
- Return type:
kill(bool)
- mirror.sync.start(package, trigger='auto', extra_args=None)[source]
Start sync for a package.
Rejects if a sync for the same pkgid is already in progress.
- Parameters:
package (mirror.structure.Package) – Package to sync.
trigger (str) – Source of the trigger (“auto”, “manual”, etc.).
extra_args (dict[str, str], optional) – Extra key-value pairs to associate with this sync (str->str). Validated before the lock is acquired. Cleared from the registry on completion or on scoped launch failure. Raises ValueError on bad input (non-str keys/values, empty key, ‘=’ or NUL in key, NUL in value). Raises RuntimeError if a sync for this pkgid is already in progress (existing behavior unchanged).
- Raises:
ValueError – If sync method is unknown or extra_args is invalid.
RuntimeError – If a sync for this pkgid is already in progress.
- Return type:
None
- mirror.sync.get_extra_args(pkgid)[source]
Return a shallow copy of the extra_args registered for an in-flight sync, or empty.
mirror.toolbox
- mirror.toolbox.parse_iso_duration(iso8601)[source]
Parse an ISO 8601 duration string into total seconds.
Only supports days, hours, minutes, and seconds.
- mirror.toolbox.format_iso_duration(duration)[source]
Format total seconds into an ISO 8601 duration string.
Only supports days, hours, minutes, and seconds.
- mirror.toolbox.parse_file_mode(value)[source]
Parse an octal file-mode string into an integer.
Accepts forms like “0770”, “0o770”, or “770”; all interpreted as base-8.
mirror.worker
- class mirror.worker.Job(job_id, commandline, env, uid, gid, nice, log_path=None, log_helper_command=None)[source]
Bases:
objectRepresents a worker process.
- Parameters:
- start()[source]
Spawn the subprocess with the configured command, uid, gid, and niceness.
- Return type:
None
- mirror.worker.create(job_id, commandline, env, uid, gid, nice, log_path=None, log_helper_command=None)[source]
Create and start a new worker.
- Parameters:
- Returns:
The started Job instance
- Return type:
job(Job)
- Raises:
ValueError – If a job with the given ID already exists
- mirror.worker.prune_finished()[source]
Remove finished jobs from the registry after notifying clients.
Notification is attempted via mirror.socket.worker.send_finished_notification. If notification fails, the attempt counter is incremented. After NOTIFY_ATTEMPT_BUDGET consecutive failures the job is force-pruned.