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.

62 lines
2.1 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 = _get_output('bzr revision-info')
  35. except Exception, e:
  36. rev_id = 'Exception: %s' % (e,)
  37. os_lang = '.'.join([x for x in locale.getdefaultlocale() if x])
  38. if not os_lang:
  39. os_lang = 'NOT SET'
  40. if os.name == 'posix' and platform.system() == 'Linux':
  41. lsbinfo = _get_output('lsb_release -a')
  42. else:
  43. lsbinfo = 'not lsb compliant'
  44. return (
  45. ('platform', platform.platform()),
  46. ('os.name', os.name),
  47. ('lsb_release', lsbinfo),
  48. ('release', platform.release()),
  49. ('version', platform.version()),
  50. ('architecture', platform.architecture()[0]),
  51. ('locale', os_lang),
  52. ('python', platform.python_version()),
  53. ('openerp', release.version),
  54. ('revision', rev_id),
  55. )