HEX
Server: Apache
System: Linux msm5694.mjhst.com 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64
User: camjab_ssh (1000)
PHP: 5.3.29
Disabled: NONE
Upload Files
File: //lib/python2.7/site-packages/vdo/utils/FileUtils.pyc
ó
.Åt_c@s'dZddlmZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlmZddl
m
Z
mZejdƒdefd	„ƒYZd
efd„ƒYZdefd
„ƒYZdefd„ƒYZdefd„ƒYZdS(sˆ

  FileUtils - Provides dmmgmnt file-related capabilities.

  $Id: //eng/vdo-releases/magnesium/src/python/vdo/utils/FileUtils.py#1 $

iÿÿÿÿ(tprint_functionNi(tCommand(tTimeouttTimeoutErrortutilstFileBasecBsheZdZejdƒZed„ƒZd„Zd„Z	d„Z
ed„ƒZejd„ƒZRS(s‘The FileBase object; provides basic file control.

  Class attributes:
    log (logging.Logger) - logger for this class
  Attributes:
    None
  sutils.FileBasecCs|jS(N(t_FileBase__filePath(tself((s7/usr/lib/python2.7/site-packages/vdo/utils/FileUtils.pytpath:scOsAtt|ƒjƒtjj|ƒ|_|jddƒ|_	dS(s:
    Arguments:
      None
    Returns:
      Nothing
    tfdN(
tsuperRt__init__tosRtrealpathRtgettNonet
_FileBase__fd(RtfilePathtargstkwargs((s7/usr/lib/python2.7/site-packages/vdo/utils/FileUtils.pyRAscCs|S(N((R((s7/usr/lib/python2.7/site-packages/vdo/utils/FileUtils.pyt	__enter__MscCstS(N(tFalse(Rt
exceptionTypetexceptionValuet	traceback((s7/usr/lib/python2.7/site-packages/vdo/utils/FileUtils.pyt__exit__QscCs|jS(N(R(R((s7/usr/lib/python2.7/site-packages/vdo/utils/FileUtils.pyt_fdXscCs
||_dS(N(R(Rtvalue((s7/usr/lib/python2.7/site-packages/vdo/utils/FileUtils.pyR_s(
t__name__t
__module__t__doc__tloggingt	getLoggertlogtpropertyRRRRRtsetter(((s7/usr/lib/python2.7/site-packages/vdo/utils/FileUtils.pyR-s			t	FileTouchcBs8eZdZejdƒZd„Zd„Zd„ZRS(s‡The FileTouch object; touches the file.

  Class attributes:
    log (logging.Logger) - logger for this class
  Attributes:
    None
  sutils.FileTouchcOs tt|ƒj|||ŽdS(s:
    Arguments:
      None
    Returns:
      Nothing
    N(R
R$R(RRRR((s7/usr/lib/python2.7/site-packages/vdo/utils/FileUtils.pyRyscCsštt|ƒjƒ|jdkr–tjj|jƒ}tj|tj	ƒsnt
dd|gƒ}|jƒntj|jtj	ƒs–|jƒq–n|S(s0Make certain the file exists and return ourself.tmkdirs-pN(
R
R$RRRRRtdirnametaccesstF_OKRtrunt_createFile(RtdirPathtcmd((s7/usr/lib/python2.7/site-packages/vdo/utils/FileUtils.pyRƒs
cCs#td|jgƒ}|jƒdS(sCreates the targe file.ttouchN(RRR)(RR,((s7/usr/lib/python2.7/site-packages/vdo/utils/FileUtils.pyR*šs(	RRRRR R!RRR*(((s7/usr/lib/python2.7/site-packages/vdo/utils/FileUtils.pyR$hs
		
	tFileOpencBsÅeZdZejdƒZed„ƒZd„Zdd„Z	dd„Z
dd„Ze
jd„Zdd	„Zd
„Zd„Zd„Zd
„Zd„Zdd„Zd„Zed„ƒZRS(s•The FileOpen object; provides basic access to a file.

  Class attributes:
    log (logging.Logger) - logger for this class
  Attributes:
    None
  sutils.FileOpencCs|jS(N(t_FileOpen__file(R((s7/usr/lib/python2.7/site-packages/vdo/utils/FileUtils.pytfile²scCs|jjƒdS(N(R0tflush(R((s7/usr/lib/python2.7/site-packages/vdo/utils/FileUtils.pyR1·siÿÿÿÿcCs|jj|ƒS(N(R0tread(Rt
numberOfBytes((s7/usr/lib/python2.7/site-packages/vdo/utils/FileUtils.pyR2»scCs|jj|ƒS(N(R0treadline(RR3((s7/usr/lib/python2.7/site-packages/vdo/utils/FileUtils.pyR4¿scCs-|dkr|jjƒS|jj|ƒSdS(N(RR0t	readlines(RtnumberOfBytesHint((s7/usr/lib/python2.7/site-packages/vdo/utils/FileUtils.pyR5Ãs
cCs|jj||ƒdS(N(R0tseek(Rtoffsettwhence((s7/usr/lib/python2.7/site-packages/vdo/utils/FileUtils.pyR7ÎscCs0|dkr|jjƒn|jj|ƒdS(N(RR0ttruncate(Rtsize((s7/usr/lib/python2.7/site-packages/vdo/utils/FileUtils.pyR:ÒscCs|jj|ƒdS(N(R0twrite(Rtstring((s7/usr/lib/python2.7/site-packages/vdo/utils/FileUtils.pyR<ÝscCs|jj|ƒdS(N(R0t	writeline(RtsequenceOfStrings((s7/usr/lib/python2.7/site-packages/vdo/utils/FileUtils.pyt
writelinesáscCs
|jjƒS(N(R0tnext(R((s7/usr/lib/python2.7/site-packages/vdo/utils/FileUtils.pyRAçscCs_tt|ƒjƒ|jdkr@tj|j|jƒ|_ntj	|j|j
ƒ|_|S(s!Open the file and return ourself.N(R
R.RRRRtopenRt_osModetfdopent_FileOpen__modeR/(R((s7/usr/lib/python2.7/site-packages/vdo/utils/FileUtils.pyRës
cCs)|jjƒtt|ƒj|||ƒS(s Close the file.(R0tcloseR
R.R(RRRR((s7/usr/lib/python2.7/site-packages/vdo/utils/FileUtils.pyRôs
trcOs×tt|ƒj|||Žd}t|ƒdkrPd|dkrPtj}nH|ddkrltj}n,|ddkrtjtj	B}n	tj}|ddkr¸|tj
B}nd|_||_||_
dS(s:
    Arguments:
      None
    Returns:
      Nothing
    it+iRGtwtaN(R
R.RRtlenRtO_RDWRtO_RDONLYtO_WRONLYtO_TRUNCtO_APPENDR/REt_FileOpen__osMode(RRtmodeRRtosMode((s7/usr/lib/python2.7/site-packages/vdo/utils/FileUtils.pyRüs"			cCs|S(N((R((s7/usr/lib/python2.7/site-packages/vdo/utils/FileUtils.pyt__iter__scCs|jS(N(RQ(R((s7/usr/lib/python2.7/site-packages/vdo/utils/FileUtils.pyRCsN(RRRRR R!R"R0R1R2R4RR5RtSEEK_SETR7R:R<R@RARRRRTRC(((s7/usr/lib/python2.7/site-packages/vdo/utils/FileUtils.pyR.¥s"								tFileLockcBs;eZdZejdƒZdd„Zd„Zd„Z	RS(sThe FileLock object; a context manager providing interlocked access on
  a file.

  The file is created, if necessary.

  Class attributes:
    log (logging.Logger) - logger for this class
  Attributes:
    _timeout - timeout in seconds (None = no timeout)
  sutils.FileLockcOs&tt|ƒj||ƒ||_dS(s¦
    Arguments:
      filePath - (str) path to file
      mode - (str) open mode
      timeout - (int) timeout in seconds; may be None
    Returns:
      Nothing
    N(R
RVRt_timeout(RRRRttimeoutRR((s7/usr/lib/python2.7/site-packages/vdo/utils/FileUtils.pyR:s	cCstt|ƒjƒ|jtjkr7tj}d}ntj}d}|j	dk	rÐ|jjdj
d|jd|j	d|ƒƒt|j	tdƒj
d|jd|j	ƒƒtj|j|ƒWdQXn8|jjd	j
d|jd|ƒƒtj|j|ƒ|S(
s_If the open mode is read-only the file is locked shared else it is
    locked exclusively.
    tsharedt	exclusives'attempting to lock {f} in {s}s mode {m}tftstms!Could not lock {f} in {s} secondsNsattempting to lock {f} mode {m}(R
RVRRCRRMtfcntltLOCK_SHtLOCK_EXRWRR!tdebugtformatRRt_tflockR0(Rt	flockModetlockModeString((s7/usr/lib/python2.7/site-packages/vdo/utils/FileUtils.pyRGs(					
	
cCs`tj|jtjƒ|tk	rD|jjdjd|jƒƒnt	t
|ƒj|||ƒS(s Unlocks and closes the file.sreleased lock {f}R[(R^RdR0tLOCK_UNRR!RaRbRR
RVR(RRRR((s7/usr/lib/python2.7/site-packages/vdo/utils/FileUtils.pyRds"N(
RRRRR R!RRRR(((s7/usr/lib/python2.7/site-packages/vdo/utils/FileUtils.pyRV&s

	
	tFileTempcBs8eZdZejdƒZdddd„Zd„ZRS(sµThe FileTemp object; a context manager providing temporary files
  with specified (or default) owner and permissions.
  An optional destination parameter specifies the location to which the
  temp file should be moved at exit, if no exception is encountered.
  The move, if specified, is performed after performing the owner
  manipulations.

  Class attributes:
    log (logging.Logger) - logger for this class
  Attributes:
    None
  sutils.FileTempcOs|tjƒ}tt|ƒj|ddd|dƒ|sNttjƒƒ}n|s]d}n||_||_	||_
dS(sæ
    Arguments:
      owner - (str) the owner to set for the file
      ownerPerm - (str) the permissions to set for the owner
      destination (str) the path to which to move the temp file on exit
    Returns:
      Nothing
    isr+R	itrwN(ttempfiletmkstempR
RhRtstrRtgeteuidt_FileTemp__ownert_FileTemp__ownerPermt_FileTemp__destination(Rtownert	ownerPermtdestinationRRttmpFile((s7/usr/lib/python2.7/site-packages/vdo/utils/FileUtils.pyRs
'			cCs6|}|dkrÏ|jdk	rÏytd|j|jgƒ}|jƒtddjd|jgƒ|jgƒ}|jƒ|jj	ƒtd|j|jgƒ}|jƒWqÏt
k
rË}|}qÏXn|dk	sê|jdkry#td|jgƒ}|jƒWqqXntt|ƒj
|||ƒS(Ntchowntchmodt=tutmvtrm(RRpRRnRR)tjoinRoR0RFt	ExceptionR
RhR(RRRRt	exceptionR,tex((s7/usr/lib/python2.7/site-packages/vdo/utils/FileUtils.pyR¥s*
*


N(	RRRRR R!RRR(((s7/usr/lib/python2.7/site-packages/vdo/utils/FileUtils.pyRhws	(Rt
__future__RterrnoR^tgettexttgrpRRtstatRjttimeRRRtinstalltobjectRR$R.RVRh(((s7/usr/lib/python2.7/site-packages/vdo/utils/FileUtils.pyt<module>s$
;=Q