def main(): args = get_args() logger = JSONLogger(None) name, ext = os.path.splitext(args.filename) outfile = "{name}-expanded{ext}".format(name=name, ext=ext) with open(args.filename, 'r') as infile, open(outfile, 'w') as outfile: for (msg, meta) in JSONLogIterator(infile, conventional=True): if msg.msg_type in args.ignore: continue outfile.write(logger.dump(msg)) outfile.write('\n')
def base_pos_log(source): # Hold for 2 hours, + 1 minute to allow Piksi to acquire satellite signal TIME_INTERVAL = 60 filename = time.strftime("gnss-%Y%m%d-%H%M%S.sbp.json") infile = open(filename, 'w') #filename = os.path.normpath( # os.path.join("data", filename)) # Data structure for logging logger = JSONLogger(infile) # Sends data from Piksi to logger fwd = Forwarder(source, logger) fwd.start() # Collect data during interval start = time.perf_counter() diff = 0 while diff < TIME_INTERVAL: diff = time.perf_counter() - start fwd.stop() logger.flush() logger.close() send_to_OPUS(filename)
def get_append_logger(filename): """ Get a append logger based on configuration options. Parameters ---------- filename : string File to log to. """ if not filename: return NullLogger() print "Append logging at %s." % filename return JSONLogger(filename, "a")
def get_logger(use_log=False, filename=LOG_FILENAME): """ Get a logger based on configuration options. Parameters ---------- use_log : bool Whether to log or not. filename : string File to log to. """ if not use_log: return NullLogger() print "Logging at %s." % filename return JSONLogger(filename)
def get_append_logger(filename, tags): """ Get a append logger based on configuration options. Parameters ---------- filename : string File to log to. tags : string Tags to log out """ if not filename: return NullLogger() print("Append logging at %s" % filename) infile = open(filename, 'a') return JSONLogger(infile, tags)
def get_logger(use_log=False, filename=logfilename()): """ Get a logger based on configuration options. Parameters ---------- use_log : bool Whether to log or not. filename : string File to log to. """ if not use_log: return NullLogger() if os.path.isdir(filename): filename = os.path.normpath(os.path.join(filename, logfilename())) print "Starting JSON logging at %s" % filename return JSONLogger(filename)
def get_logger(use_log=False, filename=logfilename()): """ Get a logger based on configuration options. Parameters ---------- use_log : bool Whether to log or not. filename : string File to log to. """ if not use_log: return NullLogger() dirname = os.path.dirname(filename) if dirname: mkdir_p(dirname) print("Starting JSON logging at %s" % filename) infile = open(filename, 'w') return JSONLogger(infile)
def _reader(self): with BaseDriver(self.handle) as driver: with Handler(Framer(driver.read, None, verbose=True)) as source: with JSONLogger(self.raw_sbp_log_filename) as logger: source.add_callback(self.handle_incoming, msg_type=self.listen_to_sbp_msg) source.add_callback(logger) try: while not self.wait_on_stop(1.0): # Sleep until we get killed. The callback above handles actual stuff. # This is very nice for clean shutdown. pass except (OSError, serial.SerialException): print("Piksi disconnected") raise SystemExit except Exception: traceback.print_exc()