toil.lib.misc¶
Attributes¶
Exceptions¶
Version of CalledProcessError that include stderr in the error message if it is set |
Functions¶
Get the IP that this machine uses to contact the internet. |
|
Get the current user name, or a suitable substitute string if the user name |
|
|
Return a datetime in the UTC timezone corresponding to right now. |
Return the current time in milliseconds since the Unix epoch. |
|
|
Toil jobs that have completed are not allowed to have taken 0 seconds, but |
|
This is for functions used simultaneously in Toil proper and in the admin scripts. |
|
Simplified calling of external commands. |
Module Contents¶
- toil.lib.misc.logger¶
- toil.lib.misc.get_public_ip()[source]¶
Get the IP that this machine uses to contact the internet.
If behind a NAT, this will still be this computer’s IP, and not the router’s.
- Return type:
- toil.lib.misc.get_user_name()[source]¶
Get the current user name, or a suitable substitute string if the user name is not available.
- Return type:
- toil.lib.misc.utc_now()[source]¶
Return a datetime in the UTC timezone corresponding to right now.
- Return type:
- toil.lib.misc.unix_now_ms()[source]¶
Return the current time in milliseconds since the Unix epoch.
- Return type:
- toil.lib.misc.slow_down(seconds)[source]¶
Toil jobs that have completed are not allowed to have taken 0 seconds, but Kubernetes timestamps round things to the nearest second. It is possible in some batch systems for a pod to have identical start and end timestamps.
This function takes a possibly 0 job length in seconds and enforces a minimum length to satisfy Toil.
- toil.lib.misc.printq(msg, quiet, log=False)[source]¶
This is for functions used simultaneously in Toil proper and in the admin scripts.
Our admin scripts “print” to stdout, while Toil proper uses logging. For a script that, for example, cleans up IAM, EC2, etc. cruft leftover after failed CI runs, we can call an AWS delete IAM role function, and this prints or logs progress (unless quiet is True), depending on whether the function is called in, say, the jobstore or a script.
- exception toil.lib.misc.CalledProcessErrorStderr(returncode, cmd, output=None, stderr=None)[source]¶
Bases:
subprocess.CalledProcessError
Version of CalledProcessError that include stderr in the error message if it is set
- toil.lib.misc.call_command(cmd, *args, input=None, timeout=None, useCLocale=True, env=None, quiet=False)[source]¶
Simplified calling of external commands.
If the process fails, CalledProcessErrorStderr is raised.
The captured stderr is always printed, regardless of if an exception occurs, so it can be logged.
Always logs the command at debug log level.
- Parameters:
quiet (Optional[bool]) – If True, do not log the command output. If False (the default), do log the command output at debug log level.
useCLocale (bool) – If True, C locale is forced, to prevent failures that can occur in some batch systems when using UTF-8 locale.
cmd (List[str])
args (str)
input (Optional[str])
timeout (Optional[float])
- Returns:
Command standard output, decoded as utf-8.
- Return type: