pcvs.helpers.utils module
- pcvs.helpers.utils.check_valid_program(p, succ=None, fail=None, raise_if_fail=True)[source]
Check if p is a valid program, using the
which
function.- Parameters
- Raises
RunException.ProgramError – p is not a valid program
- Returns
True if p is a program, False otherwise
- Return type
- pcvs.helpers.utils.check_valid_scope(s)[source]
Check if argument is a valid scope (local, user, global).
- Parameters
s (str) – scope to check
- Raises
CommonException.BadTokenError – the argument is not a valid scope
- pcvs.helpers.utils.create_or_clean_path(prefix, dir=False)[source]
Create a path or cleans it if it already exists.
- pcvs.helpers.utils.cwd(path)[source]
Change the working directory.
- Parameters
path (os.path, str) – new working directory
- pcvs.helpers.utils.extract_infos_from_token(s, pair='right', single='right', maxsplit=3)[source]
Extract fields from tokens (a, b, c) from user’s string.
- Parameters
- Returns
3-string-tuple: mapping (scope, kind, name), any of them may be null
- Return type
- pcvs.helpers.utils.find_buildir_from_prefix(path)[source]
Find the build directory from the
path
prefix.- Parameters
path (os.path, str) – path to search the build directory from
- Raises
CommonException.NotFoundError – the build directory is not found
- Returns
the path of the build directory
- Return type
os.path
- pcvs.helpers.utils.generate_local_variables(label, subprefix)[source]
Return directories from PCVS working tree :
the base source directory
the current source directory
the base build directory
the current build directory
- Parameters
- Raises
CommonException.NotFoundError – the label is not recognized as to be validated
- Returns
paths for PCVS working tree
- Return type
- pcvs.helpers.utils.get_lock_owner(f)[source]
The lock file will contain the process ID owning the lock. This function returns it.
- pcvs.helpers.utils.get_lockfile_name(f)[source]
From a file to mutex, return the file lock name associated with it.
For instance for /a/b.yml, the lock file name will be /a/.b.yml.lck
- Parameters
f (str) – the file to mutex
- pcvs.helpers.utils.lock_file(f, reentrant=False, timeout=None, force=True)[source]
Try to lock a directory.
- Parameters
- Raises
LockException.TimeoutError – timeout is reached before the directory is locked
- Returns
True if the file is reached, False otherwise
- Return type
- pcvs.helpers.utils.set_local_path(path)[source]
Set the prefix for the
local
storage.- Parameters
path (os.path) – path of the
local
storage
- pcvs.helpers.utils.storage_order()[source]
Return scopes in order of searching.
- Returns
a list of scopes
- Return type