def open_storage(self): try: self.storage = Storage(self.config['datafile']) logging.info("Storage opened") except Exception as ex: logging.error("Could not open Storage: %s. Exiting." % ex) self.close() sys.exit(5)
def main(): writer = csv.writer(sys.stdout) storage = Storage(config['datafile']) for r in storage.reader(): if r[0] == 0x40: # camera fname = "%s-%s.jpg" % (r[0], r[1]) with open(fname, 'w') as f: f.write(r[3]) print "wrote: %s" % fname else: writer.writerow(r)
def __init__(self, datafile, probespath, probe_confs): self.active = False self.active_probes = 0 self.probespath = probespath self.loop = pyev.Loop() #self.queue = Queue() # initialize and start a idle watcher #self.idle_watcher = pyev.Idle(self.loop, self.idle_cb) #self.idle_watcher.start() # initialize and start a signal watchers sigterm_watcher = pyev.Signal(signal.SIGTERM, self.loop, self.sigterm_cb) sigterm_watcher.start() sigint_watcher = pyev.Signal(signal.SIGINT, self.loop, self.sigint_cb) sigint_watcher.start() self.loop.data = [sigterm_watcher, sigint_watcher] #self.loop.data.append(self.idle_watcher) # initialize storage logging.info("Init storage...") self.storage = Storage(datafile) # read in probes from config self.probes = [] index = 0 for probe_conf in probe_confs: self.check_command(probe_conf) self.check_data_type(probe_conf) self.check_dummy(probe_conf) # load filters self.load_filters(probe_conf) # load error filters self.load_error_filters(probe_conf) p = self.get_probe(index, self.storage, probe_conf, -1) p.register(self.loop) self.probes.append(p) if probe_conf.get("auto_start", False): self.start_probe(index) index = index + 1
def main(): storage = Storage(config['datafile']) for r in storage.get_records_by_probe_id('meerkat.probe.camera_photo', 3): data = str(r[4]).encode('utf-8') print r[0], r[1], r[2], r[3], data