首页 > 代码库 > 发掘odoo.cli.server.Server的秘密,OpenERP的第三根线头儿

发掘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 CSV fields in the module is 128KiB, which is not
10     # quite sufficient to import images to store in attachment. 500MiB is a
11     # bit overkill, but better safe than sorry I guess
12     csv.field_size_limit(500 * 1024 * 1024)
13 
14     preload = []
15     if config[db_name]:
16         preload = config[db_name].split(,)
17         for db_name in preload:
18             try:
19                 odoo.service.db._create_empty_database(db_name)
20             except odoo.service.db.DatabaseExists:
21                 pass
22 
23     if config["translate_out"]:
24         export_translation()
25         sys.exit(0)
26 
27     if config["translate_in"]:
28         import_translation()
29         sys.exit(0)
30 
31     # This needs to be done now to ensure the use of the multiprocessing
32     # signaling mecanism for registries loaded with -d
33     if config[workers]:
34         odoo.multi_process = True
35 
36     stop = config["stop_after_init"]
37 
38     setup_pid_file()
39     rc = odoo.service.server.start(preload=preload, stop=stop)
40     sys.exit(rc)

其中line 2 check_root_user仅针对posix系统 暂时忽略

1 def check_root_user():
2     """Warn if the process‘s user is ‘root‘ (on POSIX system)."""
3     if os.name == posix:
4         import pwd
5         if pwd.getpwuid(os.getuid())[0] == root:
6             sys.stderr.write("Running as user ‘root‘ is a security risk.\n")

 

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