forked from OCA/server-env
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsystem_info.py
More file actions
50 lines (43 loc) · 1.5 KB
/
system_info.py
File metadata and controls
50 lines (43 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# Based on Florent Xicluna original code. Copyright Wingo SA
# Adapted by Nicolas Bessi. Copyright Camptocamp SA
# License LGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html)
import locale
import os
import platform
import subprocess
from odoo import release
from odoo.tools.config import config
def _get_output(cmd):
bindir = config["root_path"]
p = subprocess.Popen(
cmd, shell=True, cwd=bindir, stdout=subprocess.PIPE, stderr=subprocess.STDOUT
)
return p.communicate()[0].rstrip()
def get_server_environment():
# inspired by server/bin/service/web_services.py
try:
rev_id = "git:%s" % _get_output("git rev-parse HEAD")
except Exception:
try:
rev_id = "bzr: %s" % _get_output("bzr revision-info")
except Exception:
rev_id = "Can not retrieve revison from git or bzr"
os_lang = ".".join([x for x in locale.getdefaultlocale() if x])
if not os_lang:
os_lang = "NOT SET"
if os.name == "posix" and platform.system() == "Linux":
lsbinfo = _get_output("lsb_release -a")
else:
lsbinfo = "not lsb compliant"
return (
("platform", platform.platform()),
("os.name", os.name),
("lsb_release", lsbinfo),
("release", platform.release()),
("version", platform.version()),
("architecture", platform.architecture()[0]),
("locale", os_lang),
("python", platform.python_version()),
("odoo", release.version),
("revision", rev_id),
)