| 
									
										
										
										
											2009-11-01 15:21:20 +00:00
										 |  |  | # ##### BEGIN GPL LICENSE BLOCK ##### | 
					
						
							|  |  |  | # | 
					
						
							|  |  |  | #  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. | 
					
						
							| 
									
										
										
										
											2009-11-07 22:07:46 +00:00
										 |  |  | # | 
					
						
							| 
									
										
										
										
											2009-11-01 15:21:20 +00:00
										 |  |  | #  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. | 
					
						
							| 
									
										
										
										
											2009-11-07 22:07:46 +00:00
										 |  |  | # | 
					
						
							| 
									
										
										
										
											2009-11-01 15:21:20 +00:00
										 |  |  | #  You should have received a copy of the GNU General Public License | 
					
						
							|  |  |  | #  along with this program; if not, write to the Free Software Foundation, | 
					
						
							| 
									
										
										
										
											2010-02-12 13:34:04 +00:00
										 |  |  | #  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 
					
						
							| 
									
										
										
										
											2009-11-01 15:21:20 +00:00
										 |  |  | # | 
					
						
							|  |  |  | # ##### END GPL LICENSE BLOCK ##### | 
					
						
							| 
									
										
										
										
											2009-10-31 20:16:59 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-12-05 22:03:07 +00:00
										 |  |  | # <pep8 compliant> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-13 09:28:05 +00:00
										 |  |  | # internal blender C module | 
					
						
							|  |  |  | import _bpy | 
					
						
							| 
									
										
										
										
											2010-01-31 21:52:26 +00:00
										 |  |  | from _bpy import types, props, app | 
					
						
							| 
									
										
										
										
											2009-11-13 09:28:05 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | data = _bpy.data | 
					
						
							|  |  |  | context = _bpy.context | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # python modules | 
					
						
							| 
									
										
										
										
											2009-11-13 11:10:29 +00:00
										 |  |  | from bpy import utils | 
					
						
							| 
									
										
										
										
											2009-11-13 09:28:05 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-22 11:23:19 +00:00
										 |  |  | from bpy import ops as _ops_module | 
					
						
							| 
									
										
										
										
											2009-09-28 04:29:01 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-22 11:23:19 +00:00
										 |  |  | # fake operator module | 
					
						
							|  |  |  | ops = _ops_module.ops_fake_module | 
					
						
							| 
									
										
										
										
											2009-11-19 16:15:22 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-01-20 19:26:23 +00:00
										 |  |  | import sys as _sys | 
					
						
							| 
									
										
										
										
											2009-12-13 13:59:16 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-12-05 20:45:51 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-22 11:23:19 +00:00
										 |  |  | def _main(): | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-02-28 17:11:42 +00:00
										 |  |  |     ## security issue, dont allow the $CWD in the path. | 
					
						
							|  |  |  |     ## note: this removes "" but not "." which are the same, security | 
					
						
							|  |  |  |     ## people need to explain how this is even a fix. | 
					
						
							|  |  |  |     # _sys.path[:] = filter(None, _sys.path) | 
					
						
							| 
									
										
										
										
											2010-01-20 19:26:23 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-22 11:23:19 +00:00
										 |  |  |     # a bit nasty but this prevents help() and input() from locking blender | 
					
						
							|  |  |  |     # Ideally we could have some way for the console to replace sys.stdin but | 
					
						
							|  |  |  |     # python would lock blender while waiting for a return value, not easy :| | 
					
						
							| 
									
										
										
										
											2010-03-14 23:26:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-03-08 12:29:58 +00:00
										 |  |  |     if not app.debug: | 
					
						
							|  |  |  |         _sys.stdin = None | 
					
						
							| 
									
										
										
										
											2009-11-22 11:23:19 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-03-21 14:56:26 +00:00
										 |  |  |     # because of how the console works. we need our own help() pager func. | 
					
						
							|  |  |  |     # replace the bold function because it adds crazy chars | 
					
						
							|  |  |  |     import pydoc | 
					
						
							|  |  |  |     pydoc.getpager = lambda: pydoc.plainpager | 
					
						
							|  |  |  |     pydoc.TextDoc.bold = lambda self, text: text | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-12-05 20:45:51 +00:00
										 |  |  |     # if "-d" in sys.argv: # Enable this to measure startup speed | 
					
						
							|  |  |  |     if 0: | 
					
						
							| 
									
										
										
										
											2009-11-22 11:23:19 +00:00
										 |  |  |         import cProfile | 
					
						
							| 
									
										
										
										
											2010-01-28 11:48:06 +00:00
										 |  |  |         cProfile.run('import bpy; bpy.utils.load_scripts()', 'blender.prof') | 
					
						
							| 
									
										
										
										
											2009-11-22 11:23:19 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |         import pstats | 
					
						
							|  |  |  |         p = pstats.Stats('blender.prof') | 
					
						
							|  |  |  |         p.sort_stats('cumulative').print_stats(100) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     else: | 
					
						
							| 
									
										
										
										
											2010-01-28 11:48:06 +00:00
										 |  |  |         utils.load_scripts() | 
					
						
							| 
									
										
										
										
											2009-11-22 11:23:19 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-12-28 10:00:04 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-11-22 11:23:19 +00:00
										 |  |  | _main() |