utils

Uncategorised utilities.

class deltona.utils.DataAdapter

Bases: BaseAdapter

Niquests adapter that returns the URL content (after data:) as the response body.

close() None

Clean up adapter resources.

send(request: PreparedRequest, **kwargs: Any) Response

Send a request and return the URL content as the response body.

Parameters:
request : niquests.PreparedRequest

The prepared request.

**kwargs : Any

Additional keyword arguments (unused, accepted for compatibility).

Returns:

A response with the URL content (after data:) as the body.

Return type:

niquests.Response

deltona.utils.add_cdda_times(times: Iterable[str] | None) str | None

Add CDDA time strings and get a total runtime in CDDA format.

CDDA format is MM:SS:FF where MM is minutes, SS is seconds, and FF is frames.

Parameters:
times : Iterable[str] | None

CDDA time strings to add together.

Returns:

The total runtime in CDDA format, or None if the input is empty or invalid.

Return type:

str | None

deltona.utils.kill_processes_by_name(name: str) None
deltona.utils.kill_processes_by_name(name: str, wait_timeout: float, signal: int = SIGTERM, *, force: bool = False) list[int]

Kill processes matching a name.

On Windows, uses taskkill.exe. On other platforms, uses killall.

Parameters:
name : str

Process name to kill.

wait_timeout : float | None

Seconds to wait after sending the signal. If None, do not wait or collect PIDs.

signal : int

Signal number to send.

force : bool

If True, forcefully kill remaining processes after the timeout.

Returns:

List of PIDs that were found after the initial signal, or None if wait_timeout is None.

Return type:

list[int] | None

deltona.utils.secure_move_path(client: SSHClient, filename: StrPath, remote_target: str, *, bandwidth_limit_kbits: float | None = None, dry_run: bool = False, preserve_stats: bool = False, write_into: bool = False) None

Move a file or directory to a remote host over SSH.

Like scp but deletes the local file after a successful copy.

Parameters:
client : paramiko.SSHClient

Connected SSH client.

filename : StrPath

Local file or directory to move.

remote_target : str

Remote destination path. ~ is expanded to the remote home directory. When moving a file, if this ends with / or refers to an existing remote directory, the source basename is appended; otherwise it is used as the literal destination filename.

bandwidth_limit_kbits : float | None

If set, throttle each upload to the given bandwidth in Kbit/s.

dry_run : bool

If True, do not perform any file operations.

preserve_stats : bool

If True, preserve modification and access times.

write_into : bool

If True, write into the target directory rather than creating a new one.

deltona.utils.unregister_wine_file_associations(*, debug: bool = False) None

Remove Wine file associations, icons, and MIME types from the user’s desktop environment.

Kills running Wine processes before removing files.

Parameters:
debug : bool

If True, pass verbose flags to update-desktop-database and update-mime-database.