[#18695] Replace python errors with useful messages when no full python installation is found

from Philipp Oeser (lichtwerk)
This commit is contained in:
Campbell Barton
2009-05-05 21:51:54 +00:00
parent 2bce9ff1d1
commit 4bc6749403
15 changed files with 147 additions and 65 deletions

View File

@@ -7,7 +7,7 @@ Group: 'Export'
Tooltip: 'Export to 3DS file format (.3ds).'
"""
__author__ = ["Campbell Barton", "Bob Holcomb", "Richard L<EFBFBD>rk<EFBFBD>ng", "Damien McGinnes", "Mark Stijnman"]
__author__ = ["Campbell Barton", "Bob Holcomb", "Richard Lärkäng", "Damien McGinnes", "Mark Stijnman"]
__url__ = ("blenderartists.org", "www.blender.org", "www.gametutorials.com", "lib3ds.sourceforge.net/")
__version__ = "0.90a"
__bpydoc__ = """\
@@ -50,7 +50,10 @@ import Blender
import bpy
from BPyMesh import getMeshFromObject
from BPyObject import getDerivedObjects
import struct
try:
import struct
except:
struct = None
# So 3ds max can open files, limit names to 12 in length
# this is verry annoying for filenames!
@@ -1009,5 +1012,8 @@ def save_3ds(filename):
if __name__=='__main__':
Blender.Window.FileSelector(save_3ds, "Export 3DS", Blender.sys.makename(ext='.3ds'))
if struct:
Blender.Window.FileSelector(save_3ds, "Export 3DS", Blender.sys.makename(ext='.3ds'))
else:
Blender.Draw.PupMenu("Error%t|This script requires a full python installation")
# save_3ds('/test_b.3ds')

View File

@@ -45,7 +45,8 @@ from Blender import Types, Object, NMesh, Material,Armature,Mesh
from Blender.Mathutils import *
from Blender import Draw, BGL
from Blender.BGL import *
import math
try: import math
except: math = None
global mat_flip,index_list,space,bone_list,mat_dict
global anim,flip_norm,swap_zy,flip_z,speed,ticks,no_light,recalc_norm,Bl_norm

View File

@@ -6,7 +6,8 @@ Group: 'AddMesh'
"""
import BPyAddMesh
import Blender
from math import cos, sin, pi
try: from math import cos, sin, pi
except: math = None
def add_torus(PREF_MAJOR_RAD, PREF_MINOR_RAD, PREF_MAJOR_SEG, PREF_MINOR_SEG):
Vector = Blender.Mathutils.Vector
@@ -61,5 +62,8 @@ def main():
BPyAddMesh.add_mesh_simple('Torus', verts, [], faces)
main()
if math:
main()
else:
Blender.Draw.PupMenu("Error%t|This script requires a full python installation")

View File

@@ -94,37 +94,40 @@ ______________________________________________________________
import Blender
from Blender import Mathutils, Window, Scene, sys, Draw, Mesh
import BPyMessages
import os
import subprocess
try: import os
except: os = None
try: import subprocess
except: subprocess = None
try: import copy
except: copy = None
#print os.sys.platform
#print dir(os.sys.version)
#import dxfLibrary
#reload(dxfLibrary)
from dxfLibrary import *
#-------- DWG support ------------------------------------------
extCONV_OK = True
extCONV = 'DConvertCon.exe'
extCONV_PATH = os.path.join(Blender.Get('scriptsdir'),extCONV)
if not os.path.isfile(extCONV_PATH):
extCONV_OK = False
extCONV_TEXT = 'DWG-Exporter: Abort, nothing done!|\
Copy first %s into Blender script directory.|\
More details in online Help.' %extCONV
else:
if not os.sys.platform.startswith('win'):
# check if Wine installed:
if subprocess.Popen(('which', 'winepath'), stdout=subprocess.PIPE).stdout.read().strip():
extCONV_PATH = 'wine %s'%extCONV_PATH
else:
extCONV_OK = False
extCONV_TEXT = 'DWG-Exporter: Abort, nothing done!|\
The external DWG-converter (%s) needs Wine installed on your system.|\
More details in online Help.' %extCONV
#print 'extCONV_PATH = ', extCONV_PATH
if copy and os:
from dxfLibrary import *
#-------- DWG support ------------------------------------------
extCONV_OK = True
extCONV = 'DConvertCon.exe'
extCONV_PATH = os.path.join(Blender.Get('scriptsdir'),extCONV)
if not os.path.isfile(extCONV_PATH):
extCONV_OK = False
extCONV_TEXT = 'DWG-Exporter: Abort, nothing done!|\
Copy first %s into Blender script directory.|\
More details in online Help.' %extCONV
else:
if not os.sys.platform.startswith('win'):
# check if Wine installed:
if subprocess.Popen(('which', 'winepath'), stdout=subprocess.PIPE).stdout.read().strip():
extCONV_PATH = 'wine %s'%extCONV_PATH
else:
extCONV_OK = False
extCONV_TEXT = 'DWG-Exporter: Abort, nothing done!|\
The external DWG-converter (%s) needs Wine installed on your system.|\
More details in online Help.' %extCONV
#print 'extCONV_PATH = ', extCONV_PATH
@@ -526,7 +529,8 @@ http://wiki.blender.org/index.php?title=Scripts/Manual/Export/autodesk_dxf')
#-----------------------------------------------------
if __name__=='__main__':
#main()
if not copy:
Draw.PupMenu('Error%t|This script requires a full python install')
else: Window.FileSelector(dxf_export_ui, 'EXPORT DXF', sys.makename(ext='.dxf'))
#main()
if copy and os and subprocess:
Window.FileSelector(dxf_export_ui, 'EXPORT DXF', sys.makename(ext='.dxf'))
else:
Draw.PupMenu('Error%t|This script requires a full python install')

View File

@@ -2729,15 +2729,16 @@ def fbx_ui_exit(e,v):
GLOBALS['EVENT'] = e
def do_help(e,v):
url = 'http://wiki.blender.org/index.php/Scripts/Manual/Export/autodesk_fbx'
print 'Trying to open web browser with documentation at this address...'
print '\t' + url
try:
import webbrowser
webbrowser.open(url)
except:
print '...could not open a browser window.'
url = 'http://wiki.blender.org/index.php/Scripts/Manual/Export/autodesk_fbx'
print 'Trying to open web browser with documentation at this address...'
print '\t' + url
try:
import webbrowser
webbrowser.open(url)
except:
Blender.Draw.PupMenu("Error%t|Opening a webbrowser requires a full python installation")
print '...could not open a browser window.'

View File

@@ -36,6 +36,12 @@ This script opens the user's default web browser at http://www.blender.org's
# ***** END GPL LICENCE BLOCK *****
# --------------------------------------------------------------------------
import Blender, webbrowser
version = str(int(Blender.Get('version')))
webbrowser.open('http://www.blender.org/documentation/'+ version +'PythonDoc/')
import Blender
try: import webbrowser
except: webbrowser = None
if webbrowser:
version = str(int(Blender.Get('version')))
webbrowser.open('http://www.blender.org/documentation/'+ version +'PythonDoc/')
else:
Blender.Draw.PupMenu("Error%t|This script requires a full python installation")

View File

@@ -38,5 +38,13 @@ This script opens the user's default web browser at www.blender.org's
# ***** END GPL LICENCE BLOCK *****
# --------------------------------------------------------------------------
import Blender, webbrowser
webbrowser.open('http://www.blender.org/education-help/tutorials/getting-started/')
import Blender
try: import webbrowser
except: webbrowser = None
if webbrowser:
webbrowser.open('http://www.blender.org/education-help/tutorials/getting-started/')
else:
Blender.Draw.PupMenu("Error%t|This script requires a full python installation")

View File

@@ -36,5 +36,13 @@ This script opens the user's default web browser at www.blender.org's
# ***** END GPL LICENCE BLOCK *****
# --------------------------------------------------------------------------
import Blender, webbrowser
webbrowser.open('http://wiki.blender.org/index.php/Manual')
import Blender
try: import webbrowser
except: webbrowser = None
if webbrowser:
webbrowser.open('http://wiki.blender.org/index.php/Manual')
else:
Blender.Draw.PupMenu("Error%t|This script requires a full python installation")

View File

@@ -36,6 +36,12 @@ This script opens the user's default web browser at www.blender.org's
# ***** END GPL LICENCE BLOCK *****
# --------------------------------------------------------------------------
import Blender, webbrowser
import Blender
try: import webbrowser
except: webbrowser = None
if webbrowser:
webbrowser.open('http://www.blender.org/development/release-logs/')
else:
Blender.Draw.PupMenu("Error%t|This script requires a full python installation")
webbrowser.open('http://www.blender.org/development/release-logs/')

View File

@@ -37,5 +37,11 @@ This script opens the user's default web browser at www.blender.org's
# ***** END GPL LICENCE BLOCK *****
# --------------------------------------------------------------------------
import Blender, webbrowser
webbrowser.open('http://www.blender.org/education-help/tutorials/')
import Blender
try: import webbrowser
except: webbrowser = None
if webbrowser:
webbrowser.open('http://www.blender.org/education-help/tutorials/')
else:
Blender.Draw.PupMenu("Error%t|This script requires a full python installation")

View File

@@ -38,5 +38,11 @@ www.blender.org.
# ***** END GPL LICENCE BLOCK *****
# --------------------------------------------------------------------------
import Blender, webbrowser
webbrowser.open('http://www.blender.org/')
import Blender
try: import webbrowser
except: webbrowser = None
if webbrowser:
webbrowser.open('http://www.blender.org/')
else:
Blender.Draw.PupMenu("Error%t|This script requires a full python installation")

View File

@@ -37,5 +37,11 @@ This script opens the user's default web browser at www.blender.org's
# ***** END GPL LICENCE BLOCK *****
# --------------------------------------------------------------------------
import webbrowser
webbrowser.open('http://www.blender.org/community/get-involved/')
import Blender
try: import webbrowser
except: webbrowser = None
if webbrowser:
webbrowser.open('http://www.blender.org/community/get-involved/')
else:
Blender.Draw.PupMenu("Error%t|This script requires a full python installation")

View File

@@ -37,5 +37,11 @@ This script opens the user's default web browser at www.blender.org's
# ***** END GPL LICENCE BLOCK *****
# --------------------------------------------------------------------------
import Blender, webbrowser
webbrowser.open('http://www.blender3d.org/e-shop')
import Blender
try: import webbrowser
except: webbrowser = None
if webbrowser:
webbrowser.open('http://www.blender3d.org/e-shop')
else:
Blender.Draw.PupMenu("Error%t|This script requires a full python installation")

View File

@@ -37,5 +37,11 @@ This script opens the user's default web browser at www.blender.org's
# ***** END GPL LICENCE BLOCK *****
# --------------------------------------------------------------------------
import webbrowser
webbrowser.open('http://www.blender.org/community/user-community/')
import Blender
try: import webbrowser
except: webbrowser = None
if webbrowser:
webbrowser.open('http://www.blender.org/community/user-community/')
else:
Blender.Draw.PupMenu("Error%t|This script requires a full python installation")

View File

@@ -68,8 +68,13 @@ v5.5 format.
# ***** END GPL LICENCE BLOCK *****
import Blender
import struct, cStringIO, operator
import BPyMesh
try: import struct
except: struct = None
try: import cStringIO
except: cStringIO = None
try: import operator
except: operator = None
VCOL_NAME = "\251 Per-Face Vertex Colors"
DEFAULT_NAME = "\251 Blender Default"
@@ -696,4 +701,7 @@ def fs_callback(filename):
if not filename.lower().endswith('.lwo'): filename += '.lwo'
write(filename)
Blender.Window.FileSelector(fs_callback, "Export LWO", Blender.sys.makename(ext='.lwo'))
if struct and cStringIO and operator:
Blender.Window.FileSelector(fs_callback, "Export LWO", Blender.sys.makename(ext='.lwo'))
else:
Blender.Draw.PupMenu("Error%t|This script requires a full python installation")