blender/release/scripts/sysinfo.py
Willian Padovani Germano d65fc84a68 Note: this commit includes new functionality to save and restore scripts configure options. This is ongoing work, scripts still have to be updated to use this feature and more tests are needed, though many have been performed. The new Scripts Config Editor script is the main part of this. If anyone wants to check it, only the AC3D importer and exporter have already been updated to use it: simply open them (you can then cancel with ESC) to have the data created, then try the config editor.
Scripts:
- Thanks Jean-Michel Soler (jms) for updated versions of dispaint, fixfromarmature and unweld (also renamed to remove version part).
- Thanks Bart for the upgraded VRML exporter (great doc webpage!).  It is available as VRML 97 and the original VRML 2 is for now still there, to help users testing the new version.  For the next release the old one should be removed, of course.
- New script: Scripts Config Editor (Scripts win -> Scripts -> System).  Scripts with config options (simple data that is to be set according to user needs or preferences) can use this facility instead of providing a gui and writing config files to disk themselves.
- Added new menu: System, available in the Scripts win.
- Updated sys_info.py, help_browse.py and the AC3D importer and exporter.
- Removed use of the Scrollbar and added arrow keys and mouse wheel support instead in Daniel Dunbar's old doc_browser.py. The scrollbar events handling doesn't exist, Ton suggested removing the scrollbar from the API months ago.  For now its ref doc is gone and no bundled script uses it, until we get time to implement it properly.
- Added module BPyRegistry.py with functions to handle reading / writing config files automatically to the scripts/bpydata/config dir.
- Removing dir release/bpydata and its contents (moved earlier to release/scripts/bpydata/)
- Bug #2379: made small changes to bevel_center's ui to fix a problem reported by Alexander Ewering (intrr):
http://projects.blender.org/tracker/?func=detail&atid=125&aid=2379&group_id=9

