def __init__(self): filedir = os.path.dirname( bpy.data.filepath) if bpy.data.filepath else os.getcwd() try: config = pman.get_config(filedir) user_config = pman.get_user_config( config['internal']['projectdir']) except pman.NoConfigError: config = None user_config = None self._tmpfnames = set() self.update_queue = queue.Queue() if user_config is not None and user_config['python']['in_venv']: pyprog = 'python' else: pyprog = pman.get_python_program(config) scriptloc = os.path.join(os.path.dirname(__file__), 'processor_app.py') with multiprocessing.connection.Listener() as listener: args = [ pyprog, scriptloc, filedir, str(listener.address), ] self.proc = subprocess.Popen(args) if self.proc.poll() is None: self.connection = listener.accept() self._running = True self.timer = threading.Thread(target=self._timer_thread) self.timer.start()
def update_blender_path(): try: startdir = os.path.dirname( bpy.data.filepath) if bpy.data.filepath else None user_config = pman.get_user_config(startdir) user_config['blender']['last_path'] = bpy.app.binary_path pman.write_user_config(user_config) except pman.NoConfigError: pass
def update_blender_path(): startdir = os.path.dirname( bpy.data.filepath) if bpy.data.filepath else None if pman.config_exists(startdir): user_config = pman.get_user_config(startdir) if 'blender' not in user_config: user_config['blender'] = {'use_last_path': True} user_config['blender']['last_path'] = bpy.app.binary_path pman.write_user_config(user_config)
def update_blender_path(): startdir = os.path.dirname(bpy.data.filepath) if bpy.data.filepath else None if pman.config_exists(startdir): user_config = pman.get_user_config(startdir) if 'blender' not in user_config: user_config['blender'] = { 'use_last_path': True } user_config['blender']['last_path'] = bpy.app.binary_path pman.write_user_config(user_config)
def execute(self, _context): pman.create_project(self.directory) config = pman.get_config(self.directory) user_config = pman.get_user_config(self.directory) from pman import hooks # pylint:disable=no-name-in-module hooks.create_blender(self.directory, config, user_config) if self.switch_dir: os.chdir(self.directory) update_blender_path() return {'FINISHED'}
def __init__(self): filedir = os.path.dirname(bpy.data.filepath) if bpy.data.filepath else os.getcwd() try: config = pman.get_config(filedir) user_config = pman.get_user_config(config['internal']['projectdir']) except pman.NoConfigError: config = None user_config = None self._tmpfnames = set() self.update_queue = queue.Queue() if user_config is not None and user_config['python']['in_venv']: pyprog = 'python' else: pyprog = pman.get_python_program(config) scriptloc = os.path.join( os.path.dirname(__file__), 'processor_app.py' ) with multiprocessing.connection.Listener() as listener: args = [ pyprog, scriptloc, filedir, str(listener.address), ] self.proc = subprocess.Popen(args) if self.proc.poll() is None: self.connection = listener.accept() self._running = True self.timer = threading.Thread(target=self._timer_thread) self.timer.start()
def test_venv_detect(projectdir): user_confg = pman.get_user_config() assert user_confg['python']['in_venv']
def execute(self, _context): filedir = os.path.dirname( bpy.data.filepath) if bpy.data.filepath else os.path.dirname( self.filepath) try: config = pman.get_config(filedir) except pman.NoConfigError as err: config = None if config: user_config = pman.get_user_config( config['internal']['projectdir']) else: user_config = None try: pycmd = pman.get_python_program(config) except pman.CouldNotFindPythonError as err: self.report({'ERROR'}, str(err)) return {'CANCELLED'} use_legacy_mats = (config is None or config['general']['material_mode'] == 'legacy') material_mode = 'legacy' if use_legacy_mats else 'pbr' # Check if we need to convert the file try: if self.skip_up_to_date and os.stat( bpy.data.filepath).st_mtime <= os.stat( self.filepath).st_mtime: print('"{}" is already up-to-date, skipping'.format( self.filepath)) return {'FINISHED'} except FileNotFoundError: # The file doesn't exist, so we cannot skip conversion pass # Create a temporary blend file to convert tmpfname = os.path.join(filedir, '__bp_temp__.blend') bpy.ops.wm.save_as_mainfile(filepath=tmpfname, copy=True) # Now convert the data to bam blend2bam_args = [ '--blender-dir', os.path.dirname(bpy.app.binary_path), '--material-mode', material_mode, ] blend2bam_args += [tmpfname, self.filepath] retval = {'FINISHED'} try: if user_config is not None and user_config['python']['in_venv']: # Use blend2bam from venv pman.run_program(config, ['blend2bam'] + blend2bam_args) else: # Use bundled blend2bam scriptloc = os.path.join(os.path.dirname(__file__), 'blend2bam_wrapper.py') args = [pycmd, scriptloc] + blend2bam_args if subprocess.call(args) != 0: retval = {'CANCELLED'} finally: # Remove the temporary blend file os.remove(tmpfname) return retval
def execute(self, _context): filedir = os.path.dirname(bpy.data.filepath) if bpy.data.filepath else os.path.dirname(self.filepath) try: config = pman.get_config(filedir) except pman.NoConfigError as err: config = None if config: user_config = pman.get_user_config(config['internal']['projectdir']) else: user_config = None try: pycmd = pman.get_python_program(config) except pman.CouldNotFindPythonError as err: self.report({'ERROR'}, str(err)) return {'CANCELLED'} use_legacy_mats = ( config is None or config['general']['material_mode'] == 'legacy' ) material_mode = 'legacy' if use_legacy_mats else 'pbr' # Check if we need to convert the file try: if self.skip_up_to_date and os.stat(bpy.data.filepath).st_mtime <= os.stat(self.filepath).st_mtime: print('"{}" is already up-to-date, skipping'.format(self.filepath)) return {'FINISHED'} except FileNotFoundError: # The file doesn't exist, so we cannot skip conversion pass # Create a temporary blend file to convert tmpfname = os.path.join(filedir, '__bp_temp__.blend') bpy.ops.wm.save_as_mainfile(filepath=tmpfname, copy=True) # Now convert the data to bam blend2bam_args = [ '--blender-dir', os.path.dirname(bpy.app.binary_path), '--material-mode', material_mode, ] blend2bam_args += [ tmpfname, self.filepath ] retval = {'FINISHED'} try: if user_config is not None and user_config['python']['in_venv']: # Use blend2bam from venv pman.run_program(config, ['blend2bam'] + blend2bam_args) else: # Use bundled blend2bam scriptloc = os.path.join( os.path.dirname(__file__), 'blend2bam_wrapper.py' ) args = [ pycmd, scriptloc ] + blend2bam_args if subprocess.call(args) != 0: retval = {'CANCELLED'} finally: # Remove the temporary blend file os.remove(tmpfname) return retval