def _show_skin_in_model_viewer(self, row): skin_name = self.proxy.data(self.proxy.index(row, 0)) ac_name = self.proxy.data(self.proxy.index(row, 1)) mv_autoexec_cfg = Path(self._active_dcs_install.install_path).joinpath( 'Config', 'ModelViewer', 'autoexec.lua') mv_exe = Path(self._active_dcs_install.install_path).joinpath( 'bin', 'ModelViewer.exe') for f in mv_autoexec_cfg, mv_exe: if not f.exists(): logger.error('file not found: {}'.format(f.abspath())) return mount_lines = set() if self._active_dcs_install.autoexec_cfg: for vfs_path in self._active_dcs_install.autoexec_cfg.mounted_vfs_paths: mount_lines.add( 'mount_vfs_texture_path("{}")\n'.format(vfs_path)) backup_path = mv_autoexec_cfg.dirname().joinpath( 'autoexec.lua_EMFT_BACKUP') if not backup_path.exists(): logger.info('backing up "{}" -> "{}"'.format( mv_autoexec_cfg.abspath(), backup_path.abspath())) mv_autoexec_cfg.copy2(backup_path.abspath()) orig_lines = mv_autoexec_cfg.lines() lines = [] for line in orig_lines: if Config().allow_mv_autoexec_changes: if RE_MOUNT_LINE.match(line): # print('skipping', line) continue if RE_LOAD_MODEL_LINE.match(line): # print('skipping', line) continue if RE_LOAD_LIVERY_LINE.match(line): # print('skipping', line) continue lines.append(line) # model_path = 'LoadModel("Bazar/World/Shapes/{}.edm")'.format(self._active_dcs_install.get_object_model(ac_name)) lines.insert( 0, 'LoadLivery("{ac_name}","{skin_name}")'.format(**locals())) lines.insert( 0, 'LoadModel("Bazar/World/Shapes/{ac_name}.edm")'.format(**locals())) if Config().allow_mv_autoexec_changes: for line in mount_lines: lines.insert(0, line) mv_autoexec_cfg.write_lines(lines) os.startfile(mv_exe.abspath())
def mirror_dir(src, dst): logger.debug('{} -> {}'.format(src, dst)) diff_ = dircmp(src, dst, ignore) diff_list = diff_.left_only + diff_.diff_files logger.debug('differences: {}'.format(diff_list)) for x in diff_list: source = Path(diff_.left).joinpath(x) target = Path(diff_.right).joinpath(x) logger.debug('looking at: {}'.format(x)) if source.isdir(): logger.debug('isdir: {}'.format(x)) if not target.exists(): logger.debug('creating: {}'.format(x)) target.mkdir() mirror_dir(source, target) else: logger.debug('copying: {}'.format(x)) source.copy2(diff_.right) for sub in diff_.subdirs.values(): assert isinstance(sub, dircmp) mirror_dir(sub.left, sub.right)