/usr/lib/python3/dist-packages/cloudinit/__pycache__
NameSizeModeActions
apport.cpython-310.pyc73170644editdlrm
atomic_helper.cpython-310.pyc28780644editdlrm
cloud.cpython-310.pyc31990644editdlrm
dmi.cpython-310.pyc63100644editdlrm
event.cpython-310.pyc20760644editdlrm
features.cpython-310.pyc16680644editdlrm
gpg.cpython-310.pyc69120644editdlrm
helpers.cpython-310.pyc136850644editdlrm
importer.cpython-310.pyc17760644editdlrm
lifecycle.cpython-310.pyc83840644editdlrm
netinfo.cpython-310.pyc140660644editdlrm
performance.cpython-310.pyc36670644editdlrm
persistence.cpython-310.pyc29310644editdlrm
registry.cpython-310.pyc14820644editdlrm
safeyaml.cpython-310.pyc79310644editdlrm
settings.cpython-310.pyc11850644editdlrm
signal_handler.cpython-310.pyc26890644editdlrm
simpletable.cpython-310.pyc26880644editdlrm
socket.cpython-310.pyc47440644editdlrm
ssh_util.cpython-310.pyc158150644editdlrm
stages.cpython-310.pyc275610644editdlrm
subp.cpython-310.pyc99720644editdlrm
templater.cpython-310.pyc63740644editdlrm
temp_utils.cpython-310.pyc28370644editdlrm
type_utils.cpython-310.pyc4710644editdlrm
url_helper.cpython-310.pyc291510644editdlrm
user_data.cpython-310.pyc85150644editdlrm
util.cpython-310.pyc708780644editdlrm
version.cpython-310.pyc4660644editdlrm
warnings.cpython-310.pyc33760644editdlrm
__init__.cpython-310.pyc1450644editdlrm
Edit: /usr/lib/python3/dist-packages/cloudinit/__pycache__/subp.cpython-310.pyc (9972B)
o thr1 @sdZddlZddlZddlZddlZddlmZddlmZddl m Z m Z m Z ddl mZeeZeddd gZd d ZGd d d eZde e ee effddZdddddddddd de eee ee efdefddZd ddZd de efddZddZd!ddZdS)"z9Common utility functions for interacting with subprocess.N)ENOEXEC) TextIOWrapper)ListOptionalUnion) performance SubpResultstdoutstderrcCsg}g}g}|D]A}t|tr)|ddur|dd}n(|d|kr(|d|nt|tr<||ds;||n|t|q||q|rWtd||d||ret dj |d|d|S) aEnsure user-provided commands start with base_command; warn otherwise. Each command is either a list or string. Perform the following: - If the command is a list, pop the first element if it is None - If the command is a list, insert base_command as the first element if not present. - When the command is a string not starting with 'base-command', warn. Allow flexibility to provide non-base-command environment/config setup if needed. @commands: List of commands. Each command element is a list or string. @return: List of 'fixed up' commands. @raise: TypeError on invalid config item type. rN z Non-%s commands in %s config: %s zHInvalid {name} config. These commands are not a string or list: {errors})nameerrors) isinstancelistinsertstr startswithappendLOGwarningjoin TypeErrorformat) base_commandcommandswarningsrfixed_commandscommandr 0/usr/lib/python3/dist-packages/cloudinit/subp.pyprepend_base_commands@        r"c@sZeZdZdZdZ       d ddZddZ dd eee fd eee ffd d Z dS)ProcessExecutionErrorzr%(description)s Command: %(cmd)s Exit code: %(exit_code)s Reason: %(reason)s Stdout: %(stdout)s Stderr: %(stderr)s-Nc Cs|p|j|_|r ||_n |s|tkrd|_nd|_t|tr |n|j|_|s1|dur-|jn||_n|||_|sD|dur@|jn||_ n|||_ |pN|j|_ |rU||_ |j | |j| |j| |j| |j | |j| |j d}t||dS)Nz(Exec format error. Missing #! in script?z'Unexpected error while running command.) descriptioncmd exit_coder r reason) empty_attrr&r%rrintr'r _indent_textr r(errno MESSAGE_TMPL_ensure_stringIOError__init__) selfr r r'r&r%r(r,messager r r!r0Qs4           zProcessExecutionError.__init__cCst|tr |S|S)z1 if data is bytes object, decode rbytesdecode)r1textr r r!r.sz$ProcessExecutionError._ensure_stringr6returncCs>t|ts|dddd|S|dddd|S)z indent text on all but the first line, allowing for easy to read output remove any newlines at end of text first to prevent unneeded blank line in output r r   )rr4rstripreplace)r1r6 indent_levelr r r!r+s z"ProcessExecutionError._indent_text)NNNNNNN)r7) __name__ __module__ __qualname__r-r)r0r.rrr4r+r r r r!r#Fs& /  r#argscCs@|D]}t|tst|dstd|t|d|dqdS)zcheck argument types to ensure that subp() can run the argument Throw a user-friendly exception which explains the issue. args: list of arguments passed to subp() raises: ProcessExecutionError with information explaining the issue encodezRunning invalid command: %szRunning invalid command: )r&r(N)rr4hasattrrrr#)rA componentr r r!raise_on_invalid_commands  rETFr<) datarcscaptureshell logstringr5 update_envcwdtimeoutr8c  s|durdg}tj} |r| |td|r|n||||d} d} |r,tj} tj} |dur4tj} n tj} t |t s@| }t |t rH|}nt |t rS| d}n t |dd|D}z3td|rg|n|tj|| | | | ||d}|j|| d \}}Wdn1swYWn"ty}zt|||jrd nd rd d |d d |d}~wwrdfd d }||}||}|j}||vrt||||dt||S)aRun a subprocess. :param args: command to run in a list. [cmd, arg1, arg2...] :param data: input to the command, made available on its stdin. :param rcs: a list of allowed return codes. If subprocess exits with a value not in this list, a ProcessExecutionError will be raised. By default, data is returned as a string. See 'decode' parameter. :param capture: boolean indicating if output should be captured. If True, then stderr and stdout will be returned. If False, they will not be redirected. :param shell: boolean indicating if this should be run with a shell. :param logstring: the command will be logged to DEBUG. If it contains info that should not be logged, then logstring will be logged instead. :param decode: if False, no decoding will be done and returned stdout and stderr will be bytes. Other allowed values are 'strict', 'ignore', and 'replace'. These values are passed through to bytes().decode() as the 'errors' parameter. There is no support for decoding to other than utf-8. :param update_env: update the environment for this command with this dictionary. this will not affect the current processes os.environ. :param cwd: change the working directory to cwd before executing the command. :param timeout: maximum time for the subprocess to run, passed directly to the timeout parameter of Popen.communicate() :return if not capturing, return is (None, None) if capturing, stdout and stderr are returned. if decode: entries in tuple will be string if not decode: entries in tuple will be bytes NrzFRunning command %s with allowed return codes %s (shell=%s, capture=%s)utf-8cSs$g|]}t|tr |n|dqSrN)rr4rB).0xr r r! szsubp..z Running {!r})r r stdinenvrIrL)rMr$-)r&r(r,r r cst|tr ||S|SNr3)rFmr5r r!ldecodeszsubp..ldecode)r r r'r&rO)osenvironcopyupdaterdebug subprocessPIPEDEVNULLrr4rBrrErTimedrPopen communicateOSErrorr#r, returncoder)rArFrGrHrIrJr5rKrLrMrTr r rS bytes_argsspouterrerYrcr rXr!subps2            rmcCs|dvrd}nt|tstd|tj|}|dr$|dd}|s(|St|rB|ddkrB|dd}t|rB|ddks2tj||S)N)N/zUnexpected input for target: z//r r) rr ValueErrorrZpathabspathrlenr)targetrqr r r! target_path)s     rucCst|}tjj|vrtt||r|S|dur4ddtjddtjD}|dkr-|ndd|D}dd|D}|D]}tjj ||f}tt||rS|Sq=dS)NcSsg|]}|dqS)")striprPpr r r!rRHs zwhich..PATHrnrocSsg|] }|dr|qS)ro)rrxr r r!rRLscSsg|]}tj|qSr )rZrqrrrxr r r!rROs) rurZrqsepis_exer[getsplitpathsepr)programsearchrtpathsrqppathr r r!which>s rcCstj|o t|tjSrV)rZrqisfileaccessX_OK)fpathr r r!r|Ysr|c Cs<|r tj|s dSg}g}|durg}nt|tr t|g}n t|tr(|}ntdtt|D]M}tj ||}t |rm| |z t ||gddWq3t yl}zt|| |WYd}~q3d}~wwtj|rztd|q3td|q3|r|rtdt|dd |d t|d dSdS) Nz%exe_prefix must be None, str, or listF)rHzjskipping %s as its not executable or the underlying file system is mounted without executable permissions.zNot executing special file [%s]z Runparts: z failures (,z) in z attempted commands)rZrqisdirrrrrsortedlistdirrr|rrmr#rr^rr RuntimeErrorrs) dirp skip_no_exist exe_prefixfailed attemptedprefixexe_nameexe_pathrkr r r!runparts^sF      r)NN)TN)__doc__ collectionsloggingrZr_r,riortypingrrr cloudinitr getLoggerr>r namedtuplerr"r/r#rr4rErmrurr|rr r r r!sB    3N