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
def chkTrailer (self,fL,trl_date): rc = 0 for fnp in fL: if fu.fileExists(fnp) is False: self.log.error('File %s does not exists ' % fnp) continue if fu.getFilseSize(fnp) == 0 : self.log.error('File %s is Empty !' % fnp) continue r = self._checkTrailer(fnp,trl_date) if r != 0 : rc = 1 return rc
def chkHeader(self,fL): procFiles = [] for fnp in fL: if fu.fileExists(fnp) is False: self.log.error('File %s does not exists ' % fnp) continue if fu.getFilseSize(fnp) == 0 : self.log.error('File %s is Empty !' % fnp) continue rc = self._checkHeader(fnp) if rc == 0 : procFiles.append(fnp) return procFiles
def chkErrFile(self): rc = 1 fnp = '%s/%s' % (self.ib.tgtDir,self.ib.errorFileName) self.log.info('Checking for file %s' % (fnp)) if fu.fileExists(fnp): fileSz = fu.getFilseSize(fnp) if fileSz == 0 : return 0 else: self.log.error('filename %s does not exist!' % (fnp)) if self.notifUsersFlg is True: self._notifyUsers() # At this point file exist and size > 0. Let's Check for blank lines! rc = fu.remBlankLines(fnp) self.log.info('Found File %s size = %d(bytes). Checked for non blank lines = %d.' % (fnp,fileSz,rc)) if rc != 0 : self.log.error ('Error File created : filename %s. Lines = %d ' % (fnp,rc)) if self.notifUsersFlg is True: r = self._notifyUsers(rc) self.log.info ('Notifying Users rc= %s' % (r) ) return rc