odoo11-master 学习笔记1

1.Odoo服务器启动

实现的动作:调用odoo.cli.main()

文件名:odoo11-master\odoo-bin

文件内容:

#!/usr/bin/env python3

# set server timezone in UTC before time module imported

__import__('os').environ['TZ'] = 'UTC'

import odoo

if __name__ == "__main__":

    odoo.cli.main()

实现的动作:指向main()

文件名:odoo11-master\cli\__init__.py

文件内容:

import logging

import sys

import os

import odoo

from .command import Command, main

from . import deploy

from . import scaffold

from . import server

from . import shell

from . import start

实现的动作:运行main()

         针对 odoo-bin的参数,运行不同的模块。o.run(args)运行server。

文件名:odoo11-master\cli\command.py

def main():

    args = sys.argv[1:]

    # The only shared option is '--addons-path=' needed to discover additional

    # commands from modules

    if len(args) > 1 and args[0].startswith('--addons-path=') and not args[1].startswith("-"):

        # parse only the addons-path, do not setup the logger...

        odoo.tools.config._parse_config([args[0]])

        args = args[1:]

    # Default legacy command

    command = "server"

    # TODO: find a way to properly discover addons subcommands without importing the world

    # Subcommand discovery

    if len(args) and not args[0].startswith("-"):

        logging.disable(logging.CRITICAL)

        for module in get_modules():

            if isdir(joinpath(get_module_path(module), 'cli')):

                __import__('odoo.addons.' + module)

        logging.disable(logging.NOTSET)

        command = args[0]

        args = args[1:]

    if command in commands:

        o = commands[command]()

        o.run(args)

    else:

        sys.exit('Unknow command %r' % (command,))

commands{}内容如下:

{'help':, 'deploy':, 'scaffold':, 'server':, 'shell':, 'start':}

class 'odoo.cli.command.Help'

class 'odoo.cli.deploy.Deploy'

class 'odoo.cli.scaffold.Scaffold'

class 'odoo.cli.server.Server'

class 'odoo.cli.shell.Shell'

class 'odoo.cli.start.Start'

你可能感兴趣的:(odoo11-master 学习笔记1)