PageRenderTime 45ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

/wxgeometrie/pylib/infos.py

https://github.com/Grahack/geophar
Python | 156 lines | 91 code | 22 blank | 43 comment | 25 complexity | 6474f8aaa3ce754b3f99d2515f0b75a3 MD5 | raw file
  1. # -*- coding: iso-8859-1 -*-
  2. from __future__ import division # 1/2 == .5 (par defaut, 1/2 == 0)
  3. ##--------------------------------------#######
  4. # infos pylib #
  5. ##--------------------------------------#######
  6. # WxGeometrie
  7. # Dynamic geometry, graph plotter, and more for french mathematic teachers.
  8. # Copyright (C) 2005-2010 Nicolas Pourcelot
  9. #
  10. # This program is free software; you can redistribute it and/or modify
  11. # it under the terms of the GNU General Public License as published by
  12. # the Free Software Foundation; either version 2 of the License, or
  13. # (at your option) any later version.
  14. #
  15. # This program is distributed in the hope that it will be useful,
  16. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. # GNU General Public License for more details.
  19. #
  20. # You should have received a copy of the GNU General Public License
  21. # along with this program; if not, write to the Free Software
  22. # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  23. # version unicode
  24. import sys
  25. import wx
  26. import matplotlib
  27. import os
  28. import platform
  29. import locale
  30. class dossier(object):
  31. def __init__(self, titre):
  32. self.__titre__ = titre
  33. def contenu(self):
  34. l = []
  35. l.append("+ " + self.__titre__ + ":")
  36. if hasattr(self, "version"):
  37. l.append(" Version: " + self.version)
  38. for key in self.__dict__:
  39. if key not in ("__titre__", "version"):
  40. l.append(" %s: %s" %(key.capitalize(), getattr(self, key)))
  41. return "\n".join(l) + "\n\n"
  42. def informations_configuration():
  43. dossier_os = dossier("Systeme")
  44. dossier_os.repertoire = os.getcwd()
  45. dossier_os.processeur = os.environ.get("PROCESSOR_IDENTIFIER", "?")
  46. dossier_os.version = platform.platform().replace("-", " ")
  47. if dossier_os.version.startswith("Windows"):
  48. dossier_os.distribution = "%s.%s build %s (%s) - %s" %sys.getwindowsversion()
  49. elif dossier_os.version.startswith("Linux"):
  50. try:
  51. f = open("/etc/lsb-release")
  52. s = f.read()
  53. f.close()
  54. dossier_os.distribution = " ".join(elt.split("=")[1] for elt in s.split("\n") if "=" in elt)
  55. except IOError:
  56. dossier_os.distribution = "?"
  57. except Exception:
  58. dossier_os.distribution = "#ERREUR#"
  59. # os.version = sys.platform
  60. # try:
  61. # __major__, __minor__, __build__, platform, __text__ = sys.getwindowsversion()
  62. # if platform is 0:
  63. # platform = "win32s"
  64. # elif platform is 1:
  65. # platform = "Windows 9x/ME"
  66. # elif platform is 2:
  67. # platform = "Windows NT/2000/XP"
  68. # else:
  69. # platform = "Unknown"
  70. # os.version += " %s version %s.%s %s build %s" %(platform, __major__, __minor__, __text__, __build__)
  71. # except AttributeError:
  72. # pass
  73. dossier_local = dossier("Localisation")
  74. dossier_local.langue = locale.getdefaultlocale()[0]
  75. dossier_local.encodage = locale.getpreferredencoding()
  76. dossier_python = dossier("Python")
  77. dossier_python.encodage = sys.getdefaultencoding() + " / Noms de fichiers: " + sys.getfilesystemencoding()
  78. dossier_python.version = sys.version
  79. dossier_python.executable = sys.executable
  80. # Pas tres utile :
  81. # dossier_python.api = sys.api_version
  82. # dossier_python.recursions = sys.getrecursionlimit()
  83. dossier_wxpython = dossier("WxPython")
  84. dossier_wxpython.portage = " ".join(wx.PlatformInfo[1:])
  85. dossier_wxpython.version = wx.VERSION_STRING
  86. # Le code suivant provoque un Memory Leak de WxPython :
  87. # __p__ = wx.PlatformInformation()
  88. # dossier_wxpython.architecture = __p__.GetArchName() + " " + __p__.GetEndiannessName()
  89. # dossier_wxpython.os = "%s %s.%s" %(__p__.GetOperatingSystemFamilyName(), __p__.GetOSMajorVersion(), __p__.GetOSMinorVersion())
  90. dossier_matplotlib = dossier("Matplolib")
  91. dossier_matplotlib.version = matplotlib.__version__
  92. dossier_matplotlib.tex = matplotlib.rcParams["text.usetex"]
  93. if hasattr(matplotlib, "numerix"): # matplotlib <= 0.92
  94. dossier_matplotlib.numerix = matplotlib.rcParams["numerix"]
  95. dossier_matplotlib.numerix += " (" + matplotlib.numerix.version + ")"
  96. else: # matplotlib 0.98+
  97. dossier_matplotlib.numerix = "numpy"
  98. dossier_matplotlib.numerix += " (" + matplotlib.numpy.__version__ + ")"
  99. dossier_sympy = dossier("Sympy")
  100. try:
  101. import sympy
  102. dossier_sympy.version = sympy.__version__
  103. except:
  104. dossier_sympy.version = "?"
  105. dossier_psyco = dossier("Psyco")
  106. try:
  107. import psyco
  108. dossier_psyco.version = ".".join(str(elt) for elt in psyco.version_info)
  109. try:
  110. import param
  111. if param.charger_psyco is False:
  112. dossier_psyco.utilisation = "unused"
  113. elif param.charger_psyco is None:
  114. dossier_psyco.utilisation = "profile"
  115. elif param.charger_psyco is True:
  116. dossier_psyco.utilisation = "full"
  117. else:
  118. dossier_psyco.utilisation = "inconnue"
  119. except ImportError:
  120. dossier_psyco.utilisation = "?"
  121. except ImportError:
  122. dossier_psyco.version = "Psyco non trouve."
  123. except Exception:
  124. dossier_psyco.version = "#ERREUR#"
  125. dossier_wxgeometrie = dossier("Wxgeometrie")
  126. try:
  127. import param
  128. dossier_wxgeometrie.version = param.version
  129. except Exception:
  130. dossier_wxgeometrie.version = "?"
  131. return (dossier_os.contenu() + dossier_local.contenu() + dossier_python.contenu()
  132. + dossier_wxpython.contenu() + dossier_matplotlib.contenu()
  133. + dossier_sympy.contenu() + dossier_psyco.contenu()
  134. + dossier_wxgeometrie.contenu())