Ejemplo n.º 1
0
    def _chkHeader(self,fnp,rdoff):
        RUN_DATE = su.getTodayDtStr(fmt='%y%m%d')
        rdayoffset = su.toInt(rdoff)
        
        hdr   = fu.readFile(fnp)
        
        if len(hdr) != 14 :
            self.log.error('Invalid len= %d  for %s. Need to be 14\nhdr=%s' % (len(hdr),fnp,hdr))
            return 1
            
        rowc     = su.toInt(hdr[0:8])
        hdr_date = hdr[8:]                  # Run Date from file.
          
        dt = su.getDayMinusStr(rdayoffset, RUN_DATE, '%Y%m%d')

        # Check run date.
        if dt != hdr_date:
            self.log.warn('fn %s === \tInvalid Header ran date of %s. Should be %s  ' % (fnp,dt,hdr_date))
        
        if rdayoffset < 1 : 
            self.log.error('Could not attempt next day since rdayoffset is %s < 1' % rdayoffset)
            return 2
            
        dt = su.getDayMinusStr(rdayoffset - 1, RUN_DATE, '%Y%m%d')
        # Check run date + 1.
        if dt != hdr_date:
            self.log.error('fn %s === \tInvalid Header ran date of %s. Should be %s  ' % (fnp,dt,hdr_date))
            return 3
        
        # 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 4
        
        return 0
Ejemplo n.º 2
0
    def verTrigFileDate(self):
        global RUN_DATE
        rc = 0
        
        rdayoffset = su.toInt(self.ib.rdayoffset)
        if rdayoffset is None or rdayoffset < 0:
            self.log.error('rdayoffset needs to be a number => 0. Current Value = %s' % self.ib.rdayoffset)
            
        if rdayoffset != 0 :
            RUN_DATE = su.getDayMinusStr(rdayoffset, RUN_DATE, '%Y%m%d')

        for fn in self.trigFiles:
            fdt = fu.readFile(fn).strip(' \t\n\r')
            self.log.debug('fn = %s fdt = %s RUN_DATE=%s rdayoffset = %s ' % (fn,fdt,RUN_DATE, rdayoffset))
            if fdt != RUN_DATE:
                self.log.error("%s date field %s does not match the process RUN_DATE %s." % (fn,fdt,RUN_DATE))
                rc = 1
            else :
                self.log.info("%s date field %s matches the process RUN_DATE %s." % (fn,fdt,RUN_DATE))
        return rc
Ejemplo n.º 3
0
    def getDlyCnt(self):
        rc = 1
        
        dd = su.toInt(self.ib.schDayOff)
        if dd is not None :
            dow = su.getDayofWeek(self.fileDate)
            if self.fileDate == '' :                  # Verification only. Need to be based on run date.
                if dow == 'Mon':                       # Runs on Monday. (2 days lag for proc_dt)
                    dd = 2
                    self.log.info('Monday Run %s offset = %d' % (self.fileDate,dd))
            else                   :                  # It is coming from a full run, since self.fileDate is defined from file name.
                if dow == 'Sun':
                    dd = 1
                    self.log.info('Sunday Created file %s offset = %d' % (self.fileDate,dd))

            self.log.info('Schedule Day Offset = %d' % (dd))


        else:
            self.log.error("Schedule Day Offset = %s " % self.ib.schDayOff)
            return rc

        dt =  su.getDayMinusStr(dd,self.fileDate)
        rs =self._getNZDS(da.selInvAppDtlLoadDtQry % dt)
        self.log.debug('date=', dt,'rs=', rs)
        if rs is not None and len(rs) > 0:
            cnt = su.toInt(rs[0][0])
            if cnt is not None and cnt > 1:
                self.log.info('Count for %s = %d' % (dt,cnt))
                self.RowCnt = cnt
                rc = 0
            else: self.log.error("Count for %s = %s " % (dt, cnt))
            
        else: self.log.error('rs error : ',  rs)
        
        return rc