Esempio n. 1
0
    def __generateBulletin(self,rawBulletin):
        """__generateBulletin(rawBulletin) -> objetBulletin

           Retourne un objetBulletin d'à partir d'un bulletin
           "brut".

        """
        return bulletinPlain.bulletinPlain(rawBulletin,self.logger,self.lineSeparator)
Esempio n. 2
0
    def __generateBulletin(self, rawBulletin):
        """__generateBulletin(rawBulletin) -> objetBulletin

           Retourne un objetBulletin d'à partir d'un bulletin
           "brut".

        """
        return bulletinPlain.bulletinPlain(rawBulletin, self.logger,
                                           self.lineSeparator)
Esempio n. 3
0
    def buildCollectionState(self):

        # loop on all the keys of the map

        count = 0
        map   = {}
        keys  = self.mapCollectionState.keys()
        keys.sort()

        for key in keys :

            header  = key.split("_")

            # create a fake and tiny bulletin

            bulltin = header[0] + ' ' + header[1] + ' ' + header[2] + '\n'
            if header[0][:2] == 'SI' or header[0][:2] == 'SM' :
               bulltin += 'AAXX\n'
            bulltin += 'CYUL NIL='

            unBulletin = bulletinPlain.bulletinPlain(bulltin,self.logger,'\n')
            unBulletin.doSpecificProcessing()

            # get its db name

            nomFichier = self.bullManager.getFileName(unBulletin,0)
            ingestName = self.ingestor.getIngestName(nomFichier)
            dbName     = self.ingestor.getDBName(ingestName)

            # keep only its dir

            map[os.path.dirname(dbName)] = 1

        # compute dates to scan

        fin      = self.fin   - ( self.fin   % (24*3600) )
        debut    = self.debut - ( self.debut % (24*3600) )

        # loop on all path found

        for path in map.keys() :
            parse    = path.split("/")
            specific = string.join(parse[-3:],'/')

            # loop on time

            t = debut
            while t <= fin :

                  # create DB directory

                  Dir  = PXPaths.DB
                  Dir += time.strftime("%Y%m%d",time.localtime(t)) + "/"
                  Dir += specific

                  # read and scan DB directory

                  if os.path.isdir(Dir) :
                     files = os.listdir(Dir)

                     for f in files :

                         # get map key from filename

                         parse = f.split('_')
                         key = parse[0] + '_' + parse[1] + '_' + parse[2]
                         if not key in self.mapCollectionState : continue

                         # we found entry so certainly primary was done... 

                         ( period, amendement, correction, retard, Primary, Cycle ) = self.mapCollectionState[key]

                         period = 0
                         BBB    = parse[3]

                         if BBB == '' : continue

                         # problem cases ...

                         if len(BBB) != 3 or BBB[2] < 'A' or BBB[2] > 'Z' : continue

                         # Amendement or Correction or Retard

                         value = self.alpha.index(BBB[2])

                         if BBB[0] == 'A' and amendement < value : amendement = value
                         if BBB[0] == 'C' and correction < value : correction = value
                         if BBB[0] == 'R' and retard     < value : retard     = value

                         self.mapCollectionState[key] = \
                         ( period, amendement, correction, retard, Primary, Cycle )

                         count = count + 1

                  t = t + 24*3600

        self.logger.info("Collection State had %d updates from DB",count)
Esempio n. 4
0
    def buildCollectionState(self):

        # loop on all the keys of the map

        count = 0
        map = {}
        keys = self.mapCollectionState.keys()
        keys.sort()

        for key in keys:

            header = key.split("_")

            # create a fake and tiny bulletin

            bulltin = header[0] + ' ' + header[1] + ' ' + header[2] + '\n'
            if header[0][:2] == 'SI' or header[0][:2] == 'SM':
                bulltin += 'AAXX\n'
            bulltin += 'CYUL NIL='

            unBulletin = bulletinPlain.bulletinPlain(bulltin, self.logger,
                                                     '\n')
            unBulletin.doSpecificProcessing()

            # get its db name

            nomFichier = self.bullManager.getFileName(unBulletin, 0)
            ingestName = self.ingestor.getIngestName(nomFichier)
            dbName = self.ingestor.getDBName(ingestName)

            # keep only its dir

            map[os.path.dirname(dbName)] = 1

        # compute dates to scan

        fin = self.fin - (self.fin % (24 * 3600))
        debut = self.debut - (self.debut % (24 * 3600))

        # loop on all path found

        for path in map.keys():
            parse = path.split("/")
            specific = string.join(parse[-3:], '/')

            # loop on time

            t = debut
            while t <= fin:

                # create DB directory

                Dir = PXPaths.DB
                Dir += time.strftime("%Y%m%d", time.localtime(t)) + "/"
                Dir += specific

                # read and scan DB directory

                if os.path.isdir(Dir):
                    files = os.listdir(Dir)

                    for f in files:

                        # get map key from filename

                        parse = f.split('_')
                        key = parse[0] + '_' + parse[1] + '_' + parse[2]
                        if not key in self.mapCollectionState: continue

                        # we found entry so certainly primary was done...

                        (period, amendement, correction, retard, Primary,
                         Cycle) = self.mapCollectionState[key]

                        period = 0
                        BBB = parse[3]

                        if BBB == '': continue

                        # problem cases ...

                        if len(BBB) != 3 or BBB[2] < 'A' or BBB[2] > 'Z':
                            continue

                        # Amendement or Correction or Retard

                        value = self.alpha.index(BBB[2])

                        if BBB[0] == 'A' and amendement < value:
                            amendement = value
                        if BBB[0] == 'C' and correction < value:
                            correction = value
                        if BBB[0] == 'R' and retard < value: retard = value

                        self.mapCollectionState[key] = \
                        ( period, amendement, correction, retard, Primary, Cycle )

                        count = count + 1

                t = t + 24 * 3600

        self.logger.info("Collection State had %d updates from DB", count)