Skip to content

sok.server.renames

The renames of S.O.K Server: the Ready rows of a tab go to their folder.

A rename takes the rows of one tab, all those that are Ready (or picked by hand) or a list of them, and runs in the background like an analysis, never at the same time as one. The file operations of the desktop batches move them, with the file mode, the behavior settings, the subtitles and the posters of the settings; the whole rename is one operation of the history.

With hard links, every source and destination of the rename are tested first: if one pair cannot be linked, nothing is renamed and the error says which folders. The files renamed leave the table; a file that fails, or is skipped as a duplicate, stays on its row with why.

RenameError

class RenameError(code: str, **details: str)

Bases: Exception

A rename that cannot start: unknown_type, nothing_to_rename, no_destination, scan_running, already_running, or a hard link problem (different_drives, no_hard_links, missing_folder) with the folders.

Parameters

NameTypeDescription
codestr
**detailsstr
Source

Attributes

Name
code
details

detail

def detail() -> Dict[str, str]:
Source

Renamer

class Renamer(
db: Database,
config: ConfigManager,
events: EventBus,
searcher: Searcher,
history: History,
jobs: Jobs,
notifier: Optional[Notifier] = None,
)

Start the renames and keep their results in the database.

Parameters

NameTypeDefaultDescription
dbDatabase
configConfigManager
eventsEventBus
searcherSearcher
historyHistory
jobsJobs
notifierOptional[Notifier]None
Source

current

def current() -> Dict[str, Any]:

The last rename, with its result once done.

Source

start

def start(
media_type: str,
row_ids: Optional[List[int]] = None,
auto: bool = False,
) -> int:

Start renaming the Ready rows of a tab, in the background.

Parameters

NameTypeDefaultDescription
media_typestrThe tab: movies, tv, music, books or games.
row_idsOptional[List[int]]NoneOnly these rows; all the Ready rows of the tab when None. The rows not Ready are left out.
autoboolFalseStarted by the automatic sorting (Watcher), not by a click.

Returns

  • intThe id of the rename.

Raises

Source

Functions

def link_problem(file: str, folder: str) -> Optional[str]:

Why a file cannot be hard linked into a folder, or None.

Parameters

NameTypeDescription
filestr
folderstr
Source

Attributes

NameValue
ALREADY_EXISTS'already_exists'
DONE'done'
FAILED'failed'
INTERRUPTED'interrupted'
RENAME_FAILED'failed'
RUNNING'running'
loggerlogging.getLogger(__name__)
Built with Kiln