if cwconfig['base-url'].startswith('https') else 'http') repo = app.application.registry['cubicweb.repository'] try: waitress.serve(app, host=host, port=port, url_scheme=url_scheme, clear_untrusted_proxy_headers=True) finally: repo.shutdown() if self._needreload: return 3 return 0 CWCTL.register(PyramidStartHandler) def _turn_sigterm_into_systemexit(): """Attempts to turn a SIGTERM exception into a SystemExit exception.""" try: import signal except ImportError: return def handle_term(signo, frame): raise SystemExit signal.signal(signal.SIGTERM, handle_term)
etype = self['show-etype'] visitor = s2d.OneHopESchemaVisitor(schema[etype], skiptypes=skiptypes) propshdlr = s2d.SchemaDotPropsHandler(visitor) backend = DotBackend('schema', 'BT', ratio='compress', size=None, renderer='dot', additionnal_param={ 'overlap': 'false', 'splines': 'true', 'sep': '0.2' }) generator = s2d.GraphGenerator(backend) generator.generate(visitor, propshdlr, out) if viewer: p = Popen((viewer, out)) p.wait() for cmdcls in ( UpdateCubicWebCatalogCommand, UpdateCubeCatalogCommand, NewCubeCommand, ExamineLogCommand, GenerateSchema, ): CWCTL.register(cmdcls)
CreateInstanceDBCommand, InitInstanceCommand, GrantUserOnInstanceCommand, ResetAdminPasswordCommand, DBDumpCommand, DBRestoreCommand, DBCopyCommand, DBIndexSanityCheckCommand, AddSourceCommand, CheckRepositoryCommand, RebuildFTICommand, SynchronizeSourceCommand, SchemaDiffCommand, RepositorySchedulerCommand, ): CWCTL.register(cmdclass) # extend configure command to set options in sources config file ############### db_options = (('db', { 'short': 'd', 'type': 'named', 'metavar': '[section1.]key1:value1,[section2.]key2:value2', 'default': None, 'help': '''set <key> in <section> to <value> in "source" configuration file. If <section> is not specified, it defaults to "system".
class WebUpgradeHandler(CommandHandler, GenStaticDataDirMixIn): cmdname = 'upgrade' def postupgrade(self, repo): config = self.config if not config['generate-staticdir']: return self.generate_static_dir(config, ask_clean=True, repo=repo) class GenStaticDataDir(Command, GenStaticDataDirMixIn): """Create a directory merging all data directory content from cubes and CW. """ name = 'gen-static-datadir' arguments = '<instance> [dirpath]' min_args = 1 max_args = 2 options = () def run(self, args): appid = args.pop(0) config = cwcfg.config_for(appid) dest = None if args: dest = args[0] self.generate_static_dir(config, dest) CWCTL.register(GenStaticDataDir)
arguments = '<instance id> <fs file or directory>...' options = ( ("map-folders", {'short': 'F', 'action' : 'store_true', 'default': False, 'help': 'map file-system directories as Folder entities (requires the `folder` cube).', }), ("filed-under", {'short': 'u', 'type' : 'int', 'help': 'put imported file into the folder entity of the given eid.', }), ) def run(self, args): """run the command with its specific arguments""" from cubicweb.server.serverconfig import ServerConfiguration from cubicweb.server.serverctl import repo_cnx from cubes.file.fsimport import fsimport appid = args.pop(0) config = ServerConfiguration.config_for(appid) repo, cnx = repo_cnx(config) repo.hm.call_hooks('server_maintenance', repo=repo) session = repo._get_session(cnx.sessionid, setcnxset=True) fsimport(session, args, parenteid=self.config.filed_under, mapfolders=self.config.map_folders, bfss='data' in repo.system_source._storages.get('File', ()), ) session.commit() CWCTL.register(FSImportCommand)