odoo.cli.main()做了什么?

先把代码贴过来

 1 def main():
 2     args = sys.argv[1:]
 3
 4     # The only shared option is ‘--addons-path=‘ needed to discover additional
 5     # commands from modules
 6     if len(args) > 1 and args[0].startswith(‘--addons-path=‘) and not args[1].startswith("-"): 如果有插件路径参数,则解析之
 7         # parse only the addons-path, do not setup the logger...
 8         odoo.tools.config._parse_config([args[0]])
 9         args = args[1:]
10
11     # Default legacy command  这是要启动server吗?
12     command = "server"
13
14     # TODO: find a way to properly discover addons subcommands without importing the world 需要一种方法确定必须导入的模块,而不是所有的模块
15     # Subcommand discovery
16     if len(args) and not args[0].startswith("-"):
17         logging.disable(logging.CRITICAL)
18         for module in get_modules():
19             if isdir(joinpath(get_module_path(module), ‘cli‘)):
20                 __import__(‘odoo.addons.‘ + module)
21         logging.disable(logging.NOTSET)
22         command = args[0]
23         args = args[1:]
24
25     if command in commands:
26         o = commands[command]()
27         o.run(args)
28     else:
29         sys.exit(‘Unknow command %r‘ % (command,))

at last o.run(args)

其中,command=‘server’

在python运行时探测得知

commands的内容是

{‘shell‘: <class ‘odoo.cli.shell.Shell‘>, ‘help‘: <class ‘odoo.cli.command.Help‘>, ‘deploy‘: <class ‘odoo.cli.deploy.Deploy‘>, ‘scaffold‘: <class ‘odoo.cli.scaffold.Scaffold‘>, ‘server‘: <class ‘odoo.cli.server.Server‘>, ‘star
t‘: <class ‘odoo.cli.start.Start‘>}

也就是说server 代表的是<class ‘odoo.cli.server.Server‘>

by the way

args is ”-w odoo -r odoo --addons-path=addons,../mymodules --db-filter=mydb$“

let‘s go!<class ‘odoo.cli.server.Server‘>

时间: 2024-08-03 16:16:33

odoo.cli.main()做了什么?的相关文章

odoo.cli.main()指的是哪里?OpenERP的第二根线头儿

接上回,odoo-bin中调用了odoo.cli.main(),去哪儿找? cli目录容易找 跟随__init__.py的脚步 1 import logging 2 import sys 3 import os 4 5 import odoo 6 7 from command import Command, main 8 9 import deploy 10 import scaffold 11 import server 12 import shell 13 import start see

发掘odoo.cli.server.Server的秘密,OpenERP的第三根线头儿

command.py调用了server command 在server.py中,主函数main使用了外层模块传递来的args 1 def main(args): 2 check_root_user() 3 odoo.tools.config.parse_config(args) 4 check_postgres_user() 5 report_configuration() 6 7 config = odoo.tools.config 8 9 # the default limit for CS

ODOO从哪里开始??OpenERP的线头儿

Windows下ODOO源码启动: python odoo-bin -w odoo -r odoo --addons-path=addons,../mymodules --db-filter=mydb$ 其中的odoo-bin 其实也是一个python文件,内容很短 1 #!/usr/bin/env python 2 __import__('pkg_resources').declare_namespace('odoo.addons') 3 import odoo 4 5 if __name__

05.odoo12开源框架学习

博客为日常工作学习积累总结: 1.odoo12学习 参考博客:https://alanhou.org/centos-odoo-12/ CentOS 7快速安装配置 Odoo 12 添加新用户必做,不然文件权限odoo用户五权限 useradd -m -U -r -d /opt/odoo -s /bin/bash odoo设置密码:    passwd odoo 不设置执行后述操作时会报出xxx is not in the sudoers file. This incident will be r

【Simple Java】面试问题-使用Java线程做数学运算

这是一个展示如何使用join()方法的例子. 问题: 使用Java多线程计算表达式1*2/(1+2)的值. 解决方案: 使用一个线程做加法运算,另一个线程做乘法运算,还有一个主线程main做除法运算.由于线程之间不需要通讯,所以我们只需要考虑线程的执行顺序. 在main线程中,我们让加法运算线程和乘法运算线程join到主线程,join()方法的作用是使main方法等待,直到调用join的线程执行完毕.在这个例子中,我们希望加法运算线程和乘法运算线程先结束,然后在计算除法运算. package s

golang开发:类库篇(三)命令行工具cli的使用

为什么要使用命令行 觉得这个问题不应该列出来,又觉得如果初次进行WEB开发的话,可能会觉得所有的东西都可以使用API去做,会觉得命令行没有必要. 其实,一个生产的项目命令行是绕不过去的.比如运营需要导出报表.统计下付费用户.服务不稳定修改下订单状态等等,再者,命令行的工具基本都是内部使用,调试日志可以随意点,退一万步来说,即使有问题了,还可以再次修改.不像API是是随机性的,有些业务发生错误和异常是随机的.不可逆的. 怎么使用cli 这个主要看下使用案例就一目了然了. 首先下载类库包 go ge

星辉信息科技Odoo开发教程6-配置安全权限控制02

安全记录规则 在对模型赋予访问权限时,默认用户可以访问到他的所有记录.但有时我们要限制每个用户所能访问的特定记录.通过记录规则可以实现这一点,通过定义 domain 过滤器来对读和写操作进行控制.比如我们这里的 to-do 应用,任务项应为用户私有,我们不希望其他用户看到自己的记录.需要添加记录规则来过滤出创建者自己的记录:? 框架会自动添加 create_uid 字段,并存储创建记录的用户,通过该字段可以确定每条记录的创建者? 在 user 变量中可获取到当前用户, user 变量读取上下文中

解决window7 x64位Anaconda启动报错:AttributeError: &#39;_NamespacePath&#39; object has no attribute &#39;sort&#39;

最近论文需要用到python做数据分析,python语法简单,但是Windows下安装第三方包恶心的要命,statsmodels用pip死活安装不上,网上查了说包相互依赖windows下的pip不能下载全,还有好几个其他的统计包也是如此,整晕了算. 看网上有些python大牛推荐Anaconda,可以解决包的问题,于是卸载本地的python,从官网上下了个Anconda玩玩,结果遇到新问题. 问题如下: An unexpected error has occurred. Please consi

[Erlang 0109] From Elixir to Erlang Code

Elixir代码最终编译成为erlang代码,这个过程是怎样的?本文通过一个小测试做下探索. 编译一旦完成,你就看到了真相 Elixir代码组织方式一方面和Erlang一样才用非常扁平的代码模块结构,另一方面Elixir同时支持嵌套.Elixir比较方便的一点是可以在Elixir Shell中完成对模块的定义.看下面的方式: iex> defmodule Math do ...> def sum(a, b) do ...> a + b ...> end ...> end ie