Skip to content

Commit

Permalink
pyinstaller bugs fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
hokejyo committed Apr 11, 2022
1 parent 90d8b21 commit 96d80a0
Show file tree
Hide file tree
Showing 11 changed files with 39 additions and 27 deletions.
5 changes: 5 additions & 0 deletions Core/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,3 +148,8 @@ def pool_run(workers, target, runs, *args) -> list:
pool.close()
pool.join()
return [processer.get() for processer in processer_ls]


def show_folder(folder_path):
folder_path = Path(folder_path)
_p = subprocess.run(['start', folder_path], capture_output=True, shell=True)
4 changes: 2 additions & 2 deletions Core/image_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,13 +200,13 @@ def image_upscale(self,
self._palette_png_pre_(tmp_image_file)
# 放大tmp1到tmp2
options, step_scale_ratio = self._get_options_and_step_scale_ratio(img_tmp_folder1, img_tmp_folder2, sr_engine)
image_upscale_p = subprocess.run(options, capture_output=True)
image_upscale_p = subprocess.run(options, capture_output=True, shell=True)
actual_scale_ratio = step_scale_ratio
# 未达指定倍数循环放大
while actual_scale_ratio < scale_ratio:
img_tmp_folder2.move_as(img_tmp_folder1)
img_tmp_folder2.mk_dir(parents=True, exist_ok=True)
image_upscale_p = subprocess.run(options, capture_output=True)
image_upscale_p = subprocess.run(options, capture_output=True, shell=True)
actual_scale_ratio *= step_scale_ratio
tmp_image_ls = img_tmp_folder2.file_list()
# 缩放
Expand Down
8 changes: 4 additions & 4 deletions Core/video_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def video_info(self, input_video) -> dict or bool:
'-of', 'json',
input_video
]
get_video_info_p = subprocess.run(options, capture_output=True)
get_video_info_p = subprocess.run(options, capture_output=True, shell=True)
unsort_video_info = json.loads(get_video_info_p.stdout.decode('utf-8'))
# 非常规编码视频返回空字典
if not unsort_video_info or len(unsort_video_info['streams']) == 0:
Expand Down Expand Up @@ -69,7 +69,7 @@ def vcodec_trans(self, input_video, output_video, output_vcodec):
'-q:v', self.output_video_quality(output_vcodec),
output_video
]
format_trans_p = subprocess.run(options, capture_output=True)
format_trans_p = subprocess.run(options, capture_output=True, shell=True)
return output_video

def video2png(self, input_video, output_folder):
Expand All @@ -95,7 +95,7 @@ def video2png(self, input_video, output_folder):
'-threads', str(self.cpu_cores),
png_sequence
]
video2png_p = subprocess.run(options, capture_output=True)
video2png_p = subprocess.run(options, capture_output=True, shell=True)
return png_sequence

def output_video_quality(self, output_vcodec) -> str:
Expand Down Expand Up @@ -148,7 +148,7 @@ def png2video(self, png_sequence, origin_video, output_video, output_vcodec=None
'-threads', str(self.cpu_cores),
output_video
]
png2video_p = subprocess.run(options, capture_output=True)
png2video_p = subprocess.run(options, capture_output=True, shell=True)
return output_video

def video_upscale(self, input_video, output_video, scale_ratio=2.0, output_vcodec=None):
Expand Down
9 changes: 6 additions & 3 deletions GUI/image_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ def __init__(self):
def initUI(self):
self.setup_layouts()
self.setup_connections()
add_shadow(self.list_widget)
add_shadow(self.image_show_label)
add_shadow(self.setting_frame)
# add_shadow(self.list_widget)
# add_shadow(self.image_show_label)
# add_shadow(self.setting_frame)

def setup_connections(self):
self.input_line_edit.editingFinished.connect(self.get_image_list)
Expand Down Expand Up @@ -47,6 +47,7 @@ def setup_layouts(self):

def setup_settings(self):
self.setting_frame = QFrame()
self.setting_frame.setStyleSheet('background-color:#456')
self.hlayout.addWidget(self.setting_frame)
self.set_formlayout = QFormLayout(self.setting_frame)

Expand Down Expand Up @@ -78,10 +79,12 @@ def setup_settings(self):

def setup_image_list_view(self):
self.list_widget = QListWidget()
self.list_widget.setStyleSheet('background-color:#456')
self.hlayout.addWidget(self.list_widget)

def setup_show_image_area(self):
self.image_show_label = QLabel()
self.image_show_label.setStyleSheet('background-color:#456')
self.image_show_label.setMinimumWidth(540)
self.image_show_label.setMinimumHeight(360)
self.layout.addWidget(self.image_show_label)
Expand Down
2 changes: 1 addition & 1 deletion GUI/info_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@ def setup_update_bug(self):
self.tab_view.addTab(self.update_bug_frame, '更新&&反馈')

