toil.lib.misc
¶
Module Contents¶
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 |
|
|
|
Simplified calling of external commands. |
Attributes¶
- 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.
- exception toil.lib.misc.CalledProcessErrorStderr(returncode, cmd, output=None, stderr=None)[source]¶
Bases:
digraph inheritance715bfcff3e { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "CalledProcessError" [URL="https://docs.python.org/3/library/subprocess.html#subprocess.CalledProcessError",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Raised when run() is called with check=True and the process"]; "SubprocessError" -> "CalledProcessError" [arrowsize=0.5,style="setlinewidth(0.5)"]; "CalledProcessErrorStderr" [URL="#toil.lib.misc.CalledProcessErrorStderr",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Version of CalledProcessError that include stderr in the error message if it is set"]; "CalledProcessError" -> "CalledProcessErrorStderr" [arrowsize=0.5,style="setlinewidth(0.5)"]; "SubprocessError" [URL="https://docs.python.org/3/library/subprocess.html#subprocess.SubprocessError",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top"]; }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: