Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
Size: Mime:
ó
¼EYc@sdZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlmZddlm
Z
ddlmZddlmZddlZddlmZe
jdƒZeoþejje	ƒrdd	lmZnddlZejeƒZd
efd„ƒYZdefd
„ƒYZdefd„ƒYZdefd„ƒYZ d„Z!e
j"de
j#fd„ƒYƒZ$e$j%Z&e$j'Z(e$j)Z*de+fd„ƒYZ,d„Z-d„Z.e/e/e0e1e/d„Z2d„Z3dS(s.
System-level utilities and helper functions.
iÿÿÿÿN(tencodeutils(timportutils(tstrutils(t	timeutils(t_teventlet(t
subprocesstInvalidArgumentErrorcBseZdd„ZRS(cCstt|ƒj|ƒdS(N(tsuperRt__init__(tselftmessage((sR/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_concurrency/processutils.pyR	7sN(t__name__t
__module__tNoneR	(((sR/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_concurrency/processutils.pyR6stUnknownArgumentErrorcBseZdd„ZRS(cCstt|ƒj|ƒdS(N(RRR	(R
R((sR/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_concurrency/processutils.pyR	<sN(RR
RR	(((sR/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_concurrency/processutils.pyR;stProcessExecutionErrorcBs)eZdddddd„Zd„ZRS(cCsStt|ƒj|||||ƒ||_||_||_||_||_dS(N(RRR	t	exit_codetstderrtstdouttcmdtdescription(R
RRRRR((sR/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_concurrency/processutils.pyR	As				cCs‚|j}|dkr$tdƒ}n|j}|dkrBd}ntdƒi|d6|jd6|d6|jd6|jd6}|S(	Ns'Unexpected error while running command.t-s_%(description)s
Command: %(cmd)s
Exit code: %(exit_code)s
Stdout: %(stdout)r
Stderr: %(stderr)rRRRRR(RRRRRRR(R
RRR((sR/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_concurrency/processutils.pyt__str__Ks				


N(RR
RR	R(((sR/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_concurrency/processutils.pyR@s	tNoRootWrapSpecifiedcBseZdd„ZRS(cCstt|ƒj|ƒdS(N(RRR	(R
R((sR/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_concurrency/processutils.pyR	asN(RR
RR	(((sR/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_concurrency/processutils.pyR`scCs*tjtjtjƒ|r&|ƒndS(N(tsignaltSIGPIPEtSIG_DFL(t
on_preexec_fn((sR/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_concurrency/processutils.pyt_subprocess_setupest	LogErrorscBs eZdZdZdZdZRS(sbEnumerations that affect if stdout and stderr are logged on error.

    .. versionadded:: 2.7
    iii(RR
t__doc__tDEFAULTtALLtFINAL(((sR/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_concurrency/processutils.pyRmst
ProcessLimitscBsleZdZi
dd6dd6dd6dd6d	d
6dd6d
d6dd6dd6dd6Zd„Zd„ZRS(sjResource limits on a process.

    Attributes:

    * address_space: Address space limit in bytes
    * core_file_size: Core file size limit in bytes
    * cpu_time: CPU time limit in seconds
    * data_size: Data size limit in bytes
    * file_size: File size limit in bytes
    * memory_locked: Locked memory limit in bytes
    * number_files: Maximum number of open files
    * number_processes: Maximum number of processes
    * resident_set_size: Maximum Resident Set Size (RSS) in bytes
    * stack_size: Stack size limit in bytes

    This object can be used for the *prlimit* parameter of :func:`execute`.
    s--ast
address_spaces--coretcore_file_sizes--cputcpu_times--datat	data_sizes--fsizet	file_sizes	--memlockt
memory_lockeds--nofiletnumber_filess--nproctnumber_processess--rsstresident_set_sizes--stackt
stack_sizecKshx3|jjƒD]"}t|||j|dƒƒqW|rdtddjt|jƒƒƒƒ‚ndS(Nsinvalid limits: %ss, (t_LIMITStkeystsetattrtpopRt
ValueErrortjointsorted(R
tkwtlimit((sR/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_concurrency/processutils.pyR	¤s
 cCs`g}xS|jjƒD]B}t||ƒ}|dk	r|jd|j||fƒqqW|S(s8Create a list of arguments for the prlimit command line.s%s=%sN(R.R/tgetattrRtappend(R
targsR6tval((sR/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_concurrency/processutils.pytprlimit_args¬s%(RR
RR.R	R;(((sR/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_concurrency/processutils.pyR#„s
	c#Osµ|jdd&ƒ}|jdd&ƒ}|d&k	rBtj|ƒ}n|jdd&ƒ}|jddgƒ}t}|jdtƒ}|jddƒ}|jd	tƒ}	|jd
dƒ}
|jdtƒ}|jd
tjƒ}|jdd&ƒ}
|
d&krtj	}
n|jdtƒ}|jdd&ƒ}|jdd&ƒ}|jdd&ƒ}|jdd&ƒ}t
|tƒr„|}dg}nt
|tƒrŸ|g}n|r¾t
tdƒ|ƒ‚nt
|
tjƒrßt|
ƒ}
nt
|
tƒsttdƒ|
ƒ‚n|	r›ttdƒr›tjƒdkr›|
sLtdtdƒƒ‚n|rdj|
|dfƒgt|dƒ}q›tj|
ƒt|ƒ}ng|D]}t|ƒ^q¢}|r0tjdkrètj|tdƒƒq0tjddg}|j |j!ƒƒ|j"dƒ|j |ƒ|}nt#j$dj|ƒƒ}t%j&ƒ}xZ|dkr°|d8}|j'ƒz%yìtj|tdƒ|ƒt(j)}tjdkr½d&}t}nt*j+t,|ƒ}t}t(j-|d |d!|d"|d#|d|d|d|d$|ƒ}|r'||ƒnzH|j.|ƒ}|j/j0ƒ|j1}tj|d%|||j2ƒƒWd&|r…||ƒnX|r||kr|\}}tj3rÏtj4|ƒ}tj4|ƒ}nt#j$|ƒ}t#j$|ƒ} t5d'|d!|d"| d(|ƒ‚ntj3ra|ra|d&k	ra|\}}tj4|ƒ}tj4|ƒ}||fS|SWn2t5t6fk
rš}!|
t7ks|
t8kr3|r3t
|!t5ƒrtd)ƒ}"tj||"i|!j9d*6|!j:d(6|!j;d+6|!j<d!6|!j=d"6ƒq3td,ƒ}"tj||"i|d(6|!j>d-6ƒn|sXtj|td.ƒ|ƒ‚q›tj|td/ƒ|ƒ|r›t?j@tAjBd0d1ƒd2ƒq›nXWd&t?j@dƒXqWWd&S(3s`Helper method to shell out and execute a command through subprocess.

    Allows optional retry.

    :param cmd:             Passed to subprocess.Popen.
    :type cmd:              string
    :param cwd:             Set the current working directory
    :type cwd:              string
    :param process_input:   Send to opened process.
    :type process_input:    string or bytes
    :param env_variables:   Environment variables and their values that
                            will be set for the process.
    :type env_variables:    dict
    :param check_exit_code: Single bool, int, or list of allowed exit
                            codes.  Defaults to [0].  Raise
                            :class:`ProcessExecutionError` unless
                            program exits with one of these code.
    :type check_exit_code:  boolean, int, or [int]
    :param delay_on_retry:  True | False. Defaults to True. If set to True,
                            wait a short amount of time before retrying.
    :type delay_on_retry:   boolean
    :param attempts:        How many times to retry cmd.
    :type attempts:         int
    :param run_as_root:     True | False. Defaults to False. If set to True,
                            the command is prefixed by the command specified
                            in the root_helper kwarg.
    :type run_as_root:      boolean
    :param root_helper:     command to prefix to commands called with
                            run_as_root=True
    :type root_helper:      string
    :param shell:           whether or not there should be a shell used to
                            execute this command. Defaults to false.
    :type shell:            boolean
    :param loglevel:        log level for execute commands.
    :type loglevel:         int.  (Should be logging.DEBUG or logging.INFO)
    :param log_errors:      Should stdout and stderr be logged on error?
                            Possible values are
                            :py:attr:`~.LogErrors.DEFAULT`,
                            :py:attr:`~.LogErrors.FINAL`, or
                            :py:attr:`~.LogErrors.ALL`. Note that the
                            values :py:attr:`~.LogErrors.FINAL` and
                            :py:attr:`~.LogErrors.ALL`
                            are **only** relevant when multiple attempts of
                            command execution are requested using the
                            ``attempts`` parameter.
    :type log_errors:       :py:class:`~.LogErrors`
    :param binary:          On Python 3, return stdout and stderr as bytes if
                            binary is True, as Unicode otherwise.
    :type binary:           boolean
    :param on_execute:      This function will be called upon process creation
                            with the object as a argument.  The Purpose of this
                            is to allow the caller of `processutils.execute` to
                            track process creation asynchronously.
    :type on_execute:       function(:class:`subprocess.Popen`)
    :param on_completion:   This function will be called upon process
                            completion with the object as a argument.  The
                            Purpose of this is to allow the caller of
                            `processutils.execute` to track process completion
                            asynchronously.
    :type on_completion:    function(:class:`subprocess.Popen`)
    :param preexec_fn:      This function will be called
                            in the child process just before the child
                            is executed. WARNING: On windows, we silently
                            drop this preexec_fn as it is not supported by
                            subprocess.Popen on windows (throws a
                            ValueError)
    :type preexec_fn:       function()
    :param prlimit:         Set resource limits on the child process. See
                            below for a detailed description.
    :type prlimit:          :class:`ProcessLimits`
    :returns:               (stdout, stderr) from process execution
    :raises:                :class:`UnknownArgumentError` on
                            receiving unknown arguments
    :raises:                :class:`ProcessExecutionError`
    :raises:                :class:`OSError`

    The *prlimit* parameter can be used to set resource limits on the child
    process.  If this parameter is used, the child process will be spawned by a
    wrapper process which will set limits before spawning the command.

    .. versionchanged:: 3.17
       *process_input* can now be either bytes or string on python3.

    .. versionchanged:: 3.4
       Added *prlimit* optional parameter.

    .. versionchanged:: 1.5
       Added *cwd* optional parameter.

    .. versionchanged:: 1.9
       Added *binary* optional parameter. On Python 3, *stdout* and *stderr*
       are now returned as Unicode strings by default, or bytes if *binary* is
       true.

    .. versionchanged:: 2.1
       Added *on_execute* and *on_completion* optional parameters.

    .. versionchanged:: 2.3
       Added *preexec_fn* optional parameter.
    tcwdt
process_inputt
env_variablestcheck_exit_codeitdelay_on_retrytattemptsitrun_as_roottroot_helperttshelltloglevelt
log_errorstbinaryt
on_executet
on_completiont
preexec_fntprlimitsGot unknown keyword args: %rsGot invalid arg log_errors: %rtgeteuidRs:Command requested root, but did not specify a root helper.t tntsPProcess resource limits are ignored as this feature is not supported on Windows.s-msoslo_concurrency.prlimits--sRunning cmd (subprocess): %ststdinRRt	close_fdstenvsCMD "%s" returned: %s in %0.3fsNRRsS%(desc)r
command: %(cmd)r
exit code: %(code)r
stdout: %(stdout)r
stderr: %(stderr)rtdesctcodes0Got an OSError
command: %(cmd)r
errno: %(errno)rterrnos%r failed. Not Retrying.s%r failed. Retrying.iiÈgY@(CR1RRtto_utf8tFalsetTruetloggingtDEBUGRR t
isinstancetbooltintRRtsixt
integer_typesRthasattrtosRMRR3tlisttshlextsplittstrtnametLOGtlogtsyst
executabletextendR;R8Rt
mask_passwordRt	StopWatchtrestartRtPIPEt	functoolstpartialRtPopentcommunicateRPtcloset
returncodetelapsedtPY3tfsdecodeRtOSErrortLOG_ALL_ERRORStLOG_FINAL_ERRORRRRRRRUttimetsleeptrandomtrandint(#RtkwargsR<R=R>R?tignore_exit_codeR@RARBRCRERFRGRHRIRJRKRLtcR9t
sanitized_cmdtwatcht_PIPERRQtobjtresultt_returncodeRRtsanitized_stdouttsanitized_stderrterrtformat((sR/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_concurrency/processutils.pytexecute¶söf
'-	

	

					

		



(	cOs‰|jdtƒ}yt||Ž\}}t}Wn/tk
rb}dtj|ƒ}}t}nX|r|r|rd}n||fS(s•A wrapper around execute() to more easily handle warnings and errors.

    Returns an (out, err) tuple of strings containing the output of
    the command's stdout and stderr.  If 'err' is not empty then the
    command can be considered to have failed.

    :discard_warnings   True | False. Defaults to False. If set to True,
                        then for succeeding commands, stderr is cleared

    tdiscard_warningsRD(R1RWRRR^t	text_typeRX(R9R€RŽtoutR‹tfailedtexn((sR/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_concurrency/processutils.pyttrycmdÃs

	c
CsÁtj|ƒ}tjd|ƒ|r:ttdƒƒ‚n|rUttdƒƒ‚n|j|d|ƒ\}}	}
|	j}|	jƒ}|
jƒ}
|j	ƒ|j
ƒ}tjrÔt
j|ƒ}t
j|
ƒ}
ntj|ƒ}tj|
ƒ}
|dkrHtjd|ƒ|rH|dkrHtd|d	|d
|
d|ƒ‚qHn|r·tjr–t|tƒru|jƒ}nt|
tƒr´|
jƒ}
q´q·t
j|ƒ}t
j|
ƒ}
n||
fS(sfRun a command through SSH.

    .. versionchanged:: 1.9
       Added *binary* optional parameter.
    sRunning cmd (SSH): %ss"Environment not supported over SSHs$process_input not supported over SSHttimeoutiÿÿÿÿs
Result was %siRRRR(RRlRgtdebugRRtexec_commandtchanneltreadRttrecv_exit_statusR^RwRaRxRtPY2R[tunicodetencodetfsencode(tsshRR=taddl_envR?RHR”Rƒtstdin_streamt
stdout_streamt
stderr_streamR—RRtexit_status((sR/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_concurrency/processutils.pytssh_executeÞsD	
		cCs'ytjƒSWntk
r"dSXdS(s¤Utility to get the default worker count.

    @return: The number of CPUs if that can be determined, else a default
             worker count of 1 is returned.
    iN(tmultiprocessingt	cpu_counttNotImplementedError(((sR/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_concurrency/processutils.pytget_worker_count s
(4RRpRYR¥RaR~RcRRiR|tenumt
oslo_utilsRRRRR^toslo_concurrency._i18nRt
try_importRtpatchertis_monkey_patchedteventlet.greenRt	getLoggerRRgt	ExceptionRRRRRtuniquetIntEnumRR!RzR"R{R tLOG_DEFAULT_ERRORtobjectR#RR“RRXRWR¤R¨(((sR/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_concurrency/processutils.pyt<module>sN 					2	ÿ	@