Exemplo n.º 1
0
    def _isFileStable(self, fn):
        # We know that file exist
        r = fu.chkFileModTime(fn)
        rc = (float(r) > float(self.ib.stableFile))
        self.log.debug('chkFileModTime r = %s > %s \trc=%s' % (r, self.ib.stableFile, rc))
        if rc is True: self.log.info('File %s is stable ' % (fn))
        else         : self.log.warn('File %s is Not stable.\n\tWill Sleep for %s secs' % (fn, self.ib.stableFile))

        if rc is False:
            i = 1
            wi = int(self.ib.stbFileIter)
            while (i <= wi):
                time.sleep(float(self.ib.stableFile))
                r = fu.chkFileModTime(fn)
                rc = (float(r) > float(self.ib.stableFile))
                self.log.debug('chkFileModTime r = %s > %s \trc=%s' % (r, self.ib.stableFile, rc))
                self.log.info('Iteration %d out of %d' % (i, wi))
                if rc is True: self.log.info('File %s is stable ' % (fn))
                else         : self.log.warn('File %s is Not stable.\n\tWill Sleep for %s secs' % (fn, self.ib.stableFile))

                if rc is True : break
                else          : i += 1
        
        self.log.info('rc = ', rc)
        if rc is False: return 1 
    
        return rc 
Exemplo n.º 2
0
def _checkIncWildFiles(fn):

    # Get file
    fnp = fu.getNewestFile(ib.landDir, fn)
    log.debug("Newest File ", fnp)
    if fnp is None:
        log.error("No files were found for %s/%s " % (ib.landDir, fn))
        return 1

    # Check file last modification time
    tm = fu.chkFileModTime(fnp)
    if float(tm) > float(ib.fileAge):
        log.error("file %s age %.1f secs is older than fileAge %s secs" % (fnp, tm, ib.fileAge))
        return 2

    log.info("file %s age  %.1f secs is newer than  fileAge %s secs" % (fnp, tm, ib.fileAge))

    fms = su.toInt(ib.fileMinSize)
    log.debug("fms = %s ib.fileMinSize %s" % (fms, ib.fileMinSize))
    if fms is None:
        return 3
    # Check File Size in bytes, only if fileMinSize > -1
    if fms > -1:
        fs = fu.getFilseSize(fnp)
        log.debug("size = %s minsize = %s fnp = %s " % (fs, fms, fnp))

        if fs < fms:
            log.error("File fnp %s %s(bytes) < %s fileMinSize" % (fnp, fs, fms))
            return 4

    return 0