From 44a436cece65c28c76d361245a899f7b8e69cdc0 Mon Sep 17 00:00:00 2001 From: T-lens <11454286+greylink@users.noreply.github.com> Date: Mon, 18 Dec 2023 10:44:06 +0800 Subject: [PATCH] update spec file --- .gitattributes | Bin 0 -> 42 bytes .github/workflows/python-app.yml | 26 ++++++++++++ .gitignore | 2 +- ApLogTool.py | 70 ++++++++++++++++++++++++++----- ApLogTool.spec | 50 ++++++++++++++++++++++ Utils.py | 14 +++++++ log_rules.ini | 21 ++++++++++ 7 files changed, 172 insertions(+), 11 deletions(-) create mode 100644 .gitattributes create mode 100644 .github/workflows/python-app.yml create mode 100644 ApLogTool.spec diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000000000000000000000000000000000000..713f7330977dacbcf6fab1cd4a9fe8de2029cf45 GIT binary patch literal 42 rcmezWPm4i;p@boop#n(SG9)sT0_l99SSpar0gB`>q%rU^a4`S?;*to7 literal 0 HcmV?d00001 diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml new file mode 100644 index 0000000..84ebd1f --- /dev/null +++ b/.github/workflows/python-app.yml @@ -0,0 +1,26 @@ + +name: Package Application with Pyinstaller + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Package Application + uses: JackMcKew/pyinstaller-action-windows@python3-10-pyinstaller-5-3 + with: + path: . + + - uses: actions/upload-artifact@v2 + with: + name: name-of-artifact + path: ./dist/windows diff --git a/.gitignore b/.gitignore index 3a0415c..ec26c8e 100644 --- a/.gitignore +++ b/.gitignore @@ -30,7 +30,7 @@ MANIFEST # Usually these files are written by a python script from a template # before PyInstaller builds the exe, so as to inject date/other infos into it. *.manifest -*.spec +#*.spec # Installer logs pip-log.txt diff --git a/ApLogTool.py b/ApLogTool.py index 612c388..5a794bf 100644 --- a/ApLogTool.py +++ b/ApLogTool.py @@ -1,9 +1,12 @@ import os import tkinter as tk -from tkinter import simpledialog, filedialog +from tkinter import simpledialog, filedialog, messagebox from tkinterdnd2 import TkinterDnD, DND_FILES from configparser import ConfigParser +from tkinter import Scrollbar +import threading import LogParser +from Utils import Toast from rules_config import CONFIG_FILE @@ -25,17 +28,20 @@ def __init__(self, master): self.config['settings'] = {'last_selected_folder': ''} # 创建按钮 - self.button_frame = tk.Frame(master) - self.button_frame.pack(pady=10) - self.buttons = {} self.current_rule_name = None # Initialize current_rule_name + # 创建带有滚动条的Canvas + self.canvas = tk.Canvas(master) + self.button_frame = tk.Frame(master) + self.canvas.create_window((0, 0), window=self.button_frame, anchor="nw") for rule_name in self.config['log_rules']: button = tk.Button(self.button_frame, text=rule_name, command=lambda name=rule_name: self.load_config_by_name(name)) - button.pack(side=tk.LEFT, padx=5) + button.bind("", lambda event, name=rule_name: self.show_context_menu(event, name)) # Bind right-click event self.buttons[rule_name] = button # Store the button reference + self.canvas.pack(pady=10) + # 新建规则 new_rule_button = tk.Button(master, text="新建规则", command=self.create_new_rule) new_rule_button.pack(pady=10) @@ -52,12 +58,12 @@ def __init__(self, master): # 获取最后一次选择的文件夹 self.last_selected_folder = self.config.get('settings', 'last_selected_folder', fallback='') # Add a button for file selection - select_file_button = tk.Button(master, text="Select File", command=self.select_file, width=28, height=4) + select_file_button = tk.Button(master, text="Select File", command=self.select_file, width=14, height=2) select_file_button.pack(pady=10) # 创建drop - self.file_label = tk.Label(self.master, text="Drop Files Here(no work)", relief=tk.SUNKEN, width=30, height=2) + self.file_label = tk.Label(self.master, text="Drop Files Here(no work)", relief=tk.SUNKEN, width=30, height=3) self.file_label.pack(pady=20) # 启用拖放功能 self.file_label.drop_target_register(DND_FILES) @@ -139,10 +145,20 @@ def handle_file(self, file_path): print(f"文件路径: {file_path}") if self.current_rule_name is not None: print("handle_filecurrent_rule_name = " + self.current_rule_name) - LogParser.process_logs(file_path, self.current_rule_name) + # messagebox.showinfo("文件处理开始", f"正在处理文件: {file_path}") + + threading.Thread(target=self.process_logs_in_background, args=(file_path,)).start() + else: print("未选择规则") - + + def process_logs_in_background(self, file_path): + toast = Toast(self.master, "文件处理...") + try: + LogParser.process_logs(file_path, self.current_rule_name) + finally: + toast.close + def create_new_rule(self): # 使用 tkinter.simpledialog 获取新规则的名称和配置 new_rule_name = tk.simpledialog.askstring("新建规则", "请输入新规则的名称:") @@ -166,11 +182,45 @@ def update_button_list(self): button.destroy() # 创建新按钮 + row_count = 0 + col_count = 0 + max_cols_per_row = 5 + for rule_name in self.config['log_rules']: button = tk.Button(self.button_frame, text=rule_name, command=lambda name=rule_name: self.load_config_by_name(name)) - button.pack(side=tk.LEFT, padx=5) + button.grid(row=row_count, column=col_count, padx=5, pady=5) self.buttons[rule_name] = button + col_count += 1 + if col_count >= max_cols_per_row: + col_count = 0 + row_count += 1 + + # 更新Canvas的大小 + self.canvas.update_idletasks() + self.canvas.config(scrollregion=self.canvas.bbox("all")) + + def show_context_menu(self, event, rule_name): + print("on show_context_menu") + menu = tk.Menu(self.master, tearoff=0) + menu.add_command(label="删除", command=lambda name=rule_name: self.delete_rule(name)) + menu.post(event.x_root, event.y_root) + + def delete_rule(self, rule_name): + # 从界面上删除按钮 + button = self.buttons.pop(rule_name, None) + if button: + button.destroy() + + # 从配置文件中删除规则 + if rule_name in self.config['log_rules']: + del self.config['log_rules'][rule_name] + # 保存更新后的配置到文件 + with open(CONFIG_FILE, 'w') as configfile: + self.config.write(configfile) + configfile.flush() + + def create_default_config(self): default_config = { 'settings': { diff --git a/ApLogTool.spec b/ApLogTool.spec new file mode 100644 index 0000000..a3efe92 --- /dev/null +++ b/ApLogTool.spec @@ -0,0 +1,50 @@ +# -*- mode: python ; coding: utf-8 -*- + + +block_cipher = None + + +a = Analysis( + ['ApLogTool.py'], + pathex=[], + binaries=[], + datas=[], + hiddenimports=[], + hookspath=[], + hooksconfig={}, + runtime_hooks=[], + excludes=[], + win_no_prefer_redirects=False, + win_private_assemblies=False, + cipher=block_cipher, + noarchive=False, +) +pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher) + +exe = EXE( + pyz, + a.scripts, + [], + exclude_binaries=True, + name='ApLogTool', + debug=True, + bootloader_ignore_signals=False, + strip=False, + upx=True, + console=True, + disable_windowed_traceback=False, + argv_emulation=False, + target_arch=None, + codesign_identity=None, + entitlements_file=None, +) +coll = COLLECT( + exe, + a.binaries, + a.zipfiles, + a.datas, + strip=False, + upx=True, + upx_exclude=[], + name='ApLogTool', +) diff --git a/Utils.py b/Utils.py index 24a6dc8..e29a37d 100644 --- a/Utils.py +++ b/Utils.py @@ -1,6 +1,8 @@ import os import platform import shutil +import tkinter as tk + def get_notepadpp_info(): if platform.system() != 'Windows': @@ -24,3 +26,15 @@ def get_notepadpp_info(): # 如果都没有找到,返回False和None return False, None +class Toast: + def __init__(self, root, text, duration=2000): + self.root = root + self.text = text + self.duration = duration + self.label = tk.Label(root, text=text) + self.label.pack() + self.label.place(relx=0.5, rely=0.9, anchor='s') + self.root.after(self.duration, self.close) + + def close(self): + self.label.destroy() \ No newline at end of file diff --git a/log_rules.ini b/log_rules.ini index 6919abf..750c575 100644 --- a/log_rules.ini +++ b/log_rules.ini @@ -3,6 +3,27 @@ call = ImsPhoneCallTracker|IMS_REGISTRATION_STATE|GET_CURRENT_CALLS|RequestManag mms = Mms-debug|MmsSmsProvider|Mms : sms = onSendSmsResult dddd = ddd +ss1 = ss +call1 = ImsPhoneCallTracker|IMS_REGISTRATION_STATE|GET_CURRENT_CALLS|RequestManager|RILJ|qcrilNr +mms1 = Mms-debug|MmsSmsProvider|Mms : +sms1 = onSendSmsResult +1dddd = ddd +2ss = ss +2call = ImsPhoneCallTracker|IMS_REGISTRATION_STATE|GET_CURRENT_CALLS|RequestManager|RILJ|qcrilNr +3mms = Mms-debug|MmsSmsProvider|Mms : +4sms = onSendSmsResult +5dddd = ddd +5ss = ss +6call = ImsPhoneCallTracker|IMS_REGISTRATION_STATE|GET_CURRENT_CALLS|RequestManager|RILJ|qcrilNr +6mms = Mms-debug|MmsSmsProvider|Mms : +6sms = onSendSmsResult +7dddd = ddd +7ss = ss +7call = ImsPhoneCallTracker|IMS_REGISTRATION_STATE|GET_CURRENT_CALLS|RequestManager|RILJ|qcrilNr +8mms = Mms-debug|MmsSmsProvider|Mms : +9sms = onSendSmsResult +0dddd = ddd +0ss = ss [settings] last_selected_folder = /home/ls/work/APLogTools