execute
- qcengine.util.execute(command, infiles=None, outfiles=None, *, as_binary=None, scratch_name=None, scratch_directory=None, scratch_suffix=None, scratch_messy=False, scratch_exist_ok=False, blocking_files=None, timeout=None, interupt_after=None, environment=None, shell=False, exit_code=0)[source]
Runs a process in the background until complete.
Returns True if exit code <= exit_code (default 0)
- Parameters:
infiles (
Optional[Dict[str,str]]) – Input file names (names, not full paths) and contents. to be written in scratch dir. May be {}.outfiles (
Optional[List[str]]) – Output file names to be collected after execution into values. May be {}.as_binary (
Optional[List[str]]) – Keys of infiles or outfiles to be treated as bytes.scratch_name (
Optional[str]) – Passed to temporary_directoryscratch_directory (
Optional[str]) – Passed to temporary_directoryscratch_suffix (
Optional[str]) – Passed to temporary_directoryscratch_messy (
bool) – Passed to temporary_directoryscratch_exist_ok (
bool) – Passed to temporary_directoryblocking_files (
Optional[List[str]]) – Files which should stop execution if present beforehand.interupt_after (
Optional[int]) – Interupt the process (not hard kill) after n seconds.environment (
Optional[Dict[str,str]]) – The environment to run inexit_code (
Optional[int]) – The exit code above which the process is considered failure.
- Raises:
FileExistsError – If any file in blocking is present
- Return type:
Examples
# execute multiple commands in same dir >>> success, dexe = qcng.util.execute([‘command_1’], infiles, [], scratch_messy=True) >>> success, dexe = qcng.util.execute([‘command_2’], {}, outfiles, scratch_messy=False, scratch_name=Path(dexe[‘scratch_directory’]).name, scratch_exist_ok=True)