repo.py

class mirrors.repo.Repo(name, config)[source]
__init__(name, config)[source]

A repo object which stores info about a single repo.

Parameters:
__weakref__

list of weak references to the object (if defined)

is_alive()[source]

Bool of syncing status.

kill()[source]

Send SIGKILL To the rsync process.

class rsync_thread(name, config)[source]

Extended threading.Thread class to control rsync via subprocess.

Parameters:
  • name (str) – Name of repo
  • config (Configparser.Configparser) – Running config options
Repo.running_time()[source]

Total running time of active sync.

Return type:int
Returns:An int of total syncing time elapsed
Return type:None
Returns:None if not syncing
Repo.sleep_time()[source]

Sleep duration of sleeping sync.

Return type:int
Returns:A int of time elapsed since sleeping
Return type:None
Returns:None if not in sleeping state
Repo.start_sync()[source]

Run an rsync against the repo source.

Repo.terminate()[source]

Send SIGTERM To the rsync process.

Repo.time_remaining()[source]

Return time left until sleep is over.

Return type:int
Returns:A int of time remaining in sleep state
Return type:None
Returns:None if not in sleeping state
class mirrors.repo.RepoManager(config)[source]
__init__(config)[source]

Singleton manager of the repositories and threading.

Parameters:config (Configparser.Configparser) – Running config options
__metaclass__

alias of Singleton

__weakref__

list of weak references to the object (if defined)

activate(name)[source]

Activate repo for syncing.

Parameters:name (str) – Name of Repo
Raises Repo.RepoError:
 if no repo exists by given name
add_repo(name)[source]

Create a repo for a section in the running config.

Parameters:name (str) – Name of repo
Raises Repo.RepoConfigError:
 if no config exists for given repo name
deactivate(name)[source]

Deactivate repo from syncing.

Parameters:name (str) – Name of repo
Raises Repo.RepoError:
 if no repo exists by given name
del_repo(name)[source]

Delete repo object from dict.

Parameters:name (str) – Name of repo
Raises Repo.RepoError:
 if no repo exists by passed in name.
enqueue(name)[source]

Add repo to the queue.

Parameters:name (str) – Name of repo
Raises Repo.RepoError:
 if repo is already queued or doesn’t exist
gen_repo()[source]

Generator for repo_dict.

Return type:Repo
Returns:Repo Object
get_repo(name)[source]

Return repo object if exists.

Parameters:name (str) – name of repo
Return type:Repo
Returns:Repo Object
Return type:None
Returns:None if no repo exists by passed in name
status(name)[source]

Return status of Repo.

Parameters:name (str) – Name of Repo
Return type:str
Returns:str status of Repo