Current File : //lib/python2.7/site-packages/cloudinit/temp_utils.pyo
�
oB�]c@s�ddlZddlZddlZddlZddlZdadZdZde	d�Z
d�Zeje	d��Z
d�Zd�ZdS(	i����Ns/run/cloud-init/tmps/var/tmp/cloud-initcCs�|dk	r|S|rRt}tjj|�sNtj|�tj|d�n|Str\tStj�dkrwt	}ntj
jdd�}tjj|�s�tj|�tj|d�n|a|S(s%Return the proper 'dir' argument for tempfile functions.

    When root, cloud-init will use /run/cloud-init/tmp to avoid
    any cleaning that a distro boot might do on /tmp (such as
    systemd-tmpfiles-clean).

    If the caller of this function (mkdtemp or mkstemp) was provided
    with a 'dir' argument, then that is respected.

    @param odir: original 'dir' arg to 'mkdtemp' or other.
    @param needs_exe: Boolean specifying whether or not exe permissions are
        needed for tempdir. This is needed because /run is mounted noexec.
    i�itTMPDIRs/tmpN(tNonet_EXE_ROOT_TMPDIRtostpathtisdirtmakedirstchmodt_TMPDIRtgetuidt_ROOT_TMPDIRtenvirontget(todirt	needs_exettdir((s8/usr/lib/python2.7/site-packages/cloudinit/temp_utils.pyt_tempfile_dir_args$
	
csot|jdd�|jdt��|d<tj|��d�}|�_�fd�}t�d|��S(NtdirRcSsFytj|�Wn.tk
rA}|jtjkrB|�qBnXdS(N(RtunlinktOSErrorterrnotENOENT(Rte((s8/usr/lib/python2.7/site-packages/cloudinit/temp_utils.pyt_unlink_if_exists>s
cs�j�j�dS(N(Rtname((tfh(s8/usr/lib/python2.7/site-packages/cloudinit/temp_utils.pyt
unlink_nowLsR(RtpopRtFalsettempfiletNamedTemporaryFileRtsetattr(tkwargsRR((Rs8/usr/lib/python2.7/site-packages/cloudinit/temp_utils.pytExtendedTemporaryFile6s(		cks0t|�}z	|VWdtj|d|�XdS(Nt
ignore_errors(tmkdtemptshutiltrmtree(trmtree_ignore_errorsR R((s8/usr/lib/python2.7/site-packages/cloudinit/temp_utils.pyttempdirSs	cKs8t|jdd�|jdt��|d<tj|�S(NRR(RRRRRR#(R ((s8/usr/lib/python2.7/site-packages/cloudinit/temp_utils.pyR#_s(cKs8t|jdd�|jdt��|d<tj|�S(NRR(RRRRRtmkstemp(R ((s8/usr/lib/python2.7/site-packages/cloudinit/temp_utils.pyR(es((t
contextlibRRR$RRRR
RRRR!tcontextmanagerR'R#R((((s8/usr/lib/python2.7/site-packages/cloudinit/temp_utils.pyt<module>s(