You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
2.2 KiB

  1. # -*- coding: utf-8 -*-
  2. ##############################################################################
  3. #
  4. # Adapted by Nicolas Bessi. Copyright Camptocamp SA
  5. # Based on Florent Xicluna original code. Copyright Wingo SA
  6. #
  7. # This program is free software: you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation, either version 3 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. #
  20. ##############################################################################
  21. import locale
  22. import os
  23. import platform
  24. import subprocess
  25. from openerp import release
  26. from openerp.tools.config import config
  27. def _get_output(cmd):
  28. bindir = config['root_path']
  29. p = subprocess.Popen(cmd, shell=True, cwd=bindir, stdout=subprocess.PIPE)
  30. return p.communicate()[0].rstrip()
  31. def get_server_environment():
  32. # inspired by server/bin/service/web_services.py
  33. try:
  34. rev_id = 'git:%s' % _get_output('git rev-parse HEAD')
  35. except Exception:
  36. try:
  37. rev_id = 'bzr: %s' % _get_output('bzr revision-info')
  38. except Exception:
  39. rev_id = 'Can not retrive revison from git or bzr'
  40. os_lang = '.'.join([x for x in locale.getdefaultlocale() if x])
  41. if not os_lang:
  42. os_lang = 'NOT SET'
  43. if os.name == 'posix' and platform.system() == 'Linux':
  44. lsbinfo = _get_output('lsb_release -a')
  45. else:
  46. lsbinfo = 'not lsb compliant'
  47. return (
  48. ('platform', platform.platform()),
  49. ('os.name', os.name),
  50. ('lsb_release', lsbinfo),
  51. ('release', platform.release()),
  52. ('version', platform.version()),
  53. ('architecture', platform.architecture()[0]),
  54. ('locale', os_lang),
  55. ('python', platform.python_version()),
  56. ('openerp', release.version),
  57. ('revision', rev_id),
  58. )