layout = QVBoxLayout(self.update_bug_frame)
self.check_update_btn = FPushButton('检查更新')
self.check_update_btn = FIconButton('检查更新')
layout.addWidget(self.check_update_btn)
2 changes: 1 addition & 1 deletion GUI/main_content.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def setup_layouts(self):
def setup_top_bar(self):
# 顶部标题栏
self.top_bar = QFrame()
# 设置高度、背景颜色
# 设置高度
self.top_bar.setMinimumHeight(40)
self.top_bar.setMaximumHeight(40)
self.top_bar_layout = QHBoxLayout(self.top_bar)
Expand Down
3 changes: 2 additions & 1 deletion GamePageUIConnection.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ def finish_game_page_runner_and_unlock(self, info_str=''):
self.ui.gamepage.info_text_edit.append(format('结束处理', '=^76'))
finish_info_msg = QMessageBox()
reply = finish_info_msg.information(self.ui, '处理完成', f'{info_str}\n是否打开输出文件夹?', QMessageBox.Yes | QMessageBox.No, QMessageBox.Yes)
os.system(f'start {self.output_folder}') if reply == QMessageBox.Yes else None
show_folder(self.output_folder) if reply == QMessageBox.Yes else None
# os.system(f'start {self.output_folder}') if reply == QMessageBox.Yes else None

def crash_game_page_runner_and_unlock(self, info_str):
self.ui.gamepage.set_running_state(0)
Expand Down
Binary file added Icons/icon.ico
Binary file not shown.
3 changes: 2 additions & 1 deletion ImagePageUIConnection.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ def finish_image_page_runner_and_unlock(self, info_str=''):
self.emit_info(format('结束处理', '=^76'))
finish_info_msg = QMessageBox()
reply = finish_info_msg.information(self.ui, '处理完成', f'{info_str}\n是否打开输出文件夹?', QMessageBox.Yes | QMessageBox.No, QMessageBox.Yes)
os.system(f'start {self.output_folder}') if reply == QMessageBox.Yes else None
show_folder(self.output_folder) if reply == QMessageBox.Yes else None
# os.system(f'start {self.output_folder}') if reply == QMessageBox.Yes else None

