Skip to content

Commit

Permalink
update spec file
Browse files Browse the repository at this point in the history
  • Loading branch information
greylink committed Dec 18, 2023
1 parent debbbd2 commit 44a436c
Show file tree
Hide file tree
Showing 7 changed files with 172 additions and 11 deletions.
Binary file added .gitattributes
Binary file not shown.
26 changes: 26 additions & 0 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
70 changes: 60 additions & 10 deletions ApLogTool.py
Original file line number Diff line number Diff line change
@@ -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


Expand All @@ -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("<Button-3>", 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)
Expand All @@ -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)
Expand Down Expand Up @@ -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("新建规则", "请输入新规则的名称:")
Expand All @@ -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': {
Expand Down
50 changes: 50 additions & 0 deletions ApLogTool.spec
Original file line number Diff line number Diff line change
@@ -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',
)
14 changes: 14 additions & 0 deletions Utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import os
import platform
import shutil
import tkinter as tk


def get_notepadpp_info():
if platform.system() != 'Windows':
Expand All @@ -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()
21 changes: 21 additions & 0 deletions log_rules.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 44a436c

Please sign in to comment.