[Bf-extensions-cvs] [6c32300] : Backport revisions for the final 2.70 release

Sergey Sharybin noreply at git.blender.org
Tue Mar 18 17:13:55 CET 2014


Commit: 6c32300be8cc8d48a3e02055dc43bea2ab98a525
Author: Sergey Sharybin
Date:   Tue Mar 18 19:01:04 2014 +0600
https://developer.blender.org/rBA6c32300be8cc8d48a3e02055dc43bea2ab98a525

Backport revisions for the final 2.70 release

8b0864a

===================================================================

M	io_online_sketchfab/__init__.py
M	io_online_sketchfab/pack_for_export.py

===================================================================

diff --git a/io_online_sketchfab/__init__.py b/io_online_sketchfab/__init__.py
index 3e5d747..b39f4f7 100644
--- a/io_online_sketchfab/__init__.py
+++ b/io_online_sketchfab/__init__.py
@@ -47,6 +47,7 @@ else:
 
 import bpy
 import os
+import tempfile
 import threading
 import subprocess
 
@@ -244,7 +245,8 @@ class ExportSketchfab(bpy.types.Operator):
             basename = os.path.join(basename, "temp")
         if not ext:
             ext = ".blend"
-        filepath = basename + "-export-sketchfab" + ext
+        tempdir = tempfile.mkdtemp()
+        filepath = os.path.join(tempdir, "export-sketchfab" + ext)
 
         try:
             # save a copy of actual scene but don't interfere with the users models
@@ -262,6 +264,7 @@ class ExportSketchfab(bpy.types.Operator):
                     "-noaudio",
                     filepath,
                     "--python", os.path.join(script_path, "pack_for_export.py"),
+                    "--", tempdir
                     ])
 
             os.remove(filepath)
@@ -434,6 +437,7 @@ class SketchfabEmailToken(bpy.types.Operator):
 # remove file copy
 def terminate(filepath):
     os.remove(filepath)
+    os.rmdir(os.path.dirname(filepath))
 
 # registration
 classes = (
diff --git a/io_online_sketchfab/pack_for_export.py b/io_online_sketchfab/pack_for_export.py
index a8e7fc9..16d38cc 100644
--- a/io_online_sketchfab/pack_for_export.py
+++ b/io_online_sketchfab/pack_for_export.py
@@ -23,10 +23,12 @@
 import os
 import bpy
 import json
+import sys
 
 
 SKETCHFAB_EXPORT_DATA_FILENAME = 'sketchfab-export-data.json'
 
+SKETCHFAB_EXPORT_TEMP_DIR = sys.argv[-1]
 SKETCHFAB_EXPORT_DATA_FILE = os.path.join(
     bpy.utils.user_resource('SCRIPTS'),
     "presets",
@@ -38,7 +40,7 @@ SKETCHFAB_EXPORT_DATA_FILE = os.path.join(
 def save_blend_copy():
     import time
 
-    filepath = os.path.dirname(bpy.data.filepath)
+    filepath = SKETCHFAB_EXPORT_TEMP_DIR
     filename = time.strftime("Sketchfab_%Y_%m_%d_%H_%M_%S.blend",
                              time.localtime(time.time()))
     filepath = os.path.join(filepath, filename)
@@ -119,6 +121,5 @@ if __name__ == "__main__":
         import traceback
         traceback.print_exc()
 
-        import sys
         sys.exit(1)



More information about the Bf-extensions-cvs mailing list