1 # ##### BEGIN GPL LICENSE BLOCK #####
3 # This program is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU General Public License
5 # as published by the Free Software Foundation; either version 2
6 # of the License, or (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software Foundation,
15 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 # ##### END GPL LICENSE BLOCK #####
23 from .utils
import _write_credentials
, _read_credentials
24 from .prepare
import _prepare_scene
25 from .upload
import _ore_upload
26 from .rpc
import rffi
, _do_refresh
27 from .exceptions
import LoginFailedException
, SessionCancelFailedException
29 class OpSwitchRenderfarm(bpy
.types
.Operator
):
30 bl_label
= "Switch to Renderfarm.fi"
31 bl_idname
= "ore.switch_to_renderfarm_render"
33 def execute(self
, context
):
34 ore
= bpy
.context
.scene
.ore_render
35 rd
= bpy
.context
.scene
.render
37 ore
.resox
= rd
.resolution_x
38 ore
.resoy
= rd
.resolution_y
40 ore
.start
= bpy
.context
.scene
.frame_start
41 ore
.end
= bpy
.context
.scene
.frame_end
42 if (rd
.engine
== 'CYCLES'):
43 ore
.samples
= bpy
.context
.scene
.cycles
.samples
46 ore
.engine
= 'blender'
47 bpy
.context
.scene
.render
.engine
= 'RENDERFARMFI_RENDER'
50 class OpSwitchBlenderRender(bpy
.types
.Operator
):
51 bl_label
= "Switch to local render"
52 bl_idname
= "ore.switch_to_local_render"
54 def execute(self
, context
):
55 rd
= bpy
.context
.scene
.render
56 ore
= bpy
.context
.scene
.ore_render
57 rd
.resolution_x
= ore
.resox
58 rd
.resolution_y
= ore
.resoy
60 bpy
.context
.scene
.frame_start
= ore
.start
61 bpy
.context
.scene
.frame_end
= ore
.end
62 if (bpy
.context
.scene
.ore_render
.engine
== 'cycles'):
64 bpy
.context
.scene
.cycles
.samples
= ore
.samples
66 bpy
.context
.scene
.render
.engine
= 'BLENDER_RENDER'
69 # Copies start & end frame + others from render settings to ore settings
70 class OpCopySettings(bpy
.types
.Operator
):
71 bl_label
= "Copy settings from current scene"
72 bl_idname
= "ore.copy_settings"
74 def execute(self
, context
):
75 sce
= bpy
.context
.scene
78 ore
.resox
= rd
.resolution_x
79 ore
.resoy
= rd
.resolution_y
80 ore
.start
= sce
.frame_start
81 ore
.end
= sce
.frame_end
85 class ORE_RefreshOp(bpy
.types
.Operator
):
86 bl_idname
= 'ore.refresh_session_list'
89 def execute(self
, context
):
90 result
= _do_refresh(self
)
96 class ORE_OpenDownloadLocation(bpy
.types
.Operator
):
97 bl_idname
= 'ore.open_download_location'
98 bl_label
= 'Download new version for your platform'
100 def execute(self
, context
):
102 webbrowser
.open(bpy
.download_location
)
105 class ORE_CancelSession(bpy
.types
.Operator
):
106 bl_idname
= 'ore.cancel_session'
107 bl_label
= 'Cancel Session'
109 def execute(self
, context
):
112 if len(bpy
.ore_complete_session_queue
)>0:
113 s
= bpy
.ore_complete_session_queue
[ore
.selected_session
]
115 rffi
.cancel_session(self
, s
)
116 except SessionCancelFailedException
as scfe
:
117 print("sessioncancelfailedexception", scfe
)
121 class ORE_GetCompletedSessions(bpy
.types
.Operator
):
122 bl_idname
= 'ore.completed_sessions'
123 bl_label
= 'Completed sessions'
125 def execute(self
, context
):
128 bpy
.queue_selected
= 1
129 bpy
.ore_active_session_queue
= bpy
.ore_completed_sessions
130 update_session_list(completed_sessions
, ore
)
134 class ORE_GetCancelledSessions(bpy
.types
.Operator
):
135 bl_idname
= 'ore.cancelled_sessions'
136 bl_label
= 'Cancelled sessions'
138 def execute(self
, context
):
141 bpy
.queue_selected
= 4
142 bpy
.ore_active_session_queue
= bpy
.ore_cancelled_sessions
143 update_session_list(cancelled_sessions
, ore
)
147 class ORE_GetActiveSessions(bpy
.types
.Operator
):
148 bl_idname
= 'ore.active_sessions'
149 bl_label
= 'Rendering sessions'
151 def execute(self
, context
):
154 bpy
.queue_selected
= 2
155 bpy
.ore_active_session_queue
= bpy
.ore_active_sessions
156 update_session_list(active_sessions
, ore
)
160 class ORE_GetPendingSessions(bpy
.types
.Operator
):
161 bl_idname
= 'ore.accept_sessions' # using ORE lingo in API. acceptQueue is session waiting for admin approval
162 bl_label
= 'Pending sessions'
164 def execute(self
, context
):
167 bpy
.queue_selected
= 3
168 bpy
.ore_active_session_queue
= bpy
.ore_pending_sessions
169 update_session_list(pending_sessions
, ore
)
173 class ORE_CheckUpdate(bpy
.types
.Operator
):
174 bl_idname
= 'ore.check_update'
175 bl_label
= 'Check for a new version'
177 def execute(self
, context
):
178 blenderproxy
= xmlrpc
.client
.ServerProxy(r
'http://xmlrpc.renderfarm.fi/renderfarmfi/blender', verbose
=bpy
.RFFI_VERBOSE
)
180 self
.report({'INFO'}, 'Checking for newer version on Renderfarm.fi')
181 dl_url
= blenderproxy
.blender
.getCurrentVersion(bpy
.CURRENT_VERSION
)
182 if len(dl_url
['url']) > 0:
183 self
.report({'INFO'}, 'Found a newer version on Renderfarm.fi ' + dl_url
['url'])
184 bpy
.download_location
= dl_url
['url']
185 bpy
.found_newer_version
= True
187 bpy
.up_to_date
= True
188 self
.report({'INFO'}, 'Done checking for newer version on Renderfarm.fi')
189 except xmlrpc
.client
.Fault
as f
:
191 self
.report({'ERROR'}, 'An error occurred while checking for newer version on Renderfarm.fi: ' + f
.faultString
)
192 except xmlrpc
.client
.ProtocolError
as e
:
194 self
.report({'ERROR'}, 'An HTTP error occurred while checking for newer version on Renderfarm.fi: ' + str(e
.errcode
) + ' ' + e
.errmsg
)
198 class ORE_LoginOp(bpy
.types
.Operator
):
199 bl_idname
= 'ore.login'
202 def execute(self
, context
):
206 ore
.password
= ore
.password
.strip()
207 ore
.username
= ore
.username
.strip()
209 print("writing new credentials")
210 _write_credentials(hashlib
.md5(ore
.password
.encode() + ore
.username
.encode()).hexdigest(),ore
.username
)
214 bpy
.loginInserted
= False
215 bpy
.passwordCorrect
= False
218 _do_refresh(self
, True)
220 bpy
.passwordCorrect
= True
221 bpy
.loginInserted
= True
223 except LoginFailedException
as v
:
225 bpy
.loginInserted
= False
226 bpy
.passwordCorrect
= False
227 ore
.username
= bpy
.rffi_user
228 _write_credentials('', '')
232 self
.report({'WARNING'}, "Incorrect login: " + str(v
))
238 class ORE_ResetOp(bpy
.types
.Operator
):
239 bl_idname
= "ore.reset"
240 bl_label
= "Reset Preparation"
242 def execute(self
, context
):
246 bpy
.loginInserted
= False
259 class ORE_TestRenderOp(bpy
.types
.Operator
):
260 bl_idname
= "ore.test_render"
261 bl_label
= "Run a test render"
263 def execute(self
, context
):
264 rd
= context
.scene
.render
265 rd
.engine
= 'BLENDER_RENDER'
266 rd
.threads_mode
= 'AUTO'
268 bpy
.ops
.render
.render()
269 rd
.threads_mode
= 'FIXED'
271 rd
.engine
= 'RENDERFARMFI_RENDER'
274 class ORE_UploaderOp(bpy
.types
.Operator
):
275 bl_idname
= "ore.upload"
276 bl_label
= "Render on Renderfarm.fi"
278 def execute(self
, context
):
280 bpy
.uploadInProgress
= True
283 returnValue
= _ore_upload(self
, context
)
284 bpy
.uploadInProgress
= False
287 class ORE_UseBlenderReso(bpy
.types
.Operator
):
288 bl_idname
= "ore.use_scene_settings"
289 bl_label
= "Use Scene settings"
291 def execute(self
, context
):
294 rd
= context
.scene
.render
296 ore
.resox
= rd
.resolution_x
297 ore
.resoy
= rd
.resolution_y
298 ore
.start
= sce
.frame_start
299 ore
.end
= sce
.frame_end
304 class ORE_UseCyclesRender(bpy
.types
.Operator
):
305 bl_idname
= "ore.use_cycles_render"
308 def execute(self
, context
):
309 context
.scene
.ore_render
.engine
= 'cycles'
312 class ORE_UseBlenderRender(bpy
.types
.Operator
):
313 bl_idname
= "ore.use_blender_render"
314 bl_label
= "Blender Internal"
316 def execute(self
, context
):
317 context
.scene
.ore_render
.engine
= 'blender'
320 class ORE_ChangeUser(bpy
.types
.Operator
):
321 bl_idname
= "ore.change_user"
322 bl_label
= "Change user"
324 def execute(self
, context
):
325 ore
= context
.scene
.ore_render
326 _write_credentials('', '')
329 bpy
.ore_sessions
= []
333 bpy
.rffi_creds_found
= False
334 bpy
.passwordCorrect
= False
335 bpy
.loginInserted
= False
336 bpy
.rffi_accepts
= False
341 class ORE_CheckStatus(bpy
.types
.Operator
):
342 bl_idname
= "ore.check_status"
343 bl_label
= "Check Renderfarm.fi Accept status"
345 def execute(self
, context
):