Ejemplo n.º 1
0
    def procCustFiles(self):
        tgtFiles = []

        fnl = self.ib.custFileName.split(",")
        for fnp in fnl:
            fs = self.checkIncFiles(fnp)
            if len(fs) == 1:
                fnOff = len("_YYYYMMDD.csv")
                self.log.info("Processing %s " % fs[0])
                fn = fu.getFileBaseName(fs[0])
                d = "%s/%s" % (self.ib.archDir, fn)
                rc = fu.copyFile(fs[0], d)
                self.log.info("Archiving %s to %s\trc=%s" % (fs[0], d, rc))
                d = "%s/%s.csv" % (self.ib.workDir, fn[:-fnOff])
                rc = fu.moveFile(fs[0], d)
                self.log.info("Moving %s to %s\trc=%s" % (fs[0], d, rc))
                tgtFiles.append(d)
            else:
                fnOff = len("_*[0-9].csv")
                fn = fu.getFileBaseName(fnp)
                d = "%s/%s.csv" % (self.ib.workDir, fn[:-fnOff])
                self.log.debug("fn = %s, dest = %s" % (fn, d))
                self.log.warn("File %s was not found" % fnp)
                rc = fu.crtEmpFile(d)
                self.log.info("Creating 0 byte file %s\trc=%s" % (d, rc))

        # Verify Column Numbers:
        if self.checkFileColsFlag is True:
            rc = self.checkFileCols(tgtFiles, ",")
            if rc != 0:
                self.log.error("Issue with column number. PLease check bad directory under %s" % self.ib.badDir)
                # Implement email notification.
                # return rc

        return 0
Ejemplo n.º 2
0
 def crtTrigFile(self):
     fn = '%s/%s' % (self.ib.landDir ,self.ib.trigfile)
     rc = fu.crtEmpFile(fn)    
     if rc == False :  
         self.log.error('Could not create file %s' % fn)
         return 1
     else          : 
         self.log.info('Created file %s ' % fn)
     return 0
Ejemplo n.º 3
0
 def _touchFiles(self):
     
     if len(self.ib.crtFiles) < 1 : 
         self.log.error('List to create files is empty !')
         return 1
     
     rc = 0
     for fn in self.ib.crtFiles:
         r = fu.crtEmpFile(fn)    
         if r == False :  
             self.log.error('Could not create file %s' % fn)
             rc += 1
         else          : self.log.info('Created file %s ' % fn)
     return rc
Ejemplo n.º 4
0
 def getOptFiles(self): 
     rc = 0
     for f in self.ib.srcOptFile: 
         fnp = '%s/%s/%s' % (self.ib.shareDir,self.landDir,f)
         self.incFiles.append(fnp)           # Need to be in the incset to be moved to working dir.
         if fu.fileExists(fnp): 
             self.log.debug('fnp exists %s' % fnp)
         
         else : 
             r = fu.crtEmpFile(fnp)
             if r == True : self.log.info ('Touching File %s' % fnp)
             else          : 
                 self.log.Error ('Touching File %s' % fnp)
                 rc+=1
  
     return rc