BPython:
- Thanks Campbell Barton for new functionality: Blender.Get() now can also return all the paths from the user prefs -> file paths win and there is a new function: Blender.sys.expandpath() to transform Blender paths (those starting with '//' and ending with '#') to absolute paths.
- Added function Blender.ShowHelp(), to open the Scripts Help Browser with a given help page -- just a time saver for scripts.
- Improved function Blender.Run() to also work with gui and file select scripts.
- Found a (new?) crash related to NMesh.PutRaw when creating a new object while in edit mode.  Leaving / entering edit mode fixes the problem, so a check for obj created, edit mode and leaving / re-entering it were added to the code for now (gdb didn't help much, no backtrace)
- doc updates, including splitting intro page in two, with bpython related stuff (registering / documenting / configuring scripts and command line mode (thanks Chris Want for "use system variables to pass parameters to scripts" idea).
- Registry: functions have been updated to support writing to / reading from disk, for the config editor -- only simple config data supported, for large amounts coders should write to a file themselves.  This is done with a new parameter: Registry.GetKey(keyname, True) will also search for the key on the config dir, if not already loaded; equiv. for Registry.SetKey(keyname, dict, True).  Data is only written to / read from disk when needed and only scripts already used (assuming they support this functionality) will have config data saved.
2005-04-16 05:25:42 +00:00

286 lines
8.3 KiB
Python

#!BPY
"""
Name: 'System Information...'
Blender: 236
Group: 'HelpSystem'
Tooltip: 'Information about your Blender environment, useful to diagnose problems.'
"""
__author__ = "Willian P. Germano"
__url__ = ("blender", "elysiun")
__version__ = "1.1"
__bpydoc__ = """\
This script creates a text in Blender's Text Editor with information
about your OS, video card, OpenGL driver, Blender and Python versions,
script related paths and more.
If you are experiencing trouble running Blender itself or any Blender Python
script, this information can be useful to fix any problems or at least for
online searches (like checking if there are known issues related to your
video card) or to get help from other users or the program's developers.
"""
# $Id$
#
# --------------------------------------------------------------------------
# sysinfo.py version 1.1 Mar 20, 2005
# --------------------------------------------------------------------------
# ***** BEGIN GPL LICENSE BLOCK *****
#
# Copyright (C) 2004: Willian P. Germano, wgermano _at_ ig.com.br
#
# 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 2
# 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, write to the Free Software Foundation,
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# ***** END GPL LICENCE BLOCK *****
# --------------------------------------------------------------------------
import Blender
import Blender.sys as bsys
from Blender.BGL import *
import sys
Blender.Window.WaitCursor(1)
# has_textwrap = 1 # see commented code below
output_filename = "system-info.txt"
warnings = 0
notices = 0 # non critical warnings
def cutPoint(text, length):
"Returns position of the last space found before 'length' chars"
l = length
c = text[l]
while c != ' ':
l -= 1
if l == 0: return length # no space found
c = text[l]
return l
def textWrap(text, length = 70):
lines = []
while len(text) > 70:
cpt = cutPoint(text, length)
line, text = text[:cpt], text[cpt + 1:]
lines.append(line)
lines.append(text)
return lines
## Better use our own text wrap functions here
#try:
# import textwrap
#except:
# has_textwrap = 0
# msg = sys.exc_info()[1].__str__().split()[3]
# Blender.Draw.PupMenu("Python error:|This script requires the %s module" %msg)
version = Blender.Get('version') / 100.0
header = "= Blender %s System Information =" % version
lilies = len(header)*"="+"\n"
header = lilies + header + "\n" + lilies
output = Blender.Text.New(output_filename)
output.write(header + "\n\n")
output.write("Platform: %s\n========\n\n" % sys.platform)
output.write("Python:\n======\n\n")
output.write("- Version: %s\n\n" % sys.version)
output.write("- Paths:\n\n")
for p in sys.path:
output.write(p + '\n')
output.write("\n- Directories:")
dirlist = [
['homedir', 'Blender home dir', 1],
['scriptsdir', 'Default dir for scripts', 1],
['datadir', 'Default "bpydata/" data dir for scripts', 1],
['uscriptsdir', 'User defined dir for scripts', 0],
['udatadir', 'Data dir "bpydata/" inside user defined dir', 0]
]
has_dir = {}
for dir in dirlist:
dirname, dirstr, is_critical = dir
dirpath = Blender.Get(dirname)
output.write("\n\n %s:\n" % dirstr)
if not dirpath:
has_dir[dirname] = False
if is_critical:
warnings += 1
output.write(" <WARNING> -- not found")
else:
notices += 1
output.write(" <NOTICE> -- not found")
else:
output.write(" %s" % dirpath)
has_dir[dirname] = True
if not has_dir['homedir']:
outmsg = """
<WARNING> - Blender home dir not found!
This should probably be "<path>/.blender/"
where <path> is usually the user's home dir.
Blender's home dir is where entries like:
folders scripts/, plugins/ and locale/ and
files .Blanguages and .bfont.ttf
are located.
It's also where Blender stores the Bpymenus file
with information about registered scripts, so it
only needs to scan scripts dir(s) when they are
modified.
"""
output.write(outmsg)
has_uconfdir = False
if has_dir['udatadir']:
uconfigdir = bsys.join(Blender.Get('udatadir'), 'config')
output.write("\n\n User defined config data dir:")
if bsys.exists(uconfigdir):
has_uconfdir = True
output.write(" %s" % uconfigdir)
else:
notices += 1
output.write("""
<NOTICE> -- not found.
bpydata/config/ should be inside the user defined scripts dir.
It's used by Blender to store scripts configuration data.
(Since it is on the user defined dir, a new Blender installation
won't overwrite the data.)
""")
configdir = bsys.join(Blender.Get('datadir'), 'config')
output.write('\n\n Default config data "bpydata/config/" dir:\n')
if bsys.exists(configdir):
output.write(" %s" % configdir)
else:
warnings += 1
output.write("""<WARNING> -- not found.
config/ should be inside the default scripts *data dir*.
It's used by Blender to store scripts configuration data
when <user defined scripts dir>/bpydata/config/ dir is
not available.
""")
if has_uconfdir:
output.write("""
The user defined config dir will be used.
""")
cvsdir = 'release/scripts'
if bsys.dirsep == '\\': cvsdir = cvsdir.replace('/','\\')
sdir = Blender.Get('scriptsdir')
if sdir and sdir.find(cvsdir) >= 0:
if has_uconfdir:
notices += 1
output.write("\n\n<NOTICE>:\n")
else:
warnings += 1
output.write("\n\n<WARNING>:\n")
output.write("""
It seems this Blender binary is located in its cvs source tree.
It's recommended that the release/scripts/ dir tree is copied
to your blender home dir.
""")
if not has_uconfdir:
output.write("""
Since you also don't have a user defined scripts dir with the
bpydata/config dir inside it, it will not be possible to save
and restore scripts configuration data files, since writing
to a dir inside a cvs tree is not a good idea and is avoided.
""")
missing_mods = [] # missing basic modules
try:
from BPyBlender import basic_modules
for m in basic_modules:
try: exec ("import %s" % m)
except: missing_mods.append(m)
if missing_mods:
outmsg = """
<WARNING>:
Some expected modules were not found.
Because of that some scripts bundled with Blender may not work.
Please read the FAQ in the Readme.html file shipped with Blender
for information about how to fix the problem.
Missing modules:
"""
output.write(outmsg)
warnings += 1
for m in missing_mods:
output.write('-> ' + m + '\n')
if 'BPyRegistry' in missing_mods:
output.write("""
Module BPyRegistry.py is missing!
Without this module it's not possible to save and restore
scripts configuration data files.
""")
else:
output.write("\n\n- Modules: all basic ones were found.\n")
except ImportError:
output.write("\n\n<WARNING>:\n Couldn't find BPyBlender.py in scripts/bpymodules/ dir.")
output.write("\n Basic modules availability won't be tested.\n")
warnings += 1
output.write("\nOpenGL:\n======\n\n")
output.write("- Renderer: %s\n" % glGetString(GL_RENDERER))
output.write("- Vendor: %s\n" % glGetString(GL_VENDOR))
output.write("- Version: %s\n\n" % glGetString(GL_VERSION))
output.write("- Extensions:\n\n")
glext = glGetString(GL_EXTENSIONS)
glext = textWrap(glext, 70)
for l in glext:
output.write(l + "\n")
output.write("\n\n- Simplistic almost useless benchmark:\n\n")
t = Blender.sys.time()
nredraws = 10
for i in range(nredraws):
Blender.Redraw(-1) # redraw all windows
result = Blender.sys.time() - t
output.write("Redrawing all areas %s times took %.4f seconds.\n" % (nredraws, result))
if warnings or notices:
output.write("\n%s%s\n" % (warnings*"#", notices*"."))
if warnings:
output.write("\n(*) Found %d warning" % warnings)
if (warnings > 1): output.write("s") # (blush)
output.write(", documented in the text above.\n")
if notices:
output.write("\n(*) Found %d notice" % notices)
if (notices > 1): output.write("s") # (blush)
output.write(", documented in the text above.\n")
else: output.write("\n==\nNo problems were found (scroll up for details).")
Blender.Window.WaitCursor(0)
exitmsg = "Done!|Please check the text %s in the Text Editor window" % output.name
Blender.Draw.PupMenu(exitmsg)