def setup_class(self): self.config = { "sqldb" : os.path.join(DIRPATH, "basic.db"), "plist" : os.path.join(DIRPATH, "PLIST-basic"), "prefix_filenames" : "", "tlpdb" : os.path.join(DIRPATH, "basic.tlpdb"), "arch" : None, } self.sess = tlpdbparser.initdb(self.config, return_sess=True)
def init_orm(cfg, force_create=False): """Set up ORM. SQL database is created and populated if non-existent or out of date. """ # Check existence and mtime *before* opening connection. create, update = check_sqldb(cfg) if force_create: create = True engine = create_engine('sqlite:///%s' % (cfg.sqldb,)) sess = sessionmaker(bind=engine)() if create: print("SQL database non-existent. Initialising...") elif update: print("SQL database out of date. Re-initialising...") if create or update: from tlpdbparser import initdb initdb(cfg, sess, engine) return sess
if args.sqldb is not None: config["sqldb"] = args.sqldb if args.prefix_filenames is not None: config["prefix_filenames"] = args.prefix_filenames if args.output_plist is not None: config["plist"] = args.output_plist if args.tlpdb is not None: config["tlpdb"] = args.tlpdb if args.arch is not None: config["arch"] = args.arch if not args.version: print_version() print("\nRunning with configuration:") for k in config.iterkeys(): print(" %s: %s" % (k.ljust(25), config[k])) print("") # primary tasks if args.subset: import subset subset.compute_subset(config, args.include, args.exclude) elif args.initdb: import tlpdbparser tlpdbparser.initdb(config) elif args.version: print_version() else: assert False # should not happen