openerp apps main moved to cli ready for new commands

bzr revid: al@openerp.com-20121127005513-vi9viu4oafbrze6y
This commit is contained in:
Antony Lesuisse 2012-11-27 01:55:13 +01:00
parent 1ff6a0c20d
commit 13cdc34b65
4 changed files with 50 additions and 6 deletions

View File

@ -1,3 +1,7 @@
#!/usr/bin/env python
from openerp.main import main
main()
import openerp
if __name__ == "__main__":
openerp.cli.main()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

View File

@ -26,6 +26,7 @@
SUPERUSER_ID = 1
import addons
import cli
import conf
import loglevels
import modules

35
openerp/cli/__init__.py Normal file
View File

@ -0,0 +1,35 @@
import logging
import sys
import openerp
_logger = logging.getLogger(__name__)
commands = {}
class CommandType(type):
def __init__(cls, name, bases, attrs):
super(CommandType, cls).__init__(name, bases, attrs)
name = cls.__name__.lower()
commands[name] = cls
class Command(object):
__metaclass__ = CommandType
def run():
pass
import server
def main():
args = sys.argv[1:]
command = "server"
if len(args) and not args[0].startswith("-"):
command = args[0]
args = args[1:]
if command in commands:
o = commands[command]()
o.run(args)
# vim:et:ts=4:sw=4:

View File

@ -39,6 +39,9 @@ import traceback
import time
import openerp
from . import Command
__author__ = openerp.release.author
__version__ = openerp.release.version
@ -218,11 +221,11 @@ def configure_babel_localedata_path():
import babel
babel.localedata._dirname = os.path.join(os.path.dirname(sys.executable), 'localedata')
def main():
def main(args):
os.environ["TZ"] = "UTC"
check_root_user()
openerp.tools.config.parse_config(sys.argv[1:])
openerp.tools.config.parse_config(args)
check_postgres_user()
openerp.netsvc.init_logger()
@ -265,7 +268,8 @@ def main():
_logger.info('OpenERP server is running, waiting for connections...')
quit_on_signals()
if __name__ == "__main__":
main()
class Server(Command):
def run(self, args):
main(args)
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: