From 7b50f47332120af339317ba0174b465011fd2427 Mon Sep 17 00:00:00 2001
From: shuaikangzhou <863909694@qq.com>
Date: Mon, 13 Nov 2023 21:54:58 +0800
Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=97=A5=E5=BF=97=E6=A8=A1?=
=?UTF-8?q?=E5=9D=97?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.gitignore | 1 +
.idea/workspace.xml | 36 +++++++++++++++++------------
app/DataBase/output.py | 3 +++
app/Ui/chat/chat.py | 32 ++++++++-----------------
app/Ui/contact/analysis/analysis.py | 2 --
app/Ui/contact/analysis/charts.py | 18 +++++++++++----
app/Ui/contact/emotion/emotion.py | 3 +++
app/log/__init__.py | 3 +++
app/log/logger.py | 33 ++++++++++++++++++++++++++
doc/获取个人文件/使用说明.md | 8 +++----
10 files changed, 90 insertions(+), 49 deletions(-)
create mode 100644 app/log/__init__.py
create mode 100644 app/log/logger.py
diff --git a/.gitignore b/.gitignore
index 8dcb401..d8cc5fe 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,4 +11,5 @@ app/data/image2
app/data/emoji
*.db
*.pyc
+*.log
test*
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index e43bc2f..f8f2366 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,9 +4,15 @@
-
-
-
+
+
+
+
+
+
+
+
+
@@ -72,7 +78,7 @@
-
+
@@ -201,11 +207,11 @@
+
-
@@ -221,13 +227,6 @@
1672848140146
-
- 1673413541210
-
-
-
- 1673413541210
-
1674280781244
@@ -564,7 +563,14 @@
1699797493106
-
+
+ 1699797862964
+
+
+
+ 1699797862964
+
+
@@ -614,7 +620,6 @@
-
@@ -625,7 +630,8 @@
-
+
+
diff --git a/app/DataBase/output.py b/app/DataBase/output.py
index 259d91c..4af2363 100644
--- a/app/DataBase/output.py
+++ b/app/DataBase/output.py
@@ -14,6 +14,7 @@ from docxcompose.composer import Composer
from app import person
from app.DataBase import data
+from app.log import log
# import data
@@ -64,6 +65,7 @@ class Output(QThread):
self.output_type = type_
self.total_num = 0
+ @log
def merge_docx(self, conRemark, n):
origin_docx_path = f"{os.path.abspath('.')}/data/聊天记录/{conRemark}"
all_file_path = []
@@ -98,6 +100,7 @@ class Output(QThread):
self.okSignal.emit(1)
self.progressSignal.emit(self.i)
+ @log
def to_csv(self, conRemark, path):
origin_docx_path = f"{os.path.abspath('.')}/data/聊天记录/{conRemark}"
messages = data.get_all_message(self.ta_username)
diff --git a/app/Ui/chat/chat.py b/app/Ui/chat/chat.py
index 5b5ef22..068a8ff 100644
--- a/app/Ui/chat/chat.py
+++ b/app/Ui/chat/chat.py
@@ -8,6 +8,7 @@
@comment : 聊天窗口
"""
import time
+import traceback
from typing import Dict
import xmltodict
@@ -17,6 +18,7 @@ from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from app.Ui.MyComponents.Button_Contact import ContactUi
+from app.log import logger, log
from .chatUi import *
from ...DataBase import data
from ...ImageBox.ui import MainDemo
@@ -68,28 +70,6 @@ class ChatController(QWidget, Ui_Form):
self.message.setOpenExternalLinks(False)
# self.message.anchorClicked(self.hyperlink())
self.message.anchorClicked.connect(self.hyperlink)
- # self.btn_sendMsg = QtWidgets.QPushButton(self.textEdit)
- # self.btn_sendMsg.setGeometry(QtCore.QRect(1, 1, 121, 51))
- # font = QtGui.QFont()
- # font.setFamily("黑体")
- # font.setPointSize(15)
- # font.setBold(False)
- # font.setWeight(50)
- # self.btn_sendMsg.setFont(font)
- # self.btn_sendMsg.setCursor(QtGui.QCursor(QtCore.Qt.ArrowCursor))
- # self.btn_sendMsg.setMouseTracking(False)
- # self.btn_sendMsg.setAutoFillBackground(False)
- # self.btn_sendMsg.setStyleSheet("QPushButton {background-color: #f0f0f0;\n"
- # "padding: 10px;\n"
- # "color:rgb(5,180,104);}\n"
- # "QPushButton:hover{background-color: rgb(198,198,198)}\n"
- # )
- # self.btn_sendMsg.setIconSize(QtCore.QSize(40, 40))
- # self.btn_sendMsg.setCheckable(False)
- # self.btn_sendMsg.setAutoDefault(True)
- # self.btn_sendMsg.setObjectName("btn_sendMsg")
- # _translate = QtCore.QCoreApplication.translate
- # self.btn_sendMsg.setText(_translate("Dialog", "发送"))
self.btn_sendMsg_2.setToolTip('按Enter键发送,按Ctrl+Enter键换行')
def showChat(self):
@@ -204,6 +184,7 @@ class ChatController(QWidget, Ui_Form):
self.last_msg_time = msg_time
self.message.insertHtml(html)
+ @log
def showMsg(self, message):
"""
显示聊天消息
@@ -236,6 +217,7 @@ class ChatController(QWidget, Ui_Form):
self.pat_a_pat(content)
# self.message.moveCursor(self.message.textCursor().End)
+ @log
def pat_a_pat(self, content):
try:
pat_data = xmltodict.parse(content)
@@ -262,6 +244,7 @@ class ChatController(QWidget, Ui_Form):
''' % template
self.message.insertHtml(html)
+ @log
def show_recall_information(self, content):
html = '''
@@ -273,14 +256,15 @@ class ChatController(QWidget, Ui_Form):
''' % content
self.message.insertHtml(html)
+ @log
def show_emoji(self, isSend, imagePath, content):
imgPath = data.get_emoji(imagePath)
- print('emoji:', imgPath)
if not imgPath:
return False
try:
image = Image.open(imgPath)
except Exception as e:
+ logger.error(f"\nshow_emoji is error,here are details:\n{traceback.format_exc()}")
print(e)
return
imagePixmap = image.size # 宽高像素
@@ -303,6 +287,7 @@ class ChatController(QWidget, Ui_Form):
self.chatroom_left(html, username=username, style=style)
self.left(html, style=style)
+ @log
def show_img(self, isSend, imgPath, content):
'THUMBNAIL_DIRPATH://th_29cd0f0ca87652943be9ede365aabeaa'
# imgPath = imgPath.split('th_')[1]
@@ -325,6 +310,7 @@ class ChatController(QWidget, Ui_Form):
else:
self.left(html, style=style)
+ @log
def show_text(self, isSend, content):
if isSend:
html = '''
diff --git a/app/Ui/contact/analysis/analysis.py b/app/Ui/contact/analysis/analysis.py
index d24839b..abd2c6c 100644
--- a/app/Ui/contact/analysis/analysis.py
+++ b/app/Ui/contact/analysis/analysis.py
@@ -18,8 +18,6 @@ class AnalysisController(QWidget):
# self.setWindowFlag(Qt.FramelessWindowHint)
self.setStyleSheet('''QWidget{background-color:rgb(255, 255, 255);}''')
- # self.setBackground()
- # self.resize(400, 300)
self.center()
self.setAttribute(Qt.WA_AttributeCount)
self.label_01()
diff --git a/app/Ui/contact/analysis/charts.py b/app/Ui/contact/analysis/charts.py
index 0f1d89f..940a1c0 100644
--- a/app/Ui/contact/analysis/charts.py
+++ b/app/Ui/contact/analysis/charts.py
@@ -1,4 +1,5 @@
import os
+import traceback
import jieba
import pandas as pd
@@ -6,6 +7,7 @@ import xmltodict
from pyecharts import options as opts
from pyecharts.charts import Pie, WordCloud, Calendar, Bar, Line, Timeline, Grid
+from app.log import logger, log
from ....DataBase import data
# from app.DataBase import data
@@ -38,6 +40,7 @@ wordcloud_width = 780
wordcloud_height = 720
+@log
def send_recv_rate(username):
send_num = data.send_nums(username)
recv_num = data.recv_nums(username)
@@ -67,6 +70,7 @@ def send_recv_rate(username):
)
+@log
def msg_type_rate(username):
type_data = data.msg_type_num(username)
type_data = sorted(type_data, key=lambda x: x[1], reverse=True)
@@ -100,6 +104,7 @@ def msg_type_rate(username):
)
+@log
def message_word_cloud(username):
text = data.get_text(username)
total_msg_len = len(text)
@@ -132,6 +137,7 @@ def message_word_cloud(username):
)
+@log
def calendar_chart(username):
msg_data = data.get_msg_by_days(username, year='2022')
if not msg_data:
@@ -162,6 +168,7 @@ def calendar_chart(username):
)
+@log
def month_num(username):
"""
每月聊天条数
@@ -182,6 +189,7 @@ def month_num(username):
)
+@log
def chat_session(username):
msg_data = data.get_msg_by_hour(username)
x_axis = list(map(lambda x: x[0], msg_data))
@@ -219,6 +227,7 @@ def chat_session(username):
)
+@log
def sport(username):
sports = data.get_sport()
ranks = []
@@ -230,8 +239,8 @@ def sport(username):
rank_data = xmltodict.parse(content)
sub_data = rank_data['msg']['appmsg']['hardwareinfo']['messagenodeinfo']
# print(sub_data)
- my_rank = sub_data['rankinfo']['rank']['rankdisplay']
- my_steps = int(sub_data['rankinfo']['score']['scoredisplay'])
+ # my_rank = sub_data['rankinfo']['rank']['rankdisplay']
+ # my_steps = int(sub_data['rankinfo']['score']['scoredisplay'])
# print(f'rank: {my_rank},steps: {my_steps}')
rank_view = rank_data['msg']['appmsg']['hardwareinfo']['rankview']['rankinfolist']['rankinfo']
for userinfo in rank_view:
@@ -243,6 +252,7 @@ def sport(username):
steps.append(steps_ta)
date.append(t)
except:
+ logger.error(f"\nsport is error,here are details:\n{traceback.format_exc()}\n")
continue
try:
# todo 可能没有运动信息
@@ -349,6 +359,7 @@ def sport(username):
}
+@log
def chat_start_endTime(username):
start_time = data.get_msg_start_time(username)
end_time = data.get_msg_end_time(username)
@@ -431,11 +442,11 @@ setInterval(getRTime, 1000);