# HG changeset patch # User Sylvain Thénault # Date 1277127178 -7200 # Node ID 51cc4b61f9ae5320bac03974abcf5e4ab9e4d53a # Parent e77cea9721e7089c83d0ca40b2407676ce525b0c [repo] fix 'c-c start --loglevel LEVEL' for repository only configuration. Closes #1058269. diff -r e77cea9721e7 -r 51cc4b61f9ae cwctl.py --- a/cwctl.py Mon Jun 21 13:23:11 2010 +0200 +++ b/cwctl.py Mon Jun 21 15:32:58 2010 +0200 @@ -17,9 +17,8 @@ # with CubicWeb. If not, see . """the cubicweb-ctl tool, based on logilab.common.clcommands to provide a pluggable commands system. - +""" -""" __docformat__ = "restructuredtext en" # *ctl module should limit the number of import to be imported as quickly as @@ -477,24 +476,25 @@ def start_instance(self, appid): """start the instance's server""" - force = self['force'] - loglevel = self['loglevel'] config = cwcfg.config_for(appid, debugmode=self['debug']) - if loglevel is not None: - loglevel = 'LOG_%s' % loglevel.upper() - config.global_set_option('log-threshold', loglevel) - config.init_log(loglevel, force=True) + init_cmdline_log_threshold(config, self['loglevel']) if self['profile']: config.global_set_option('profile', self.config.profile) helper = self.config_helper(config, cmdname='start') pidf = config['pid-file'] - if exists(pidf) and not force: + if exists(pidf) and not self['force']: msg = "%s seems to be running. Remove %s by hand if necessary or use \ the --force option." raise ExecutionError(msg % (appid, pidf)) helper.start_server(config) +def init_cmdline_log_threshold(config, loglevel): + if loglevel is not None: + config.global_set_option('log-threshold', loglevel.upper()) + config.init_log(config['log-threshold'], force=True) + + class StopInstanceCommand(InstanceCommand): """Stop the given instances. diff -r e77cea9721e7 -r 51cc4b61f9ae devtools/testlib.py --- a/devtools/testlib.py Mon Jun 21 13:23:11 2010 +0200 +++ b/devtools/testlib.py Mon Jun 21 15:32:58 2010 +0200 @@ -15,9 +15,8 @@ # # You should have received a copy of the GNU Lesser General Public License along # with CubicWeb. If not, see . -"""this module contains base classes and utilities for cubicweb tests +"""this module contains base classes and utilities for cubicweb tests""" -""" from __future__ import with_statement __docformat__ = "restructuredtext en" diff -r e77cea9721e7 -r 51cc4b61f9ae etwist/server.py --- a/etwist/server.py Mon Jun 21 13:23:11 2010 +0200 +++ b/etwist/server.py Mon Jun 21 15:32:58 2010 +0200 @@ -15,9 +15,8 @@ # # You should have received a copy of the GNU Lesser General Public License along # with CubicWeb. If not, see . -"""twisted server for CubicWeb web instances +"""twisted server for CubicWeb web instances""" -""" __docformat__ = "restructuredtext en" import sys diff -r e77cea9721e7 -r 51cc4b61f9ae etwist/twctl.py --- a/etwist/twctl.py Mon Jun 21 13:23:11 2010 +0200 +++ b/etwist/twctl.py Mon Jun 21 15:32:58 2010 +0200 @@ -15,9 +15,7 @@ # # You should have received a copy of the GNU Lesser General Public License along # with CubicWeb. If not, see . -"""cubicweb-clt handlers for twisted - -""" +"""cubicweb-clt handlers for twisted""" from cubicweb.toolsutils import CommandHandler from cubicweb.web.webctl import WebCreateHandler diff -r e77cea9721e7 -r 51cc4b61f9ae server/server.py --- a/server/server.py Mon Jun 21 13:23:11 2010 +0200 +++ b/server/server.py Mon Jun 21 15:32:58 2010 +0200 @@ -74,10 +74,10 @@ class RepositoryServer(object): - def __init__(self, config, debug=False): + def __init__(self, config): """make the repository available as a PyRO object""" self.config = config - self.repo = Repository(config, debug=debug) + self.repo = Repository(config) self.ns = None self.quiting = None # event queue diff -r e77cea9721e7 -r 51cc4b61f9ae server/serverctl.py --- a/server/serverctl.py Mon Jun 21 13:23:11 2010 +0200 +++ b/server/serverctl.py Mon Jun 21 15:32:58 2010 +0200 @@ -15,9 +15,10 @@ # # You should have received a copy of the GNU Lesser General Public License along # with CubicWeb. If not, see . -"""cubicweb-ctl commands and command handlers specific to the server.serverconfig +"""cubicweb-ctl commands and command handlers specific to the +server.serverconfig +""" -""" __docformat__ = 'restructuredtext en' # *ctl module should limit the number of import to be imported as quickly as @@ -251,11 +252,12 @@ cmdname = 'start' cfgname = 'repository' - def start_server(self, ctlconf): + def start_server(self, config): command = ['cubicweb-ctl start-repository '] - if ctlconf.debugmode: + if config.debugmode: command.append('--debug') - command.append(self.config.appid) + command.append('--loglevel %s' % config['log-threshold']) + command.append(config.appid) os.system(' '.join(command)) @@ -264,8 +266,7 @@ cfgname = 'repository' def poststop(self): - """if pyro is enabled, ensure the repository is correctly - unregistered + """if pyro is enabled, ensure the repository is correctly unregistered """ if self.config.pyro_enabled(): from cubicweb.server.repository import pyro_unregister @@ -527,22 +528,28 @@ ('debug', {'short': 'D', 'action' : 'store_true', 'help': 'start server in debug mode.'}), + ('loglevel', + {'short': 'l', 'type' : 'choice', 'metavar': '', + 'default': None, 'choices': ('debug', 'info', 'warning', 'error'), + 'help': 'debug if -D is set, error otherwise', + }), ) def run(self, args): from logilab.common.daemon import daemonize + from cubicweb.cwctl import init_cmdline_log_threshold from cubicweb.server.server import RepositoryServer appid = pop_arg(args, msg='No instance specified !') - config = ServerConfiguration.config_for(appid) - if sys.platform == 'win32': - if not self.config.debug: - from logging import getLogger - logger = getLogger('cubicweb.ctl') - logger.info('Forcing debug mode on win32 platform') - self.config.debug = True - debug = self.config.debug + debug = self['debug'] + if sys.platform == 'win32' and not debug: + from logging import getLogger + logger = getLogger('cubicweb.ctl') + logger.info('Forcing debug mode on win32 platform') + debug = True + config = ServerConfiguration.config_for(appid, debugmode=debug) + init_cmdline_log_threshold(config, self['loglevel']) # create the server - server = RepositoryServer(config, debug) + server = RepositoryServer(config) # ensure the directory where the pid-file should be set exists (for # instance /var/run/cubicweb may be deleted on computer restart) pidfile = config['pid-file']