Viewing File: /usr/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(		
Back to Directory File Manager