def crash_image_page_runner_and_unlock(self, info_str):
self.ui.imagepage.set_running_state(0)
Expand Down
29 changes: 15 additions & 14 deletions VNEngines/Kirikiri/kirikiri.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,9 +316,9 @@ def asd2x(self):
'''
asd_keyword_list = ['clipleft', 'cliptop', 'clipwidth', 'clipheight', 'left',
'top', 'height', 'weight', 'dx', 'dy', 'dw', 'dh', 'sx', 'sy', 'sw', 'sh', 'x', 'y']
asd_file_ls = patch9_first(self.game_data.file_list('asd'))
# asd_file_ls = patch9_first(self.game_data.file_list('asd'))
# 忽略人物表情处理,这东西不需要改,改了反而不正常
# asd_file_ls = patch9_first(self.game_data.file_list('asd', ignored_folders=['emotion', 'emotions', 'Emotion', 'Emotions', 'anim']))
asd_file_ls = patch9_first(self.game_data.file_list('asd', ignored_folders=['emotion', 'emotions', 'Emotion', 'Emotions', 'anim']))
for asd_file in asd_file_ls:
result = []
lines, current_encoding = self.get_lines_encoding(asd_file)
Expand Down Expand Up @@ -362,7 +362,7 @@ def scn2x(self):
[scn_file.move_as(self.t2p(scn_file)) for scn_file in scaled_scn_file_ls]

def scn_de(self, scn_file):
scn_de_p = subprocess.run([self.psb_de_exe, scn_file], capture_output=True)
scn_de_p = subprocess.run([self.psb_de_exe, scn_file], capture_output=True, shell=True)

def scn_en(self, scn_json_file):
output_folder = scn_json_file.parent
Expand Down Expand Up @@ -529,8 +529,8 @@ def _general_image2x(self):
'''
image_extension_ls = ['bmp', 'jpg', 'jpeg', 'png', 'webp']
for image_extension in image_extension_ls:
image_file_list = patch9_first(self.game_data.file_list(image_extension))
# image_file_list = patch9_first(self.game_data.file_list(image_extension, ignored_folders=['sysscn', 'fgimage', 'emotion', 'emotions', 'Emotion', 'Emotions', 'anim']))
# image_file_list = patch9_first(self.game_data.file_list(image_extension))
image_file_list = patch9_first(self.game_data.file_list(image_extension, ignored_folders=['sysscn', 'fgimage', 'emotion', 'emotions', 'Emotion', 'Emotions', 'anim']))
if image_file_list:
with tempfile.TemporaryDirectory() as tmp_folder:
self.tmp_folder = Path(tmp_folder)
Expand Down Expand Up @@ -589,7 +589,7 @@ def _pimg_de(self, pimg_out_path) -> Path:
pimg_tmp_folder = Path(pimg_tmp_folder)
tmp_pimg = pimg_file.copy_to(pimg_tmp_folder)
# 拆分pimg文件到pimg文件所在目录
pimg_de_p = subprocess.run([self.psb_de_exe, tmp_pimg], capture_output=True)
pimg_de_p = subprocess.run([self.psb_de_exe, tmp_pimg], capture_output=True, shell=True)
tmp_png_folder = tmp_pimg.with_suffix('')
tmp_png_folder.move_to(output_dir)
tmp_json_file1 = tmp_pimg.with_suffix('.json')
Expand Down Expand Up @@ -660,8 +660,8 @@ def _tlg2x(self):
'''
对tlg格式图片进行放大处理
'''
ori_tlg_file_ls = patch9_first(self.game_data.file_list('tlg'))
# ori_tlg_file_ls = patch9_first(self.game_data.file_list('tlg', ignored_folders=['fgimage', 'emotion', 'emotions', 'Emotion', 'Emotions', 'anim']))
# ori_tlg_file_ls = patch9_first(self.game_data.file_list('tlg'))
ori_tlg_file_ls = patch9_first(self.game_data.file_list('tlg', ignored_folders=['fgimage', 'emotion', 'emotions', 'Emotion', 'Emotions', 'anim']))
if ori_tlg_file_ls:
with tempfile.TemporaryDirectory() as tmp_folder:
self.tmp_folder = Path(tmp_folder)
Expand Down Expand Up @@ -704,7 +704,7 @@ def _tlg2png(self, tlg_png_path) -> Path:
将tlg图片转化为png格式
'''
tlg_file, png_file = tlg_png_path
tlg2png_p = subprocess.run([self.tlg2png_exe, tlg_file, png_file], capture_output=True)
tlg2png_p = subprocess.run([self.tlg2png_exe, tlg_file, png_file], capture_output=True, shell=True)
return png_file

def png2tlg_batch(self, input_path, output_folder, tlg5_mode=False) -> list:
Expand Down Expand Up @@ -737,8 +737,9 @@ def png2tlg_batch(self, input_path, output_folder, tlg5_mode=False) -> list:
png_file.copy_as(tmp_png)
tmp_target_dict[tmp_png] = target_tlg
self.emit_info('请将弹出文件夹中的png图片拖入吉里吉里图像转换器窗口\n不要修改选项,确认处理完成后关闭吉里吉里图像转换器')
os.system(f'start {tlg_tmp_folder}')
os.system(str(self.krkrtpc_exe))
show_folder(tlg_tmp_folder)
_p = subprocess.run([self.krkrtpc_exe,], capture_output=True, shell=True)
# os.system(str(self.krkrtpc_exe))
output_tlg_file_ls = []
for tmp_png, target_tlg in tmp_target_dict.items():
tmp_tlg = tmp_png.with_suffix('.tlg')
Expand All @@ -753,7 +754,7 @@ def _png2tlg6(self, png_tlg_path) -> Path:
将png图片转化为tlg6格式,适用于krkr2.24及以上版本
'''
png_file, tlg_file = png_tlg_path
png2tlg6_p = subprocess.run([self.png2tlg6_exe, png_file, tlg_file], capture_output=True)
png2tlg6_p = subprocess.run([self.png2tlg6_exe, png_file, tlg_file], capture_output=True, shell=True)
return tlg_file

def tlg2tlg_batch(self, input_path, output_folder, tlg5_mode=False) -> list:
Expand Down Expand Up @@ -843,7 +844,7 @@ def _amv_de(self, amv_tuple) -> Path:
tmp_amv = amv_tuple[0]
tmp_amv_dir = amv_tuple[1][0]
target_amv_dir = amv_tuple[1][1]
amv_de_p = subprocess.run([self.amv_de_exe, '-amvpath='+tmp_amv.to_str], capture_output=True)
amv_de_p = subprocess.run([self.amv_de_exe, '-amvpath='+tmp_amv.to_str], capture_output=True, shell=True)
amv_file_info = self._get_amv_file_info(tmp_amv)
result = json.dumps(amv_file_info, sort_keys=False, indent=2, ensure_ascii=False)
tmp_amv.unlink()
Expand Down Expand Up @@ -880,7 +881,7 @@ def _amv_en(self, amv_dict_item):
'--quality', '100',
tmp_folder, tmp_amv
]
amv_en_p = subprocess.run(options, capture_output=True)
amv_en_p = subprocess.run(options, capture_output=True, shell=True)
# 改名
tmp_amv.move_as(target_amv)
return target_amv
Expand Down
1 change: 1 addition & 0 deletions VisualNovelUpscaler.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,6 @@ def catch_exceptions(self, excType, excValue, tb):
# 启动
app = QApplication(sys.argv)
visual_novel_upscaler = VisualNovelUpscaler()
visual_novel_upscaler.ui.setWindowIcon(QIcon(str(bundle_dir/'Icons'/'icon.ico')))
visual_novel_upscaler.ui.show()
sys.exit(app.exec())

0 comments on commit 96d80a0

Please sign in to comment.