Browse Source

openerp apps main moved to cli ready for new commands

bzr revid: al@openerp.com-20121127005513-vi9viu4oafbrze6y
master
Antony Lesuisse 9 years ago
parent
commit
13cdc34b65
  1. 8
      openerp-server
  2. 1
      openerp/__init__.py
  3. 35
      openerp/cli/__init__.py
  4. 12
      openerp/cli/server.py

8
openerp-server

@ -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:

1
openerp/__init__.py

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

35
openerp/cli/__init__.py

@ -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:

12
openerp/main.py → openerp/cli/server.py

@ -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:
Loading…
Cancel
Save