%PDF- %PDF-
Direktori : /snap/core/17212/usr/lib/python3/dist-packages/cloudinit/__pycache__/ |
Current File : //snap/core/17212/usr/lib/python3/dist-packages/cloudinit/__pycache__/subp.cpython-35.pyc |
"�T`A4 � @ s� d Z d d l Z d d l Z d d l Z d d l m Z e j e � Z d d � Z Gd d � d e � Z d d d d d d d d d d d d d d � Z d d d � Z d d d d � Z d d � Z d d d d � Z d S)z9Common utility functions for interacting with subprocess.� N)�ENOEXECc C s# g } g } g } x� | D]� } t | t � rt | d d k rQ | d d � } q� | d | k r� | j d | � nH t | t � r� | j d | � s� | j | � n | j t | � � q | j | � q W| r� t j d | | d j | � � | rt d j d | d d j | � � � � | S) a� Ensure 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. r N� z%s z Non-%s commands in %s config: %s� zHInvalid {name} config. These commands are not a string or list: {errors}�name�errors)� isinstance�list�insert�str� startswith�append�LOGZwarning�join� TypeError�format)Zbase_commandZcommands�warningsr Zfixed_commands�command� r �0/usr/lib/python3/dist-packages/cloudinit/subp.py�prepend_base_command s0 r c @ sX e Z d Z d Z d Z d d d d d d d d d � Z d d � Z d d d � Z d S)�ProcessExecutionErrorzr%(description)s Command: %(cmd)s Exit code: %(exit_code)s Reason: %(reason)s Stdout: %(stdout)s Stderr: %(stderr)s�-Nc C s� | s | j | _ n | | _ | sO | rC | t k rC d | _ qX d | _ n | | _ t | t � sv | j | _ n | | _ | s� | d k r� | j | _ q� | | _ n | j | � | _ | s� | d k r� | j | _ q� | | _ n | j | � | _ | r| | _ n | j | _ | | _ | j d | j | j � d | j | j � d | j | j � d | j | j � d | j | j � d | j | j � i } t j | | � d S) Nz(Exec format error. Missing #! in script?z'Unexpected error while running command.�description�cmd� exit_code�stdout�stderr�reason)� empty_attrr r r r �intr r �_indent_textr r �errno�MESSAGE_TMPL�_ensure_string�IOError�__init__) �selfr r r r r r r! �messager r r r% E sB zProcessExecutionError.__init__c C s t | t � r | j � S| S)z1 if data is bytes object, decode )r �bytes�decode)r&