mirror of
https://github.com/LC044/WeChatMsg
synced 2025-02-22 19:02:17 +08:00
修复自定义词文件写入问题
This commit is contained in:
parent
a04a8e68e6
commit
1b901535ab
@ -350,18 +350,7 @@ class MainWinController(QMainWindow, mainwindow.Ui_MainWindow, QCursorGif):
|
|||||||
|
|
||||||
def set_my_info(self, wxid):
|
def set_my_info(self, wxid):
|
||||||
self.avatar = QPixmap()
|
self.avatar = QPixmap()
|
||||||
try:
|
|
||||||
img_bytes = misc_db.get_avatar_buffer(wxid)
|
img_bytes = misc_db.get_avatar_buffer(wxid)
|
||||||
except:
|
|
||||||
logger.error(f'数据库错误:\n{traceback.format_exc()}')
|
|
||||||
QMessageBox.critical(self, "数据库错误", "请重启电脑后重试")
|
|
||||||
close_db()
|
|
||||||
import shutil
|
|
||||||
try:
|
|
||||||
shutil.rmtree(DB_DIR)
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
return
|
|
||||||
if not img_bytes:
|
if not img_bytes:
|
||||||
return
|
return
|
||||||
if img_bytes[:4] == b'\x89PNG':
|
if img_bytes[:4] == b'\x89PNG':
|
||||||
@ -377,7 +366,7 @@ class MainWinController(QMainWindow, mainwindow.Ui_MainWindow, QCursorGif):
|
|||||||
shutil.rmtree(DB_DIR)
|
shutil.rmtree(DB_DIR)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
QMessageBox.critical(self, "数据库错误", "请重启电脑后重试")
|
QMessageBox.critical(self, "数据库错误", "数据库错误,请删除app文件夹后重启电脑再运行软件")
|
||||||
return
|
return
|
||||||
me = Me()
|
me = Me()
|
||||||
me.set_avatar(img_bytes)
|
me.set_avatar(img_bytes)
|
||||||
|
@ -250,17 +250,9 @@ class DecryptThread(QThread):
|
|||||||
import shutil
|
import shutil
|
||||||
if os.path.exists(target_database):
|
if os.path.exists(target_database):
|
||||||
os.remove(target_database)
|
os.remove(target_database)
|
||||||
try:
|
|
||||||
shutil.copy2(os.path.join(DB_DIR, 'MSG0.db'), target_database) # 使用一个数据库文件作为模板
|
shutil.copy2(os.path.join(DB_DIR, 'MSG0.db'), target_database) # 使用一个数据库文件作为模板
|
||||||
except FileNotFoundError:
|
|
||||||
logger.error(traceback.format_exc())
|
|
||||||
self.errorSignal.emit(True)
|
|
||||||
# 合并数据库
|
# 合并数据库
|
||||||
try:
|
|
||||||
merge_databases(source_databases, target_database)
|
merge_databases(source_databases, target_database)
|
||||||
except FileNotFoundError:
|
|
||||||
logger.error(traceback.format_exc())
|
|
||||||
QMessageBox.critical("错误", "数据库不存在\n请检查微信版本是否为最新")
|
|
||||||
|
|
||||||
# 音频数据库文件
|
# 音频数据库文件
|
||||||
target_database = os.path.join(DB_DIR, 'MediaMSG.db')
|
target_database = os.path.join(DB_DIR, 'MediaMSG.db')
|
||||||
@ -268,17 +260,10 @@ class DecryptThread(QThread):
|
|||||||
if os.path.exists(target_database):
|
if os.path.exists(target_database):
|
||||||
os.remove(target_database)
|
os.remove(target_database)
|
||||||
source_databases = [os.path.join(DB_DIR, f"MediaMSG{i}.db") for i in range(1, 50)]
|
source_databases = [os.path.join(DB_DIR, f"MediaMSG{i}.db") for i in range(1, 50)]
|
||||||
try:
|
|
||||||
shutil.copy2(os.path.join(DB_DIR, 'MediaMSG0.db'), target_database) # 使用一个数据库文件作为模板
|
shutil.copy2(os.path.join(DB_DIR, 'MediaMSG0.db'), target_database) # 使用一个数据库文件作为模板
|
||||||
except FileNotFoundError:
|
|
||||||
logger.error(traceback.format_exc())
|
|
||||||
self.errorSignal.emit(True)
|
|
||||||
# 合并数据库
|
# 合并数据库
|
||||||
try:
|
|
||||||
merge_MediaMSG_databases(source_databases, target_database)
|
merge_MediaMSG_databases(source_databases, target_database)
|
||||||
except FileNotFoundError:
|
|
||||||
logger.error(traceback.format_exc())
|
|
||||||
QMessageBox.critical("错误", "数据库不存在\n请检查微信版本是否为最新")
|
|
||||||
self.okSignal.emit('ok')
|
self.okSignal.emit('ok')
|
||||||
# self.signal.emit('100')
|
# self.signal.emit('100')
|
||||||
|
|
||||||
|
@ -122,11 +122,11 @@ class SettingControl(QWidget, Ui_Form):
|
|||||||
f.write(stopwords)
|
f.write(stopwords)
|
||||||
if os.path.exists('./app/data/new_words.txt'):
|
if os.path.exists('./app/data/new_words.txt'):
|
||||||
with open('./app/data/new_words.txt', 'r', encoding='utf-8') as f:
|
with open('./app/data/new_words.txt', 'r', encoding='utf-8') as f:
|
||||||
stopwords = set(f.read().splitlines())
|
new_words = set(f.read().splitlines())
|
||||||
self.plainTextEdit_newword.setPlainText(' '.join(new_words))
|
self.plainTextEdit_newword.setPlainText(' '.join(new_words))
|
||||||
else:
|
else:
|
||||||
self.plainTextEdit_newword.setPlainText(' '.join(new_words))
|
self.plainTextEdit_newword.setPlainText(' '.join(new_words))
|
||||||
stopwords = '\n'.join(stopwords)
|
stopwords = '\n'.join(new_words)
|
||||||
with open('./app/data/new_words.txt', 'w', encoding='utf-8') as f:
|
with open('./app/data/new_words.txt', 'w', encoding='utf-8') as f:
|
||||||
f.write(stopwords)
|
f.write(stopwords)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user