def complete(self): def _assert(condition, msg): if not condition: print_error("In [General] session, " + msg) sys.exit(1) def exists(key): return key in self.config if not exists("Profile"): name = self.filename.split(".")[0] _assert( id_regex.match(name), "'Profile' is not specified while the config filename could not be a legal profile name" ) self.config["Profile"] = name print_warn( "'Profile' is not specified and defaults to '{}'".format(name)) _assert(exists("Profile"), "'Profile' must be specified!") if not exists("LogFile"): self.config["LogFile"] = default_log if not exists("LogLevel"): self.config["LogLevel"] = default_log_level if not exists("DefaultTimeout"): self.config["DefaultTimeout"] = default_timeout _assert(not os.path.isdir(self.config["LogFile"]), "'{}' cannot be a directory!".format(self.config["LogFile"])) try: filename = self.config["LogFile"] fp = open(filename, "a", 0) except IOError: _assert( False, "cannot open '{}' to write!".format(self.config["LogFile"])) self.config["LogFile"] = log.LogFile(fp, self.config["LogLevel"], filename)
def collectDatas(solver_file_name, net_file, log_file_name, batch_sizes): if not os.path.isfile(solver_file_name): raise Exception("Solver file does not exist") log_file = log.LogFile(log_file_name) if type(batch_sizes) == list: for batch_size in batch_sizes: utils.setBatchSize(net_file, batch_size) # run in GPU print "load GPU data" log_raw = utils.collectData(solver_file_name, gpu=True) log_entries = utils.makeLog(log_raw, machine=MACHINE_NAME, mode='GPU', batch_size=batch_size) log_file.writeLogs(log_entries) # run in CPU log_raw = utils.collectData(solver_file_name, gpu=False) log_entries = utils.makeLog(log_raw, machine=MACHINE_NAME, mode='CPU', batch_size=batch_size) log_file.writeLogs(log_entries)
sbc.flush() logging.info(enum) if __name__ == '__main__': sys.argv.append('--estamap_version=DEV') with log.LogConsole(): logging.info('parsing args') args = docopt(__doc__) logging.info('variables') estamap_version = args['--estamap_version'] log_file = args['--log_file'] log_path = args['--log_path'] with log.LogFile(log_file, log_path): logging.info('start') try: ########### calc_address_gnaf_roadinfra(estamap_version) ########### except Exception as err: logging.exception('error occured running function.') raise logging.info('finished')
print "------------------------------------------------" act_led = LED(19) act_led.on() sleep(10) resolution_ms = 1000 run_forever = False run_time = 10 met_module = met.MetSensorModule(18, 24, 4.39) print "MET Sensors Connected" ss = ucass.UCASS(25) print("UCASS Connected") mavcon = pix.MavlinkConnection('/dev/ttyS0', 57600) print("Mavlink Connected") mavcon.get_date_time() name_string = "_".join(["AeroSAM-log", mavcon.start_date.replace('-', ''), mavcon.start_time.replace(':', '')]) sd_log = log.LogFile(name_string, "/home/pi") # usb_log = log.LogFile(name_string, "/media/usb/uav_data") print("".join(["Log File: ", name_string])) ss.read_info_string() ss.read_config_vars() print("Creating SD Log File") sd_log.make_headers(mavcon.start_date, mavcon.start_time, str(int(mavcon.epoch_time/1000)), ss.info_string, ss.bbs, ss.gsc, ss.id) print("Creating USB Log File") # usb_log.make_headers(mavcon.start_date, mavcon.start_time, str(int(mavcon.epoch_time/1000)), ss.info_string, # ss.bbs, ss.gsc, ss.id) t0 = mavcon.boot_time print("Starting Main Loop") loop_num = 0 while True: act_led.off()
import met import ucass import log import pix from time import sleep from gpiozero import LED if __name__ == '__main__': act_led = LED(19) act_led.on() name_string = "AeroSAM-log::" sd_log = log.LogFile(name_string, "/home/pi") usb_log = log.LogFile(name_string, "/media/usb/uav_data") print("".join(["Log File: ", name_string])) usb_log.make_headers("a", "h", "h", "h", "h", "j", "j")
def startup_init(): """ Startup initialization """ global logf logf=log.LogFile() logf.open(str(__name__),__name__,str(__name__)) sys.path.append(cfg.modules)