def execute(self, context: bpy.types.Context ) -> Set[str]: """Called when operator is called""" user_props = context.window_manager.tresorio_user_props if not user_props.is_logged: popup(TRADUCTOR['notif']['not_logged_in'] [CONFIG_LANG], icon='ERROR') return {'CANCELLED'} farms = bpy.context.window_manager.tresorio_farm_props farm_index = bpy.context.window_manager.tresorio_farm_props_index if farm_index < 0 or farm_index >= len(farms): popup(TRADUCTOR['notif']['choose_farm'][CONFIG_LANG], icon='ERROR') return {'FINISHED'} selected_farm = farms[farm_index] bpy.context.window_manager.tresorio_user_props.is_resuming_rendering = False render_index = context.window_manager.tresorio_renders_list_index render = context.window_manager.tresorio_renders_details[render_index] resume_render(render, farm_index) return {'FINISHED'}
def execute(self, context: bpy.types.Context ) -> Set[str]: """Called when operator is called""" user_props = context.window_manager.tresorio_user_props if not user_props.is_logged: popup(TRADUCTOR['notif']['not_logged_in'] [CONFIG_LANG], icon='ERROR') return {'CANCELLED'} if not bpy.data.is_saved or bpy.data.is_dirty: popup(TRADUCTOR['notif']['file_not_saved'] [CONFIG_LANG], icon='ERROR') return {'CANCELLED'} blend_path = bpy.data.filepath folder = context.scene.tresorio_render_form.project_folder project_name = bpy.path.clean_name(context.scene.tresorio_render_form.project_name) project = project_name + TRADUCTOR['field']['tresorio_suffix'][CONFIG_LANG] target_path = os.path.join(folder, project) if not os.path.exists(folder): alert(TRADUCTOR['notif']['doesnt_exist'][CONFIG_LANG].format(folder)) return {'CANCELLED'} if not os.path.isdir(folder): alert(TRADUCTOR['notif']['not_dir'][CONFIG_LANG].format(folder)) return {'CANCELLED'} if os.path.exists(target_path) and not os.path.isdir(target_path): alert(TRADUCTOR['notif']['pack_error'][CONFIG_LANG].format(project)) return {'CANCELLED'} new_upload(blend_path, target_path, project_name) return {'FINISHED'}
def draw(self, context): farms = bpy.context.window_manager.tresorio_farm_props index = bpy.context.window_manager.tresorio_farm_props_index rendering_mode = bpy.context.window_manager.tresorio_user_props.rendering_mode number_of_frames = bpy.context.scene.tresorio_render_form.number_of_frames layout = self.layout layout.label( text=TRADUCTOR['field']['rendering_summary'][CONFIG_LANG].format( rendering_mode, str(number_of_frames), ( 's' if number_of_frames > 1 else ''))) layout.separator() available_farms_count = functools.reduce( lambda acc, val: acc + val.is_available, farms, 0) if len(farms) == 0: layout.label(text=TRADUCTOR['field']['optimizing'][CONFIG_LANG]) else: if index >= 0 and index < len( farms) and not farms[index].is_available: bpy.context.window_manager.tresorio_farm_props_index = bpy.context.window_manager.tresorio_farm_props_old_index popup(TRADUCTOR['notif']['farm_not_available'][CONFIG_LANG], icon='ERROR') else: bpy.context.window_manager.tresorio_farm_props_old_index = index if available_farms_count == 0: layout.label( text=TRADUCTOR['field']['farms_unavailable'][CONFIG_LANG]) layout.label( text=TRADUCTOR['field']['servers_try_again'][CONFIG_LANG]) else: layout.label( text=TRADUCTOR['field']['select_farm'][CONFIG_LANG]) layout.separator() header = layout.box().split() if farms[0].gpu != 0: header.label(text="Gpu") header.label(text="Cpu") header.label(text="RAM") header.label(text=TRADUCTOR['field']['cost_per_hour'][CONFIG_LANG]) layout.template_list( 'OBJECT_UL_TRESORIO_FARMS_LIST', 'Farms_list', context.window_manager, 'tresorio_farm_props', context.window_manager, 'tresorio_farm_props_index', rows=1, maxrows=len(farms), ) layout.separator() layout.separator() row = layout.row() row.operator('tresorio.cancelrendering') if len(farms) != 0 and available_farms_count != 0: row.operator('tresorio.launchrendering')
def logout_if_unauthorized(err: ClientResponseError) -> None: """Log the user out if its cookie became invalid Arg: err: The error that appeared doing a request to the backend of Tresorio """ if err.status == HTTPStatus.UNAUTHORIZED: logout(bpy.context) popup(TRADUCTOR['notif']['expired_session'][CONFIG_LANG], icon='ERROR')
async def _update_list_renderings(cookie: str, silence_errors: bool = False) -> Coroutine: try: async with Platform() as plt: res_renders = await plt.req_list_renderings_details(cookie, jsonify=True) update_ui_renderings(res_renders, is_new=True) except Exception as err: BACKEND_LOGGER.error(err) if isinstance(err, ClientResponseError): logout_if_unauthorized(err) elif silence_errors is False: popup(TRADUCTOR['notif']['err_renders'][CONFIG_LANG], icon='ERROR')
async def _update_user_info(cookie: str, silence_errors: bool = False) -> Coroutine: async with Platform() as plt: try: res_user_info = await plt.req_get_user_info(cookie, jsonify=True) _get_user_info_callback(res_user_info) except Exception as err: BACKEND_LOGGER.error(err) if isinstance(err, ClientResponseError): logout_if_unauthorized(err) elif silence_errors is False: popup(TRADUCTOR['notif']['err_acc_info'][CONFIG_LANG], icon='ERROR')
async def _update_rendering(render: TresorioRendersDetailsProps, cookie: str) -> Coroutine: try: async with Platform() as plt: BACKEND_LOGGER.debug(f'Updating render {render.id}') render_details = await plt.req_get_rendering_details(cookie, render.id, jsonify=True) _fill_render_details(render, render_details) except Exception as err: BACKEND_LOGGER.error(err) popup(TRADUCTOR['notif']['err_render'][CONFIG_LANG], icon='ERROR') if isinstance(err, ClientResponseError): logout_if_unauthorized(err)
def execute(self, context: bpy.types.Context) -> Set[str]: """Called when operator is called""" user_props = context.window_manager.tresorio_user_props ip_address, port, https = user_props.backend_ip_address, user_props.backend_port, user_props.backend_https if ip_address == '': popup(TRADUCTOR['notif']['no_ip_address'][CONFIG_LANG], icon='ERROR') return {'CANCELLED'} new_url = "http" if https: new_url += 's' new_url += "://" + ip_address + ':' + port set_backend_url(new_url) bpy.context.window_manager.tresorio_user_props.advanced_settings = False return {'FINISHED'}
def execute(self, context: bpy.types.Context) -> Set[str]: """Called when operator is called""" context.window_manager.tresorio_user_props.is_launching_rendering = True user_props = context.window_manager.tresorio_user_props if not user_props.is_logged: popup(TRADUCTOR['notif']['not_logged_in'][CONFIG_LANG], icon='ERROR') return {'CANCELLED'} farms = bpy.context.window_manager.tresorio_farm_props index = bpy.context.window_manager.tresorio_farm_props_index if index < 0 or index >= len(farms): popup(TRADUCTOR['notif']['choose_farm'][CONFIG_LANG], icon='ERROR') return {'FINISHED'} selected_farm = farms[index] new_render() bpy.context.window_manager.tresorio_user_props.is_launching_rendering = False return {'FINISHED'}
async def _connect_to_tresorio(data: Dict[str, str]) -> Coroutine: async with Platform() as plt: try: bpy.context.window_manager.tresorio_report_props.login_in = True res = await plt.req_connect_to_tresorio(data, jsonify=False) session_cookie = res.cookies['connect.sid'].value bpy.context.window_manager.tresorio_user_props.cookie = session_cookie bpy.context.window_manager.tresorio_user_props.is_logged = True except Exception as err: bpy.context.window_manager.tresorio_report_props.login_in = False BACKEND_LOGGER.error(err) if isinstance(err, ClientResponseError): if err.status == HTTPStatus.UNAUTHORIZED: popup(TRADUCTOR['notif']['invalid_login'][CONFIG_LANG], icon='ERROR') else: popup(TRADUCTOR['notif']['err_connection'][CONFIG_LANG], icon='ERROR') else: bpy.context.window_manager.tresorio_report_props.login_in = False await _refresh_loop(session_cookie)
def execute(self, context: bpy.types.Context ) -> Set[str]: """Called when operator is called""" user_props = context.window_manager.tresorio_user_props email, password = user_props.email, get_password(user_props) context.window_manager.tresorio_user_props.hidden_password = reset_password( len(password)) context.window_manager.tresorio_user_props.clear_password = reset_password( len(password)) if user_props.is_logged: popup(TRADUCTOR['notif']['already_logged_in'] [CONFIG_LANG], icon='ERROR') return {'CANCELLED'} if email == '' and password == '': popup(TRADUCTOR['notif']['no_mail_password'] [CONFIG_LANG], icon='ERROR') return {'CANCELLED'} if email == '': popup(TRADUCTOR['notif']['no_mail'][CONFIG_LANG], icon='ERROR') return {'CANCELLED'} if password == '': popup(TRADUCTOR['notif']['no_password'][CONFIG_LANG], icon='ERROR') return {'CANCELLED'} if user_props.remember_email: USER_CONFIG['email'] = email USER_CONFIG['password'] = password else: USER_CONFIG['email'] = '' user_props.email = '' USER_CONFIG['password'] = '' user_props.email = '' user_props.hidden_password = '' user_props.clear_password = '' connect_to_tresorio(email, password) return {'FINISHED'}
def execute(self, context: bpy.types.Context) -> Set[str]: """Called when operator is called""" name = bpy.context.scene.tresorio_render_form.rendering_name is_name_already_taken = False for render in bpy.context.window_manager.tresorio_renders_details: if render.name == name: is_name_already_taken = True if len(name) == 0 or "/" in name or name.isspace(): popup(msg=TRADUCTOR['notif']['wrong_name'][CONFIG_LANG], icon='ERROR') return {'FINISHED'} elif is_name_already_taken == True: popup(msg=TRADUCTOR['notif']['render_name_already_taken'] [CONFIG_LANG].format(name.capitalize()), icon='ERROR') return {'FINISHED'} bpy.context.window_manager.tresorio_farm_props_index = -1 context.window_manager.tresorio_user_props.is_launching_rendering = True user_props = context.window_manager.tresorio_user_props number_of_frames = bpy.context.scene.frame_end - bpy.context.scene.frame_start + 1 if get_render_type() == RenderTypes.FRAME: number_of_frames = 1 bpy.context.scene.tresorio_render_form.number_of_frames = number_of_frames if not user_props.is_logged: popup(TRADUCTOR['notif']['not_logged_in'][CONFIG_LANG], icon='ERROR') return {'CANCELLED'} context.window_manager.tresorio_farm_props.clear() context.window_manager.tresorio_user_props.rendering_mode = 'CPU' get_farms('CPU', number_of_frames) return {'FINISHED'}