copy_guardian package

Submodules

copy_guardian.copy_guardian module

copy_guardian.copy_guardian.BoundedSemaphore(n: int, timeout: float = 300, lock_directory: str = None, filename_pattern: str = None)[source]

Contextmanager to implement a bounded semaphore.

Parameters:
  • n – int, How many jobs/processes can execute the protected area at the same time. The (n + 1)th and later job/process wait max timeout seconds. Else an error will be triggered.

  • timeout – float, see decription of argument n.

  • lock_directory – str, per default this is ~/.copy_guard_locks.

  • filename_pattern – str, per default this is the path to the script which calls BoundedSemaphore including the full path plus a string -NN.lock to enumerate locks, spaces are replaced by _.

class copy_guardian.copy_guardian.Connection(user: str, host: str, private_key: str, port: int = 22)[source]

Bases: object

Connection is an access object for rsync based copy operations.

Parameters:
  • user – str, username on the remote computer.

  • host – str, host name, e.g. remote.unixxx.com.

  • private_key – str, path to private key to use. If the path is just a filename which does not exist in the current working folder, the ~/.ssh folder is searched for this filename.

  • port – int, optional. optional port if the remote machine does not listen on the default port 22.

rsync_from(source: str, target: str)[source]

copy from remote machine to local machine

Parameters:
  • source – str, remote file, folder of wildcard.

  • target – str, local file or folder.

rsync_to(source: str, target: str)[source]

copy from local machine to remote machine

Parameters:
  • source – str, local file, folder of wildcard.

  • target – str, remote file or folder.

copy_guardian.copy_utils module

copy_guardian.copy_utils.copy_local_folder(source: str, target: str)[source]

copies a folder with all files locally. this function is optimized for many files, especially on an hpc system.

Parameters:
  • source – source folder

  • target – target folder, the basename of source will be a subfolder in target.

Module contents