forked from OCA/server-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
system_info.py
66 lines (59 loc) · 2.29 KB
/
system_info.py
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# -*- coding: utf-8 -*-
##############################################################################
#
# Adapted by Nicolas Bessi. Copyright Camptocamp SA
# Based on Florent Xicluna original code. Copyright Wingo SA
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
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 retrive 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),
)