[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [1196] trunk/py/scripts/addons/ game_engine_save_as_runtime.py: minor edits

Campbell Barton ideasman42 at gmail.com
Wed Nov 24 16:17:27 CET 2010


Revision: 1196
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-extensions&revision=1196
Author:   campbellbarton
Date:     2010-11-24 16:17:26 +0100 (Wed, 24 Nov 2010)

Log Message:
-----------
minor edits

Modified Paths:
--------------
    trunk/py/scripts/addons/game_engine_save_as_runtime.py

Modified: trunk/py/scripts/addons/game_engine_save_as_runtime.py
===================================================================
--- trunk/py/scripts/addons/game_engine_save_as_runtime.py	2010-11-24 14:56:33 UTC (rev 1195)
+++ trunk/py/scripts/addons/game_engine_save_as_runtime.py	2010-11-24 15:17:26 UTC (rev 1196)
@@ -32,18 +32,18 @@
     'category': 'Game Engine'}
 
 import bpy
-import struct
 import os
-import sys
-import time
 
+
 def WriteAppleRuntime(player_path, output_path):
     # Use the system's cp command to preserve some meta-data
     os.system('cp -R "%s" "%s"' % (player_path, output_path))
     
     bpy.ops.save_as_mainfile(filepath=output_path+"/Contents/Resources/game.blend", copy=True)
 
+
 def WriteRuntime(player_path, output_path):
+    import struct
 
     # Check the paths
     if not os.path.isfile(player_path):
@@ -96,7 +96,7 @@
     output.write(struct.pack('B', (offset>>0)&0xFF))
     
     # Stuff for the runtime
-    output.write("BRUNTIME".encode())
+    output.write(b'BRUNTIME')
     output.close()
     
     # Make the runtime executable on Linux
@@ -106,6 +106,7 @@
 
 from bpy.props import *
 
+
 class SaveAsRuntime(bpy.types.Operator):
     bl_idname = "wm.save_as_runtime"
     bl_label = "Save As Runtime"
@@ -120,8 +121,9 @@
     filepath = StringProperty(name="Output Path", description="Where to save the runtime", default="")
     
     def execute(self, context):
+        import time
+        start_time = time.clock()
         print("Saving runtime to", self.properties.filepath)
-        start_time = time.clock()
         WriteRuntime(self.properties.player_path,
                     self.properties.filepath)
         print("Finished in %.4fs" % (time.clock()-start_time))
@@ -132,6 +134,7 @@
         wm.add_fileselect(self)
         return {'RUNNING_MODAL'}
 
+
 def menu_func(self, context):
 
     ext = os.path.splitext(bpy.app.binary_path)[-1]
@@ -141,9 +144,11 @@
 
 def register():
     bpy.types.INFO_MT_file_export.append(menu_func)
-    
+
+
 def unregister():
     bpy.types.INFO_MT_file_export.remove(menu_func)
-    
+
+
 if __name__ == "__main__":
     register()




More information about the Bf-extensions-cvs mailing list