diff options
-rw-r--r-- | render_renderfarmfi/__init__.py | 4 | ||||
-rw-r--r-- | render_renderfarmfi/operators.py | 86 | ||||
-rw-r--r-- | render_renderfarmfi/ore_session.py | 6 | ||||
-rw-r--r-- | render_renderfarmfi/panels.py | 78 | ||||
-rw-r--r-- | render_renderfarmfi/prepare.py | 6 | ||||
-rw-r--r-- | render_renderfarmfi/rpc.py | 16 | ||||
-rw-r--r-- | render_renderfarmfi/upload.py | 21 |
7 files changed, 116 insertions, 101 deletions
diff --git a/render_renderfarmfi/__init__.py b/render_renderfarmfi/__init__.py index ca55368f..291c10f6 100644 --- a/render_renderfarmfi/__init__.py +++ b/render_renderfarmfi/__init__.py @@ -19,7 +19,7 @@ bl_info = { "name": "Renderfarm.fi", "author": "Nathan Letwory <nathan@letworyinteractive.com>, Jesse Kaukonen <jesse.kaukonen@gmail.com>", - "version": (22,), + "version": (23,), "blender": (2, 63, 0), "location": "Render > Engine > Renderfarm.fi", "description": "Send .blend as session to http://www.renderfarm.fi to render", @@ -59,6 +59,8 @@ bpy.rffi_user = '' bpy.rffi_hash = '' bpy.passwordCorrect = False bpy.loginInserted = False +bpy.rffi_accepting = False +bpy.rffi_motd = '' bpy.errorMessages = { 'missing_desc': 'You need to enter a title, short and long description', diff --git a/render_renderfarmfi/operators.py b/render_renderfarmfi/operators.py index c9daa3c5..2c867934 100644 --- a/render_renderfarmfi/operators.py +++ b/render_renderfarmfi/operators.py @@ -29,11 +29,11 @@ from .exceptions import LoginFailedException, SessionCancelFailedException class OpSwitchRenderfarm(bpy.types.Operator): bl_label = "Switch to Renderfarm.fi" bl_idname = "ore.switch_to_renderfarm_render" - + def execute(self, context): ore = bpy.context.scene.ore_render rd = bpy.context.scene.render - + ore.resox = rd.resolution_x ore.resoy = rd.resolution_y ore.fps = rd.fps @@ -50,7 +50,7 @@ class OpSwitchRenderfarm(bpy.types.Operator): class OpSwitchBlenderRender(bpy.types.Operator): bl_label = "Switch to local render" bl_idname = "ore.switch_to_local_render" - + def execute(self, context): rd = bpy.context.scene.render ore = bpy.context.scene.ore_render @@ -70,7 +70,7 @@ class OpSwitchBlenderRender(bpy.types.Operator): class OpCopySettings(bpy.types.Operator): bl_label = "Copy settings from current scene" bl_idname = "ore.copy_settings" - + def execute(self, context): sce = bpy.context.scene rd = sce.render @@ -85,7 +85,7 @@ class OpCopySettings(bpy.types.Operator): class ORE_RefreshOp(bpy.types.Operator): bl_idname = 'ore.refresh_session_list' bl_label = 'Refresh' - + def execute(self, context): result = _do_refresh(self) if (result == 0): @@ -96,7 +96,7 @@ class ORE_RefreshOp(bpy.types.Operator): class ORE_OpenDownloadLocation(bpy.types.Operator): bl_idname = 'ore.open_download_location' bl_label = 'Download new version for your platform' - + def execute(self, context): import webbrowser webbrowser.open(bpy.download_location) @@ -105,7 +105,7 @@ class ORE_OpenDownloadLocation(bpy.types.Operator): class ORE_CancelSession(bpy.types.Operator): bl_idname = 'ore.cancel_session' bl_label = 'Cancel Session' - + def execute(self, context): sce = context.scene ore = sce.ore_render @@ -115,65 +115,65 @@ class ORE_CancelSession(bpy.types.Operator): rffi.cancel_session(self, s) except SessionCancelFailedException as scfe: print("sessioncancelfailedexception", scfe) - + return {'FINISHED'} class ORE_GetCompletedSessions(bpy.types.Operator): bl_idname = 'ore.completed_sessions' bl_label = 'Completed sessions' - + def execute(self, context): sce = context.scene ore = sce.ore_render bpy.queue_selected = 1 bpy.ore_active_session_queue = bpy.ore_completed_sessions update_session_list(completed_sessions, ore) - + return {'FINISHED'} class ORE_GetCancelledSessions(bpy.types.Operator): bl_idname = 'ore.cancelled_sessions' bl_label = 'Cancelled sessions' - + def execute(self, context): sce = context.scene ore = sce.ore_render bpy.queue_selected = 4 bpy.ore_active_session_queue = bpy.ore_cancelled_sessions update_session_list(cancelled_sessions, ore) - + return {'FINISHED'} class ORE_GetActiveSessions(bpy.types.Operator): bl_idname = 'ore.active_sessions' bl_label = 'Rendering sessions' - + def execute(self, context): sce = context.scene ore = sce.ore_render bpy.queue_selected = 2 bpy.ore_active_session_queue = bpy.ore_active_sessions update_session_list(active_sessions, ore) - + return {'FINISHED'} class ORE_GetPendingSessions(bpy.types.Operator): bl_idname = 'ore.accept_sessions' # using ORE lingo in API. acceptQueue is session waiting for admin approval bl_label = 'Pending sessions' - + def execute(self, context): sce = context.scene ore = sce.ore_render bpy.queue_selected = 3 bpy.ore_active_session_queue = bpy.ore_pending_sessions update_session_list(pending_sessions, ore) - + return {'FINISHED'} class ORE_CheckUpdate(bpy.types.Operator): bl_idname = 'ore.check_update' bl_label = 'Check for a new version' - + def execute(self, context): blenderproxy = xmlrpc.client.ServerProxy(r'http://xmlrpc.renderfarm.fi/renderfarmfi/blender', verbose=bpy.RFFI_VERBOSE) try: @@ -192,20 +192,20 @@ class ORE_CheckUpdate(bpy.types.Operator): except xmlrpc.client.ProtocolError as e: print('ERROR:', e) self.report({'ERROR'}, 'An HTTP error occurred while checking for newer version on Renderfarm.fi: ' + str(e.errcode) + ' ' + e.errmsg) - + return {'FINISHED'} class ORE_LoginOp(bpy.types.Operator): bl_idname = 'ore.login' bl_label = 'Login' - + def execute(self, context): sce = context.scene ore = sce.ore_render ore.password = ore.password.strip() ore.username = ore.username.strip() - + print("writing new credentials") _write_credentials(hashlib.md5(ore.password.encode() + ore.username.encode()).hexdigest(),ore.username) _read_credentials() @@ -213,13 +213,13 @@ class ORE_LoginOp(bpy.types.Operator): ore.username = '' bpy.loginInserted = False bpy.passwordCorrect = False - + try: _do_refresh(self, True) - + bpy.passwordCorrect = True bpy.loginInserted = True - + except LoginFailedException as v: bpy.ready = False bpy.loginInserted = False @@ -232,13 +232,13 @@ class ORE_LoginOp(bpy.types.Operator): self.report({'WARNING'}, "Incorrect login: " + str(v)) print(v) return {'CANCELLED'} - + return {'FINISHED'} class ORE_ResetOp(bpy.types.Operator): bl_idname = "ore.reset" bl_label = "Reset Preparation" - + def execute(self, context): sce = context.scene ore = sce.ore_render @@ -253,13 +253,13 @@ class ORE_ResetOp(bpy.types.Operator): ore.tags = '' ore.title = '' ore.url = '' - + return {'FINISHED'} class ORE_TestRenderOp(bpy.types.Operator): bl_idname = "ore.test_render" bl_label = "Run a test render" - + def execute(self, context): rd = context.scene.render rd.engine = 'BLENDER_RENDER' @@ -274,12 +274,12 @@ class ORE_TestRenderOp(bpy.types.Operator): class ORE_UploaderOp(bpy.types.Operator): bl_idname = "ore.upload" bl_label = "Render on Renderfarm.fi" - + def execute(self, context): - + bpy.uploadInProgress = True _prepare_scene() - + returnValue = _ore_upload(self, context) bpy.uploadInProgress = False return returnValue @@ -287,24 +287,24 @@ class ORE_UploaderOp(bpy.types.Operator): class ORE_UseBlenderReso(bpy.types.Operator): bl_idname = "ore.use_scene_settings" bl_label = "Use Scene settings" - + def execute(self, context): sce = context.scene ore = sce.ore_render rd = context.scene.render - + ore.resox = rd.resolution_x ore.resoy = rd.resolution_y ore.start = sce.frame_start ore.end = sce.frame_end ore.fps = rd.fps - + return {'FINISHED'} - + class ORE_UseCyclesRender(bpy.types.Operator): bl_idname = "ore.use_cycles_render" bl_label = "Cycles" - + def execute(self, context): context.scene.ore_render.engine = 'cycles' return {'FINISHED'} @@ -312,7 +312,7 @@ class ORE_UseCyclesRender(bpy.types.Operator): class ORE_UseBlenderRender(bpy.types.Operator): bl_idname = "ore.use_blender_render" bl_label = "Blender Internal" - + def execute(self, context): context.scene.ore_render.engine = 'blender' return {'FINISHED'} @@ -320,7 +320,7 @@ class ORE_UseBlenderRender(bpy.types.Operator): class ORE_ChangeUser(bpy.types.Operator): bl_idname = "ore.change_user" bl_label = "Change user" - + def execute(self, context): ore = context.scene.ore_render _write_credentials('', '') @@ -333,5 +333,15 @@ class ORE_ChangeUser(bpy.types.Operator): bpy.rffi_creds_found = False bpy.passwordCorrect = False bpy.loginInserted = False - + bpy.rffi_accepts = False + bpy.rffi_motd = '' + + return {'FINISHED'} + +class ORE_CheckStatus(bpy.types.Operator): + bl_idname = "ore.check_status" + bl_label = "Check Renderfarm.fi Accept status" + + def execute(self, context): + rffi.check_status() return {'FINISHED'} diff --git a/render_renderfarmfi/ore_session.py b/render_renderfarmfi/ore_session.py index fdbad807..0f8cc4ef 100644 --- a/render_renderfarmfi/ore_session.py +++ b/render_renderfarmfi/ore_session.py @@ -19,7 +19,7 @@ from math import floor class OreSession: - + def __init__(self, id, title): self.id = id self.title = title @@ -28,13 +28,13 @@ class OreSession: self.endframe = 0 self.rendertime = 0 self.percentage = 0 - + def percentageComplete(self): totFrames = self.endframe - self.startframe done = 0 if totFrames != 0: done = floor((self.frames / totFrames)*100) - + if done > 100: done = 100 return done diff --git a/render_renderfarmfi/panels.py b/render_renderfarmfi/panels.py index 4c011a45..117df785 100644 --- a/render_renderfarmfi/panels.py +++ b/render_renderfarmfi/panels.py @@ -27,54 +27,45 @@ class RenderButtonsPanel(): bl_space_type = 'PROPERTIES' bl_region_type = 'WINDOW' bl_context = "render" - # COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here + # COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here class EngineSelectPanel(RenderButtonsPanel, bpy.types.Panel): bl_idname = "OBJECT_PT_engineSelectPanel" bl_label = "Choose rendering mode" COMPAT_ENGINES = set(['RENDERFARMFI_RENDER']) - + def draw(self, context): layout = self.layout - rd = context.scene.render row = layout.row() row.operator("ore.switch_to_renderfarm_render", text="Renderfarm.fi", icon='WORLD') row.operator("ore.switch_to_local_render", text="Local computer", icon='BLENDER') -# row = layout.row() -# if (bpy.context.scene.render.engine == 'RENDERFARMFI_RENDER'): -# if bpy.found_newer_version == True: -# layout.operator('ore.open_download_location') -# else: -# if bpy.up_to_date == True: -# layout.label(text='You have the latest version') -# layout.operator('ore.check_update') - + class LOGIN_PT_RenderfarmFi(RenderButtonsPanel, bpy.types.Panel): bl_label = 'Login to Renderfarm.fi' COMPAT_ENGINES = set(['RENDERFARMFI_RENDER']) - + @classmethod def poll(cls, context): rd = context.scene.render return (rd.use_game_engine==False) and (rd.engine in cls.COMPAT_ENGINES) - + def draw(self, context): - # login + # login if not bpy.loginInserted: if _read_credentials(): try: if rffi.login(None, True, False): bpy.passwordCorrect = True bpy.loginInserted = True - except LoginFailedException as lfe: + except LoginFailedException: bpy.passwordCorrect = False bpy.loginInserted = False layout = self.layout ore = context.scene.ore_render check_status(ore) - + if bpy.passwordCorrect == False: row = layout.row() row.label(text="Email or password missing/incorrect", icon='ERROR') @@ -87,20 +78,28 @@ class LOGIN_PT_RenderfarmFi(RenderButtonsPanel, bpy.types.Panel): layout.label(text=bpy.rffi_user) layout.operator('ore.change_user') + layout.label(text='Message from Renderfarm.fi', icon='INFO') + layout.label(text=bpy.rffi_motd) + if bpy.rffi_accepting: + layout.label(text='Accepting sessions', icon='FILE_TICK') + else: + layout.label(text='Not accepting sessions', icon='ERROR') + layout.operator('ore.check_status') + class SESSIONS_PT_RenderfarmFi(RenderButtonsPanel, bpy.types.Panel): bl_label = 'My sessions' COMPAT_ENGINES = set(['RENDERFARMFI_RENDER']) - + @classmethod def poll(cls, context): rd = context.scene.render return (rd.use_game_engine==False) and (rd.engine in cls.COMPAT_ENGINES) - + def draw(self, context): ore = context.scene.ore_render if (bpy.passwordCorrect == True and bpy.loginInserted == True): layout = self.layout - + layout.template_list("UI_UL_list", "rederfarmfi_render", ore, 'all_sessions', ore, 'selected_session', rows=5) layout.operator('ore.cancel_session') if (bpy.cancelError == True): @@ -117,18 +116,21 @@ class SESSIONS_PT_RenderfarmFi(RenderButtonsPanel, bpy.types.Panel): class RENDER_PT_RenderfarmFi(RenderButtonsPanel, bpy.types.Panel): bl_label = "Settings" COMPAT_ENGINES = set(['RENDERFARMFI_RENDER']) - + @classmethod def poll(cls, context): rd = context.scene.render return (rd.use_game_engine==False) and (rd.engine in cls.COMPAT_ENGINES) - + def draw(self, context): layout = self.layout sce = context.scene ore = sce.ore_render - rd = sce.render - + + if not bpy.rffi_accepting: + layout.label(text="Renderfarm.fi is currently not accepting sessions.") + return + if (bpy.passwordCorrect == False or bpy.loginInserted == False): layout.label(text='You must login first') else: @@ -145,13 +147,13 @@ class RENDER_PT_RenderfarmFi(RenderButtonsPanel, bpy.types.Panel): layout.label(text="Example: blue skies hero castle flowers grass particles") layout.prop(ore, 'url') layout.label(text="Example: www.sintel.org") - + #layout.label(text="Please verify your settings", icon='MODIFIER') row = layout.row() row = layout.row() #row.operator('ore.copy_settings') #row = layout.row() - + layout.label(text="Rendering engine") row = layout.row() if (ore.engine == 'blender'): @@ -163,9 +165,9 @@ class RENDER_PT_RenderfarmFi(RenderButtonsPanel, bpy.types.Panel): else: row.operator('ore.use_blender_render', icon='FILE_TICK') row.operator('ore.use_cycles_render') - + row = layout.row() - + layout.separator() row = layout.row() row.prop(ore, 'resox') @@ -184,13 +186,13 @@ class RENDER_PT_RenderfarmFi(RenderButtonsPanel, bpy.types.Panel): #row.prop(ore, 'parts') layout.separator() row = layout.row() - + layout.label(text="Licenses", icon='FILE_REFRESH') row = layout.row() row.prop(ore, 'inlicense') row = layout.row() row.prop(ore, 'outlicense') - + check_status(ore) if (len(bpy.errors) > 0): bpy.ready = False @@ -200,17 +202,19 @@ class RENDER_PT_RenderfarmFi(RenderButtonsPanel, bpy.types.Panel): class UPLOAD_PT_RenderfarmFi(RenderButtonsPanel, bpy.types.Panel): bl_label = "Upload to www.renderfarm.fi" COMPAT_ENGINES = set(['RENDERFARMFI_RENDER']) - + @classmethod def poll(cls, context): rd = context.scene.render return (rd.use_game_engine==False) and (rd.engine in cls.COMPAT_ENGINES) - + def draw(self, context): layout = self.layout - sce = context.scene - ore = sce.ore_render - rd = sce.render + + if not bpy.rffi_accepting: + layout.label(text="Renderfarm.fi is currently not accepting sessions.") + return + if (bpy.passwordCorrect == False or bpy.loginInserted == False): layout.label(text="You must login first") else: @@ -224,9 +228,9 @@ class UPLOAD_PT_RenderfarmFi(RenderButtonsPanel, bpy.types.Panel): layout.label(text=" * No filter type composite nodes (blur, glare etc.)") layout.label(text=" * No SSS") layout.label(text=" * No Motion Blur") - + layout.separator() - + row = layout.row() if (bpy.uploadInProgress == True): layout.label(text="------------------------") diff --git a/render_renderfarmfi/prepare.py b/render_renderfarmfi/prepare.py index e59230de..67770635 100644 --- a/render_renderfarmfi/prepare.py +++ b/render_renderfarmfi/prepare.py @@ -125,15 +125,11 @@ def changeSettings(): bpy.childParticleWarning = False if (hasUnsupportedSimulation()): - simulationWarning = True + bpy.simulationWarning = True else: bpy.simulationWarning = False def _prepare_scene(): - sce = bpy.context.scene - rd = sce.render - ore = sce.ore_render - changeSettings() print("Packing external textures...") diff --git a/render_renderfarmfi/rpc.py b/render_renderfarmfi/rpc.py index 3d9642b9..c871f4be 100644 --- a/render_renderfarmfi/rpc.py +++ b/render_renderfarmfi/rpc.py @@ -18,10 +18,7 @@ import xmlrpc.client import imp -import traceback -import sys import time - import bpy from .exceptions import LoginFailedException, SessionCancelFailedException, \ @@ -39,11 +36,11 @@ def _is_dev(): user_creds = imp.load_module('rffi_dev', pwmod[0], pwmod[1], pwmod[2]) if 'dev' in dir(user_creds) and user_creds.dev: is_dev = True - except ImportError as e: + except ImportError: is_dev = False finally: if pwmod and pwmod[0]: pwmod[0].close() - except ImportError as e: + except ImportError: is_dev = False finally: if pwmod and pwmod[0]: pwmod[0].close() @@ -60,11 +57,11 @@ def _be_verbose(): user_creds = imp.load_module('rffi_dev', pwmod[0], pwmod[1], pwmod[2]) if 'verbose' in dir(user_creds) and user_creds.verbose: be_verbose = True - except ImportError as e: + except ImportError: be_verbose = False finally: if pwmod and pwmod[0]: pwmod[0].close() - except ImportError as e: + except ImportError: be_verbose = False finally: if pwmod and pwmod[0]: pwmod[0].close() @@ -193,4 +190,9 @@ class RffiRpc(object): bpy.errorStartTime = time.time() raise SessionCancelFailedException(str(v)) + def check_status(self): + res = self.proxy.service.motd() + bpy.rffi_accepts = res['accepting'] + bpy.rffi_motd = res['motd'] + rffi = RffiRpc() diff --git a/render_renderfarmfi/upload.py b/render_renderfarmfi/upload.py index 077da943..5bf28bed 100644 --- a/render_renderfarmfi/upload.py +++ b/render_renderfarmfi/upload.py @@ -19,7 +19,8 @@ import xmlrpc.client import http.client import hashlib -from os.path import isabs, isfile, join, exists +from os.path import isabs, isfile +import time import bpy @@ -33,15 +34,15 @@ def _random_string(length): def _encode_multipart_data(data, files): boundary = _random_string(30) - + def get_content_type(filename): return 'application/octet-stream' # default this - + def encode_field(field_name): return ('--' + boundary, 'Content-Disposition: form-data; name="%s"' % field_name, '', str(data[field_name])) - + def encode_file(field_name): filename = files [field_name] fcontent = None @@ -54,7 +55,7 @@ def _encode_multipart_data(data, files): 'Content-Disposition: form-data; name="%s"; filename="%s"' % (field_name, filename), 'Content-Type: %s' % get_content_type(filename), '', fcontent) - + lines = [] for name in data: lines.extend(encode_field(name)) @@ -63,12 +64,12 @@ def _encode_multipart_data(data, files): lines.extend(('--%s--' % boundary, '')) print("joining lines into body") body = '\r\n'.join(lines) - + headers = {'content-type': 'multipart/form-data; boundary=' + boundary, 'content-length': str(len(body))} print("headers and body ready") - + return body, headers def _send_post(data, files): @@ -108,7 +109,7 @@ def _upload_file(key, userid, sessionid, path): 'blenderfile': path } r = _send_post(data, files) - + return r def _run_upload(key, userid, sessionid, path): @@ -122,7 +123,7 @@ def _run_upload(key, userid, sessionid, path): def _ore_upload(op, context): sce = context.scene ore = sce.ore_render - + if not bpy.ready: op.report({'ERROR'}, 'Your user or scene information is not complete') bpy.infoError = True @@ -184,7 +185,7 @@ def _ore_upload(op, context): bpy.context.scene.render.engine = 'RENDERFARMFI_RENDER' print('Unhandled error:', e) op.report({'ERROR'}, 'A generic error occurred while sending submission to Renderfarm.fi') - + bpy.context.scene.render.engine = 'RENDERFARMFI_RENDER' _do_refresh(op) return {'FINISHED'} |