home *** CD-ROM | disk | FTP | other *** search
/ Windows News 2005 November / WNnov2005.iso / Windows / Equipement / Blender / blender-2.37a-windows.exe / $_5_ / .blender / scripts / sysinfo.py < prev    next >
Text File  |  2005-04-17  |  9KB  |  286 lines

  1. #!BPY
  2.  
  3. """
  4. Name: 'System Information...'
  5. Blender: 236
  6. Group: 'HelpSystem'
  7. Tooltip: 'Information about your Blender environment, useful to diagnose problems.'
  8. """
  9.  
  10. __author__ = "Willian P. Germano"
  11. __url__ = ("blender", "elysiun")
  12. __version__ = "1.1"
  13. __bpydoc__ = """\
  14. This script creates a text in Blender's Text Editor with information
  15. about your OS, video card, OpenGL driver, Blender and Python versions,
  16. script related paths and more.
  17.  
  18. If you are experiencing trouble running Blender itself or any Blender Python
  19. script, this information can be useful to fix any problems or at least for
  20. online searches (like checking if there are known issues related to your
  21. video card) or to get help from other users or the program's developers.
  22. """
  23.  
  24. # $Id: sysinfo.py,v 1.7 2005/04/16 05:25:41 ianwill Exp $
  25. #
  26. # --------------------------------------------------------------------------
  27. # sysinfo.py version 1.1 Mar 20, 2005
  28. # --------------------------------------------------------------------------
  29. # ***** BEGIN GPL LICENSE BLOCK *****
  30. #
  31. # Copyright (C) 2004: Willian P. Germano, wgermano _at_ ig.com.br
  32. #
  33. # This program is free software; you can redistribute it and/or
  34. # modify it under the terms of the GNU General Public License
  35. # as published by the Free Software Foundation; either version 2
  36. # of the License, or (at your option) any later version.
  37. #
  38. # This program is distributed in the hope that it will be useful,
  39. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  40. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.    See the
  41. # GNU General Public License for more details.
  42. #
  43. # You should have received a copy of the GNU General Public License
  44. # along with this program; if not, write to the Free Software Foundation,
  45. # Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  46. #
  47. # ***** END GPL LICENCE BLOCK *****
  48. # --------------------------------------------------------------------------
  49.  
  50. import Blender
  51. import Blender.sys as bsys
  52. from Blender.BGL import *
  53. import sys
  54.  
  55. Blender.Window.WaitCursor(1)
  56. # has_textwrap = 1 # see commented code below
  57. output_filename = "system-info.txt"
  58. warnings = 0
  59. notices = 0 # non critical warnings
  60.  
  61. def cutPoint(text, length):
  62.     "Returns position of the last space found before 'length' chars"
  63.     l = length
  64.     c = text[l]
  65.     while c != ' ':
  66.         l -= 1
  67.         if l == 0: return length # no space found
  68.         c = text[l]
  69.     return l
  70.  
  71. def textWrap(text, length = 70):
  72.     lines = []
  73.     while len(text) > 70:
  74.         cpt = cutPoint(text, length)
  75.         line, text = text[:cpt], text[cpt + 1:]
  76.         lines.append(line)
  77.     lines.append(text)
  78.     return lines
  79.  
  80. ## Better use our own text wrap functions here
  81. #try:
  82. #  import textwrap
  83. #except:
  84. #  has_textwrap = 0
  85. #  msg = sys.exc_info()[1].__str__().split()[3]
  86. #  Blender.Draw.PupMenu("Python error:|This script requires the %s module" %msg)
  87.  
  88. version = Blender.Get('version') / 100.0
  89. header = "=  Blender %s System Information  =" % version
  90. lilies = len(header)*"="+"\n"
  91. header = lilies + header + "\n" + lilies
  92.  
  93. output = Blender.Text.New(output_filename)
  94.  
  95. output.write(header + "\n\n")
  96.  
  97. output.write("Platform: %s\n========\n\n" % sys.platform)
  98.  
  99. output.write("Python:\n======\n\n")
  100. output.write("- Version: %s\n\n" % sys.version)
  101. output.write("- Paths:\n\n")
  102. for p in sys.path:
  103.     output.write(p + '\n')
  104.  
  105. output.write("\n- Directories:")
  106.  
  107. dirlist = [
  108.     ['homedir', 'Blender home dir', 1],
  109.     ['scriptsdir', 'Default dir for scripts', 1],
  110.     ['datadir', 'Default "bpydata/" data dir for scripts', 1],
  111.     ['uscriptsdir', 'User defined dir for scripts', 0],
  112.     ['udatadir', 'Data dir "bpydata/" inside user defined dir', 0]
  113. ]
  114.  
  115. has_dir = {}
  116.  
  117. for dir in dirlist:
  118.     dirname, dirstr, is_critical = dir
  119.     dirpath = Blender.Get(dirname)
  120.     output.write("\n\n %s:\n" % dirstr)
  121.     if not dirpath:
  122.         has_dir[dirname] = False
  123.         if is_critical:
  124.             warnings += 1
  125.             output.write("  <WARNING> -- not found")
  126.         else:
  127.             notices += 1
  128.             output.write("  <NOTICE> -- not found")
  129.     else:
  130.         output.write("  %s" % dirpath)
  131.         has_dir[dirname] = True
  132.  
  133. if not has_dir['homedir']:
  134.     outmsg = """
  135.  
  136. <WARNING> - Blender home dir not found!
  137.   This should probably be "<path>/.blender/"
  138.   where <path> is usually the user's home dir.
  139.  
  140.   Blender's home dir is where entries like:
  141.     folders scripts/, plugins/ and locale/ and
  142.     files .Blanguages and .bfont.ttf
  143.   are located.
  144.  
  145.   It's also where Blender stores the Bpymenus file
  146.   with information about registered scripts, so it
  147.   only needs to scan scripts dir(s) when they are
  148.   modified.
  149. """
  150.     output.write(outmsg)
  151.  
  152. has_uconfdir = False
  153. if has_dir['udatadir']:
  154.     uconfigdir = bsys.join(Blender.Get('udatadir'), 'config')
  155.     output.write("\n\n User defined config data dir:")
  156.     if bsys.exists(uconfigdir):
  157.         has_uconfdir = True
  158.         output.write("  %s" % uconfigdir)
  159.     else:
  160.         notices += 1
  161.         output.write("""
  162.   <NOTICE> -- not found.
  163.   bpydata/config/ should be inside the user defined scripts dir.
  164.   It's used by Blender to store scripts configuration data.
  165.   (Since it is on the user defined dir, a new Blender installation
  166.   won't overwrite the data.)
  167. """)
  168.  
  169. configdir = bsys.join(Blender.Get('datadir'), 'config')
  170. output.write('\n\n Default config data "bpydata/config/" dir:\n')
  171. if bsys.exists(configdir):
  172.     output.write("  %s" % configdir)
  173. else:
  174.     warnings += 1
  175.     output.write("""<WARNING> -- not found.
  176.   config/ should be inside the default scripts *data dir*.
  177.   It's used by Blender to store scripts configuration data
  178.   when <user defined scripts dir>/bpydata/config/ dir is
  179.   not available.
  180. """)
  181.  
  182. if has_uconfdir:
  183.     output.write("""
  184.  
  185. The user defined config dir will be used.
  186. """)
  187.  
  188. cvsdir = 'release/scripts'
  189. if bsys.dirsep == '\\': cvsdir = cvsdir.replace('/','\\')
  190. sdir = Blender.Get('scriptsdir')
  191. if sdir and sdir.find(cvsdir) >= 0:
  192.     if has_uconfdir:
  193.         notices += 1
  194.         output.write("\n\n<NOTICE>:\n")
  195.     else:
  196.         warnings += 1
  197.         output.write("\n\n<WARNING>:\n")
  198.     output.write("""
  199. It seems this Blender binary is located in its cvs source tree.
  200.  
  201. It's recommended that the release/scripts/ dir tree is copied
  202. to your blender home dir.
  203. """)
  204.     if not has_uconfdir:
  205.         output.write("""
  206. Since you also don't have a user defined scripts dir with the
  207. bpydata/config dir inside it, it will not be possible to save
  208. and restore scripts configuration data files, since writing
  209. to a dir inside a cvs tree is not a good idea and is avoided. 
  210. """)
  211.  
  212. missing_mods = [] # missing basic modules
  213.  
  214. try:
  215.     from BPyBlender import basic_modules
  216.     for m in basic_modules:
  217.         try: exec ("import %s" % m)
  218.         except: missing_mods.append(m)
  219.  
  220.     if missing_mods:
  221.         outmsg = """
  222.  
  223. <WARNING>:
  224.  
  225. Some expected modules were not found.
  226. Because of that some scripts bundled with Blender may not work.
  227. Please read the FAQ in the Readme.html file shipped with Blender
  228. for information about how to fix the problem.
  229. Missing modules:
  230. """
  231.         output.write(outmsg)
  232.         warnings += 1
  233.         for m in missing_mods:
  234.             output.write('-> ' + m + '\n')
  235.         if 'BPyRegistry' in missing_mods:
  236.             output.write("""
  237. Module BPyRegistry.py is missing!
  238. Without this module it's not possible to save and restore
  239. scripts configuration data files.
  240. """)
  241.  
  242.     else:
  243.         output.write("\n\n- Modules: all basic ones were found.\n")
  244.  
  245. except ImportError:
  246.     output.write("\n\n<WARNING>:\n  Couldn't find BPyBlender.py in scripts/bpymodules/ dir.")
  247.     output.write("\n  Basic modules availability won't be tested.\n")
  248.     warnings += 1
  249.  
  250. output.write("\nOpenGL:\n======\n\n")
  251. output.write("- Renderer:   %s\n" % glGetString(GL_RENDERER))
  252. output.write("- Vendor:     %s\n" % glGetString(GL_VENDOR))
  253. output.write("- Version:    %s\n\n" % glGetString(GL_VERSION))
  254. output.write("- Extensions:\n\n")
  255.  
  256. glext = glGetString(GL_EXTENSIONS)
  257. glext = textWrap(glext, 70)
  258.  
  259. for l in glext:
  260.     output.write(l + "\n")
  261.  
  262. output.write("\n\n- Simplistic almost useless benchmark:\n\n")
  263. t = Blender.sys.time()
  264. nredraws = 10
  265. for i in range(nredraws):
  266.     Blender.Redraw(-1) # redraw all windows
  267. result = Blender.sys.time() - t
  268. output.write("Redrawing all areas %s times took %.4f seconds.\n" % (nredraws, result))
  269.  
  270. if warnings or notices:
  271.     output.write("\n%s%s\n" % (warnings*"#", notices*"."))
  272.     if warnings:
  273.         output.write("\n(*) Found %d warning" % warnings)
  274.         if (warnings > 1): output.write("s") # (blush)
  275.         output.write(", documented in the text above.\n")
  276.     if notices:
  277.         output.write("\n(*) Found %d notice" % notices)
  278.         if (notices > 1): output.write("s") # (blush)
  279.         output.write(", documented in the text above.\n")
  280.  
  281. else: output.write("\n==\nNo problems were found (scroll up for details).")
  282.  
  283. Blender.Window.WaitCursor(0)
  284. exitmsg = "Done!|Please check the text %s in the Text Editor window" % output.name
  285. Blender.Draw.PupMenu(exitmsg)
  286.