Skip to content
Snippets Groups Projects
Commit 3836746b authored by Jesse Kaukonen's avatar Jesse Kaukonen
Browse files

Fixing a bug with an assertation failing due to file being saved in inaccessable directory

parent bf97ac20
No related branches found
No related tags found
No related merge requests found
...@@ -21,7 +21,7 @@ DEV = False ...@@ -21,7 +21,7 @@ DEV = False
bl_info = { bl_info = {
"name": "Renderfarm.fi", "name": "Renderfarm.fi",
"author": "Nathan Letwory <nathan@letworyinteractive.com>, Jesse Kaukonen <jesse.kaukonen@gmail.com>", "author": "Nathan Letwory <nathan@letworyinteractive.com>, Jesse Kaukonen <jesse.kaukonen@gmail.com>",
"version": (19,), "version": (20,),
"blender": (2, 6, 2), "blender": (2, 6, 2),
"location": "Render > Engine > Renderfarm.fi", "location": "Render > Engine > Renderfarm.fi",
"description": "Send .blend as session to http://www.renderfarm.fi to render", "description": "Send .blend as session to http://www.renderfarm.fi to render",
...@@ -43,6 +43,7 @@ import http.client ...@@ -43,6 +43,7 @@ import http.client
import xmlrpc.client import xmlrpc.client
import math import math
from os.path import isabs, isfile from os.path import isabs, isfile
import os
import time import time
from bpy.props import PointerProperty, StringProperty, BoolProperty, EnumProperty, IntProperty, CollectionProperty from bpy.props import PointerProperty, StringProperty, BoolProperty, EnumProperty, IntProperty, CollectionProperty
...@@ -81,7 +82,7 @@ bpy.cancelError = False ...@@ -81,7 +82,7 @@ bpy.cancelError = False
bpy.texturePackError = False bpy.texturePackError = False
bpy.linkedFileError = False bpy.linkedFileError = False
bpy.uploadInProgress = False bpy.uploadInProgress = False
bpy.originalFileName = bpy.path.display_name_from_filepath(bpy.data.filepath) bpy.originalFileName = bpy.data.filepath
bpy.particleBakeWarning = False bpy.particleBakeWarning = False
bpy.childParticleWarning = False bpy.childParticleWarning = False
bpy.simulationWarning = False bpy.simulationWarning = False
...@@ -324,14 +325,29 @@ def prepareScene(): ...@@ -324,14 +325,29 @@ def prepareScene():
# Save with a different name # Save with a different name
print("Saving into a new file...") print("Saving into a new file...")
bpy.originalFileName = bpy.data.filepath
print("Original path is " + bpy.originalFileName)
try: try:
# If the filename is empty, we'll make one from the path of the Blender installation # If the filename is empty, we'll make one from the path of the user's resource folder
if (len(bpy.originalFileName) == 0): if (len(bpy.originalFileName) == 0):
bpy.originalFileName = bpy.utils.resource_path(type='LOCAL') + "renderfarm.blend" print("No existing file path found, saving to autosave directory")
bpy.ops.wm.save_mainfile(filepath=bpy.originalFileName) savePath = bpy.utils.user_resource("AUTOSAVE")
try:
os.mkdir(savePath)
except Exception as ex:
print(ex)
try:
savePath = savePath + "_renderfarm"
except Exception as ex:
print(ex)
try:
bpy.ops.wm.save_mainfile(filepath=savePath)
except Exception as ex:
print(ex)
else: else:
print("Saving to current .blend directory")
savePath = bpy.originalFileName savePath = bpy.originalFileName
savePath = savePath + "_renderfarm" savePath = savePath + "_renderfarm.blend"
bpy.ops.wm.save_mainfile(filepath=savePath) bpy.ops.wm.save_mainfile(filepath=savePath)
except Exception as e: except Exception as e:
print(e) print(e)
...@@ -691,9 +707,13 @@ def encode_multipart_data(data, files): ...@@ -691,9 +707,13 @@ def encode_multipart_data(data, files):
return body, headers return body, headers
def send_post(data, files): def send_post(data, files):
print("Forming connection for post")
connection = http.client.HTTPConnection(rffi_xmlrpc_upload) connection = http.client.HTTPConnection(rffi_xmlrpc_upload)
print("Requesting")
connection.request('POST', '/burp/storage', *encode_multipart_data(data, files)) # was /file connection.request('POST', '/burp/storage', *encode_multipart_data(data, files)) # was /file
print("Getting response")
response = connection.getresponse() response = connection.getresponse()
print("Reading response")
res = response.read() res = response.read()
return res return res
...@@ -709,7 +729,9 @@ def md5_for_file(filepath): ...@@ -709,7 +729,9 @@ def md5_for_file(filepath):
return md5hash.hexdigest() return md5hash.hexdigest()
def upload_file(key, userid, sessionid, path): def upload_file(key, userid, sessionid, path):
print("Asserting absolute path")
assert isabs(path) assert isabs(path)
print("Asserting path is a file")
assert isfile(path) assert isfile(path)
data = { data = {
'userId': str(userid), 'userId': str(userid),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment