From ccfb96be105602f010d5d9e2b582ae4c724f97c3 Mon Sep 17 00:00:00 2001 From: Yoshiko2 Date: Sat, 26 Feb 2022 05:13:02 +0800 Subject: [PATCH 1/5] Update main.yml --- .github/workflows/main.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b05c5fa..477451a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -39,10 +39,11 @@ jobs: run: | pyinstaller \ --onefile Movie_Data_Capture.py \ + --hidden-import "ImageProcessing.hog" \ --add-data "$(python -c 'import cloudscraper as _; print(_.__path__[0])' | tail -n 1):cloudscraper" \ --add-data "$(python -c 'import opencc as _; print(_.__path__[0])' | tail -n 1):opencc" \ + --add-data "$(python -c 'import face_recognition_models as _; print(_.__path__[0])' | tail -n 1):face_recognition_models" \ --add-data "Img:Img" \ - --add-data "ImageProcessing:ImageProcessing" \ --add-data "config.ini:." \ - name: Build with PyInstaller for windows @@ -50,10 +51,11 @@ jobs: run: | pyinstaller ` --onefile Movie_Data_Capture.py ` + --hidden-import "ImageProcessing.hog" ` --add-data "$(python -c 'import cloudscraper as _; print(_.__path__[0])' | tail -n 1);cloudscraper" ` --add-data "$(python -c 'import opencc as _; print(_.__path__[0])' | tail -n 1);opencc" ` + --add-data "$(python -c 'import face_recognition_models as _; print(_.__path__[0])' | tail -n 1):face_recognition_models" ` --add-data "Img;Img" ` - --add-data "ImageProcessing:ImageProcessing" ` --add-data "config.ini;." ` - name: Copy config.ini From 2b4e445f3b010a3e8f732a462856423547d5dd45 Mon Sep 17 00:00:00 2001 From: Yoshiko2 Date: Sat, 26 Feb 2022 05:14:28 +0800 Subject: [PATCH 2/5] Fix Image Processing module wrapper --- py_to_exe.ps1 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/py_to_exe.ps1 b/py_to_exe.ps1 index c3a41d6..498e7cd 100644 --- a/py_to_exe.ps1 +++ b/py_to_exe.ps1 @@ -3,13 +3,14 @@ $CLOUDSCRAPER_PATH=$(python -c 'import cloudscraper as _; print(_.__path__[0])' | select -Last 1) $OPENCC_PATH=$(python -c 'import opencc as _; print(_.__path__[0])' | select -Last 1) +$FACE_RECOGNITION_MODELS=$(python -c 'import face_recognition_models as _; print(_.__path__[0])' | select -Last 1) mkdir build mkdir __pycache__ pyinstaller --onefile Movie_Data_Capture.py ` - --hidden-import ADC_function.py ` - --hidden-import core.py ` + --hidden-import "ImageProcessing.hog" ` + --add-data "$FACE_RECOGNITION_MODELS;face_recognition_models" ` --add-data "$CLOUDSCRAPER_PATH;cloudscraper" ` --add-data "$OPENCC_PATH;opencc" ` --add-data "Img;Img" ` From 8e7cbd8fa6596a31501d9fe9650164c52c7dfdf2 Mon Sep 17 00:00:00 2001 From: Yoshiko2 Date: Sat, 26 Feb 2022 05:30:16 +0800 Subject: [PATCH 3/5] Update main.yml --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 477451a..34c2c61 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -54,7 +54,7 @@ jobs: --hidden-import "ImageProcessing.hog" ` --add-data "$(python -c 'import cloudscraper as _; print(_.__path__[0])' | tail -n 1);cloudscraper" ` --add-data "$(python -c 'import opencc as _; print(_.__path__[0])' | tail -n 1);opencc" ` - --add-data "$(python -c 'import face_recognition_models as _; print(_.__path__[0])' | tail -n 1):face_recognition_models" ` + --add-data "$(python -c 'import face_recognition_models as _; print(_.__path__[0])' | tail -n 1);face_recognition_models" ` --add-data "Img;Img" ` --add-data "config.ini;." ` From a3c8398f29829c24523124afaf79dde8573d2433 Mon Sep 17 00:00:00 2001 From: lededev Date: Sat, 26 Feb 2022 15:36:05 +0800 Subject: [PATCH 4/5] fix OpenCC not work --- WebCrawler/__init__.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/WebCrawler/__init__.py b/WebCrawler/__init__.py index 8d291db..63012cb 100644 --- a/WebCrawler/__init__.py +++ b/WebCrawler/__init__.py @@ -275,7 +275,7 @@ def get_data_from_json(file_number, oCC): if len(mapping_data.xpath('a[contains(@keyword, $name)]/@' + language, name=vars)) != 0: return mapping_data.xpath('a[contains(@keyword, $name)]/@' + language, name=vars)[0] else: - return vars + raise IndexError('keyword not found') for cc in cc_vars: if json_data[cc] == "" or len(json_data[cc]) == 0: continue @@ -303,20 +303,20 @@ def get_data_from_json(file_number, oCC): json_data[cc] = ADC_function.delete_all_elements_in_list("删除", json_data[cc]) elif ccm == 3: json_data[cc] = convert_list(info_mapping_data, "jp", json_data[cc]) - json_data[cc] = ADC_function.delete_list_all_elements("删除", json_data[cc]) + json_data[cc] = ADC_function.delete_all_elements_in_list("删除", json_data[cc]) except: json_data[cc] = [oCC.convert(t) for t in json_data[cc]] else: try: if ccm == 1: json_data[cc] = convert(info_mapping_data, "zh_cn", json_data[cc]) - json_data[cc] = ADC_function.delete_list_all_elements("删除", json_data[cc]) + json_data[cc] = ADC_function.delete_all_elements_in_list("删除", json_data[cc]) elif ccm == 2: json_data[cc] = convert(info_mapping_data, "zh_tw", json_data[cc]) - json_data[cc] = ADC_function.delete_list_all_elements("删除", json_data[cc]) + json_data[cc] = ADC_function.delete_all_elements_in_list("删除", json_data[cc]) elif ccm == 3: json_data[cc] = convert(info_mapping_data, "jp", json_data[cc]) - json_data[cc] = ADC_function.delete_list_all_elements("删除", json_data[cc]) + json_data[cc] = ADC_function.delete_all_elements_in_list("删除", json_data[cc]) except IndexError: json_data[cc] = oCC.convert(json_data[cc]) except: From c354518c571d37fb19ed2b194eba1c463b883cbf Mon Sep 17 00:00:00 2001 From: lededev Date: Sat, 26 Feb 2022 15:37:05 +0800 Subject: [PATCH 5/5] vscode debug AttributeError: 'NoneType' object has no attribute 'flush' or 'fileno' --- Movie_Data_Capture.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Movie_Data_Capture.py b/Movie_Data_Capture.py index 141a241..49501aa 100644 --- a/Movie_Data_Capture.py +++ b/Movie_Data_Capture.py @@ -113,9 +113,12 @@ class OutLogger(object): self.log.write(msg) def flush(self): - self.term.flush() - self.log.flush() - os.fsync(self.log.fileno()) + if 'flush' in dir(self.term): + self.term.flush() + if 'flush' in dir(self.log): + self.log.flush() + if 'fileno' in dir(self.log): + os.fsync(self.log.fileno()) def close(self): if self.term is not None: