예제 #1
0
 def getFileProcDate(self,fnp):
     tr  = fu.getLastLine(fnp)
     tok = tr.split()
     self.log.debug('Last line = ', tr , ' tokens ', tok)
     if len(tok) != 4 :
         self.log.error('filename %s === \tInvalid Number of tokens.It has %d need to be 4 !' % (fnp,len(tok)))
         return None
         
     if su.isValidDate(tok[1],'%Y%m%d') is False : 
         self.log.error('fn %s === \tInvalid date %s!' % (fnp,tok[1]))
         return None
     
     return tok[1]
예제 #2
0
 def _checkTrailer(self,fnp,trl_date):
     self.log.info("Filename : %s " %  fnp)
     fd = -1; ln =-1; tr=-1; rowc=-1; dt=-1; lc=-1;tok = []
     try:
         # Check if valid Date & truncate last line (trailer Line)
         tr         = fu.getLastLine(fnp,1).rstrip()     # Trailer Line
         tok        = tr.split()
         self.log.debug('Last line = ', tr , ' tokens ', tok)
         if len(tok) != 4 :
             self.log.error('filename %s === \tInvalid Number of tokens.It has %d need to be 4 !' % (fnp,len(tok)))
             return 1
         
         if tok[0] != 'TRAILER':
             self.log.error('filename %s === \tInvalid TRAILER LINE.It need to start with TRAILER insted of !' % (fnp,tok[0]))
             return 2
         
         dt = tok[1]
         if su.isValidDate(dt,'%Y%m%d') is False : 
             self.log.error('fn %s === \tInvalid date %s!' % (fnp,dt))
             return 3
         
         rowc = su.toInt(tok[3])
         if rowc is None:
             self.log.error('fn %s === \tInvalid row count %s!' % (fnp,tok[3]))
             return 4
         
         if dt != trl_date:
             self.log.error('fn %s === \tInvalid Trailer ran date of %s. Should be %s  ' % (fnp,dt,trl_date))
             return 5
                 
         # Check Number of lines 
         ln  = fu.getLines(fnp)      # Number of lines w/o trailer.
         dc =  int(ln) - rowc        # ln file has 2 extra lines header/trailer, but at this point trailer rec had been removed.
         self.log.debug('fn %s === \tFile record count %s trailer = %s diff %s' % (fnp,ln,rowc,dc))
         if  dc != 0 :
             self.log.error('fn %s === \tFile record count %s do not match trailer = %s # of records diff = %d!' % (fnp,ln,rowc,dc))
             return 6
         
         return 0
     
     # Invalid datatypes fields for verification process !!
     except:            
         self.log.error(' ==EXCEP %s ' % (sys.exc_info()[1]))
         return 5
     
     finally:
         self.log.debug('fn  %s == date %s\t lines %s' % (fnp,fd,ln))
         self.log.debug('trl %s == date %s\t lines %s' % (tr,dt,rowc))
예제 #3
0
    def _chkMthlyTrailer(self,fnp,fdr):
 
        # Check if valid Date & truncate last line (trailer Line)
        tr         = fu.getLastLine(fnp,1).rstrip()     # Trailer Line
        dt, rowc = tr[:6],int(tr[6:])
        date = '%s%s' % (dt[:4],dt[4:])
        if su.isValidDate(date,'%Y%m') is False : 
            self.log.error('fn %s === \tInvalid date %s!' % (fnp,date))
            return -1
              
        fd  = fdr[:6]
        if dt != fd :
            self.log.error('fn %s === \tFile Date = %s do not match trailer = %s!' % (fnp,fd,dt))
            return -2     
        
        return rowc