Logo Search packages:      
Sourcecode: mailping version File versions  Download package

fileutil.py

import os, errno, time, socket, shutil

HOSTNAME = socket.gethostname().replace('/', r'\057').replace(':', r'\072')
PID = os.getpid()

def getTime(path):
    try:
        f=open(path)
    except IOError, e:
        if e.errno == errno.ENOENT:
            return -1
        else:
            raise

    l=f.readline()
    return float(l)

def writeFile(path, content, temp=None):
    if temp is None:
        temp = '%s.%d.%s.%d.tmp' % (
            path,
            int((time.time())*10e6),
            HOSTNAME,
            PID,
            )
    f = file(temp, 'w')
    f.write(content)
    f.close()
    shutil.move(temp, path)

Generated by  Doxygen 1.6.0   Back to index