Beispiel #1
0
    def recalculate(self):
        log.info('recalculating trip %s' % self.tid)
        pub = Publisher()

        # delete old logs
        for name, config in self.config['series'].items():
            if config['series_type'] != 'secondary': continue
            if name in self.series:
                self.series[name].close()
                del self.series[name]

            for i in config['files']:
                p = self.j(i)
                if os.path.exists(p):
                    os.remove(p)
            del self.config['series'][name]

        d2 = self.j('secondary')
        if not os.path.isdir(d2):
            os.mkdir(d2)
        assert os.listdir(d2) == []

        self.write_manifest()

        def publish(name, ts, value):
            log.debug("%10.3f %s %r" % (ts, name, value))
            self.write_series(name, ts, value)
            pub.fire(name, ts, value)

        pub.publish = publish

        processor_names = [
            name for (name, value) in app.config.items('processors')
            if app.config.getboolean('processors', name)
        ]

        self.processors = {}
        self.config['processors'] = processor_names

        # TODO wipe series manifest??
        for processor_name in processor_names:
            log.info('loading processor %s' % processor_name)
            processor = processors.get_processor(processor_name)(pub)
            self.processors[processor_name] = processor

        try:
            for name, (ts, value) in series_reader(self.series):
                if not name.startswith('canusb'):
                    log.debug("%10.3f %s %r" % (ts, name, value))
                pub.fire(name, ts, value)

        finally:
            for processor in self.processors.itervalues():
                processor.close()
            for series in self.series.itervalues():
                series.close()
            self.write_manifest()

        self.load_logs()
Beispiel #2
0
  def recalculate(self):
    log.info('recalculating trip %s' % self.tid)
    pub = Publisher()

    # delete old logs
    for name, config in self.config['series'].items():
      if config['series_type'] != 'secondary': continue
      if name in self.series:
        self.series[name].close()
        del self.series[name]

      for i in config['files']:
        p = self.j(i)
        if os.path.exists(p):
          os.remove(p)
      del self.config['series'][name]

    d2 = self.j('secondary')
    if not os.path.isdir(d2):
      os.mkdir(d2)
    assert os.listdir(d2) == []

    self.write_manifest()

    def publish(name, ts, value):
      log.debug("%10.3f %s %r" % (ts, name, value))
      self.write_series(name, ts, value)
      pub.fire(name, ts, value)

    pub.publish = publish

    processor_names = [name for (name, value) in app.config.items('processors')
      if app.config.getboolean('processors', name)]

    self.processors = {}
    self.config['processors'] = processor_names

    # TODO wipe series manifest??
    for processor_name in processor_names:
      log.info('loading processor %s' % processor_name)
      processor = processors.get_processor(processor_name)(pub)
      self.processors[processor_name] = processor

    try:
      for name, (ts, value) in series_reader(self.series):
        if not name.startswith('canusb'):
          log.debug("%10.3f %s %r" % (ts, name, value))
        pub.fire(name, ts, value)

    finally:
      for processor in self.processors.itervalues():
        processor.close()
      for series in self.series.itervalues():
        series.close()
      self.write_manifest()

    self.load_logs()
Beispiel #3
0
  def init_processors(self):
    d2 = self.j('secondary')
    if not os.path.isdir(d2):
      os.mkdir(d2)

    processor_names = [name for (name, value) in app.config.items('processors')
      if app.config.getboolean('processors', name)]

    self.config['processors'] = processor_names
    for name in processor_names:
      log.info('loading processor %s' % name)
      processor = processors.get_processor(name)(self)
      self.processors[name] = processor
Beispiel #4
0
    def init_processors(self):
        d2 = self.j('secondary')
        if not os.path.isdir(d2):
            os.mkdir(d2)

        processor_names = [
            name for (name, value) in app.config.items('processors')
            if app.config.getboolean('processors', name)
        ]

        self.config['processors'] = processor_names
        for name in processor_names:
            log.info('loading processor %s' % name)
            processor = processors.get_processor(name)(self)
            self.processors[name] = processor