def _cleanup(self):
     # remove *.qlog and *.qtxt
     files = fileutil.listdir(self.logpath, qmsg_processor.QLOG_PATTERN) + \
             fileutil.listdir(self.logpath, qmsg_processor.QTXT_PATTERN)
     for f in files:
         try: (self.logpath/f).remove()
         except OSError: traceback.print_exc()
    def _findIdRange(self):
        """ Scan the $archive directory for zip files for the begin and end id. """

        apath = cfg.getpath('archive')
        files = fileutil.listdir(apath, self.arc_pattern)
        if not files:
            self._beginId = 0
            self._endId = 0
            return

        first_arc = min(files)
        last_arc  = max(files)

        first = self._findId(apath/first_arc, min)
        last  = self._findId(apath/last_arc, max)

        self._beginId = int(first_arc[:6] + first)   # would be a 9 digit id
        self._endId   = int(last_arc[:6]  + last )+1 # would be a 9 digit id