Classes | |
class | SubprocessError |
Exception thrown when command execution failed. More... | |
Functions | |
def | decode (s) |
def | execute (args, quiet=False, stdout=False, allow_fail=False, verbose=0, simulate=False, prefix=None, targets=None, base='.') |
Execute command as subprocess. More... | |
def | exedir (name=None, prefix=None, targets=None, base='.') |
Get directory of executable file. More... | |
def | exename (name=None, prefix=None, targets=None, base='.') |
Get name of executable file. More... | |
def | exepath (name=None, prefix=None, targets=None, base='.') |
Get absolute path of executable file. More... | |
def | istarget (name, prefix=None, targets=None) |
Determine whether a given build target is known. More... | |
def | print_contact (contact=CONTACT) |
Print contact information. More... | |
def | print_version (name, version=None, project=None, copyright=COPYRIGHT, license=LICENSE) |
Print version information including copyright and license notices. More... | |
def | qsplit (args) |
Split quoted string of arguments. More... | |
def | targetuid (name, prefix=None, targets=None) |
Get UID of build target. More... | |
def | tostring (args) |
Convert array of arguments to quoted string. More... | |
Variables | |
binary_type = str | |
string | CONTACT = """andreas.schuh.84@gmail.com""" |
Default contact to use for help output of executables. More... | |
string | COPYRIGHT = """2011-12 University of Pennsylvania, 2013-14 Carnegie Mellon University, 2013-16 Andreas Schuh""" |
Default copyright of executables. More... | |
string | LICENSE = """See https://cmake-basis.github.io/download.html#license or COPYING file.""" |
Default license of executables. More... | |
text_type = unicode | |
def basis.utilities.decode | ( | s | ) |
Definition at line 69 of file utilities.py.
def basis.utilities.execute | ( | args, | |
quiet = False , |
|||
stdout = False , |
|||
allow_fail = False , |
|||
verbose = 0 , |
|||
simulate = False , |
|||
prefix = None , |
|||
targets = None , |
|||
base = '.' |
|||
) |
Execute command as subprocess.
[in] | args | Command with arguments given either as quoted string or array of command name and arguments. In the latter case, the array elements are converted to strings using the built-in str() function. Hence, any type which can be converted to a string is permitted. The first argument must be the name or path of the executable of the command. |
[in] | quiet | Turns off output of stdout of child process to stdout of parent process. |
[in] | stdout | Whether to return the command output. |
[in] | allow_fail | If true, does not raise an exception if return value is non-zero. Otherwise, a SubprocessError is raised by this function. |
[in] | verbose | Verbosity of output messages. Does not affect verbosity of executed command. |
[in] | simulate | Whether to simulate command execution only. |
[in] | prefix | Common prefix of targets belonging to this project. |
[in] | targets | Dictionary mapping target UIDs to executable paths. |
[in] | base | Base directory for relative paths in targets . |
stdout
is false (the default). Otherwise, if stdout
is true, a tuple consisting of exit code and binary/encoded command output is returned. Note that if allow_fail
is false, the returned exit code will always be 0.SubprocessError | If command execution failed. This exception is not raised if the command executed with non-zero exit code but allow_fail set to True . |
Definition at line 324 of file utilities.py.
def basis.utilities.exedir | ( | name = None , |
|
prefix = None , |
|||
targets = None , |
|||
base = '.' |
|||
) |
Get directory of executable file.
[in] | name | Name of command or None . |
[in] | prefix | Common prefix of targets belonging to this project. |
[in] | targets | Dictionary mapping target UIDs to executable paths. |
[in] | base | Base directory for relative paths in targets . |
None
if not found. If name
is None
, the directory of this executable is returned. Definition at line 234 of file utilities.py.
def basis.utilities.exename | ( | name = None , |
|
prefix = None , |
|||
targets = None , |
|||
base = '.' |
|||
) |
Get name of executable file.
[in] | name | Name of command or None . |
[in] | prefix | Common prefix of targets belonging to this project. |
[in] | targets | Dictionary mapping target UIDs to executable paths. |
[in] | base | Base directory for relative paths in targets . |
None
if not found. If name
is None
, the name of this executable is returned. Definition at line 216 of file utilities.py.
def basis.utilities.exepath | ( | name = None , |
|
prefix = None , |
|||
targets = None , |
|||
base = '.' |
|||
) |
Get absolute path of executable file.
This function determines the absolute file path of an executable. If no arguments are given, the absolute path of this executable is returned. If the command names a known executable build target, the absolute path to the corresonding built (and installed) executable file is returned. Otherwise, the named command is searched in the system PATH
and its absolute path returned if found. If the executable is not found, None
is returned.
[in] | name | Name of command or None . |
[in] | prefix | Common prefix of targets belonging to this project. |
[in] | targets | Dictionary mapping target UIDs to executable paths. |
[in] | base | Base directory for relative paths in targets . |
None
if not found. If name
is None
, the path of this executable is returned. Definition at line 184 of file utilities.py.
def basis.utilities.istarget | ( | name, | |
prefix = None , |
|||
targets = None |
|||
) |
Determine whether a given build target is known.
[in] | name | Name of build target. |
[in] | prefix | Common prefix of targets belonging to this project. |
[in] | targets | Dictionary mapping target UIDs to executable paths. |
Definition at line 160 of file utilities.py.
def basis.utilities.print_contact | ( | contact = CONTACT | ) |
Print contact information.
[in] | contact | Name of contact. |
Definition at line 82 of file utilities.py.
def basis.utilities.print_version | ( | name, | |
version = None , |
|||
project = None , |
|||
copyright = COPYRIGHT , |
|||
license = LICENSE |
|||
) |
Print version information including copyright and license notices.
[in] | name | Name of executable. Should not be set programmatically to the first argument of the main module, but a string literal instead. |
[in] | version | Version of executable, e.g., release of project this executable belongs to. |
[in] | project | Name of project this executable belongs to. If None , or an empty string, no project information is printed. |
[in] | copyright | The copyright notice, excluding the common prefix "Copyright (c) " and suffix ". All rights reserved.". If None , or an empty string, no copyright notice is printed. |
[in] | license | Information regarding licensing. If None or an empty string, no license information is printed. |
Definition at line 102 of file utilities.py.
def basis.utilities.qsplit | ( | args | ) |
Split quoted string of arguments.
[in] | args | Quoted string of arguments. |
Definition at line 289 of file utilities.py.
def basis.utilities.targetuid | ( | name, | |
prefix = None , |
|||
targets = None |
|||
) |
Get UID of build target.
The UID of a build target is its name prepended by a namespace identifier which should be unique for each project.
[in] | name | Name of build target. |
[in] | prefix | Common prefix of targets belonging to this project. |
[in] | targets | Dictionary mapping target UIDs to executable paths. |
Definition at line 134 of file utilities.py.
def basis.utilities.tostring | ( | args | ) |
Convert array of arguments to quoted string.
[in] | args | Array of arguments, bytes, or non-string type. |
Definition at line 263 of file utilities.py.
basis.utilities.binary_type = str |
Definition at line 45 of file utilities.py.
string basis.utilities.CONTACT = """andreas.schuh.84@gmail.com""" |
Default contact to use for help output of executables.
Definition at line 59 of file utilities.py.
string basis.utilities.COPYRIGHT = """2011-12 University of Pennsylvania, 2013-14 Carnegie Mellon University, 2013-16 Andreas Schuh""" |
Default copyright of executables.
Definition at line 55 of file utilities.py.
string basis.utilities.LICENSE = """See https://cmake-basis.github.io/download.html#license or COPYING file.""" |
Default license of executables.
Definition at line 57 of file utilities.py.
basis.utilities.text_type = unicode |
Definition at line 44 of file utilities.py.