def main(argv): parser = argparse.ArgumentParser(description='Generate types') parser.add_argument('dest', nargs='?', default='DefaultGeneratedTestTypes.hpp') parser.add_argument('-t', '--testTypes', action='store_true') parser.add_argument('-c', '--testTypes2', action='store_true') parser.add_argument('-d', '--testTypes3', action='store_true') parser.add_argument('-v', '--verbose', action='store_true') args = parser.parse_args() ret = 0 try: if args.testTypes: generate_some_types(args.dest) elif args.testTypes2: codebase = Codebase.FromRootlevelPath("object_database") generate_from_codebase(codebase, args.dest, ["object_database.messages.ClientToServer"], verbose=args.verbose) getOrSetTypeResolver(cb_resolver(codebase)) elif args.testTypes3: codebase = Codebase.FromRootlevelPath("typed_python") getOrSetTypeResolver(cb_resolver(codebase)) testTypes = [ "typed_python.direct_types.generate_types.A", "typed_python.direct_types.generate_types.Overlap", "typed_python.direct_types.generate_types.NamedTupleTwoStrings", "typed_python.direct_types.generate_types.NamedTupleBoolIntStr", "typed_python.direct_types.generate_types.NamedTupleIntFloatDesc", "typed_python.direct_types.generate_types.NamedTupleBoolListOfInt", "typed_python.direct_types.generate_types.NamedTupleAttrAndValues", "typed_python.direct_types.generate_types.AnonTest", "typed_python.direct_types.generate_types.Bexpress" ] generate_from_codebase(codebase, args.dest, testTypes, verbose=args.verbose) ret = cpp_tests() except Exception: print("FAILED:\n", traceback.format_exc()) return 1 return ret
def configurableSetUp( self, hostname='localhost', login_plugin_factory=None, # default: LoginIpPlugin, login_config=None, auth_plugins=(None), module=None, db_init_fun=None): self.base_url = "http://{host}:{port}".format(host=hostname, port=WEB_SERVER_PORT) login_plugin_factory = login_plugin_factory or LoginIpPlugin self.token = genToken() log_level = self._logger.getEffectiveLevel() loglevel_name = logging.getLevelName(log_level) self.server, self.cleanupFn = autoconfigure_and_start_service_manager( port=DATABASE_SERVER_PORT, auth_token=self.token, loglevel_name=loglevel_name, own_hostname=hostname, db_hostname=hostname) try: self.database = connect(hostname, DATABASE_SERVER_PORT, self.token, retry=True) self.database.subscribeToSchema(core_schema, service_schema, active_webservice_schema) if db_init_fun is not None: db_init_fun(self.database) codebase = None if module is not None and not module.__name__.startswith( "object_database."): self.database.serializeFromModule(module) root_path = TypedPythonCodebase.rootlevelPathFromModule(module) tpcodebase = TypedPythonCodebase.FromRootlevelPath(root_path) with self.database.transaction(): codebase = service_schema.Codebase.createFromCodebase( tpcodebase) with self.database.transaction(): service = ServiceManager.createOrUpdateService( ActiveWebService, "ActiveWebService", target_count=0) ActiveWebService.configureFromCommandline(self.database, service, [ '--port', str(WEB_SERVER_PORT), '--host', hostname, '--log-level', loglevel_name, ]) if login_config is None: login_config = self.login_config ActiveWebService.setLoginPlugin(self.database, service, login_plugin_factory, auth_plugins, codebase=codebase, config=login_config) with self.database.transaction(): ServiceManager.startService("ActiveWebService", 1) self.waitUntilUp() except Exception: self.cleanupFn(error=True) raise
def createFromRootlevelPath(rootPath): return Codebase.createFromCodebase( TypedPythonCodebase.FromRootlevelPath(rootPath))