Skip to content

Commit

Permalink
0.0.0正式版本
Browse files Browse the repository at this point in the history
修复了beta版本的解析错误问题,修复了计划任务设置问题,修复了Query程序查询顺序混乱的缺点。优化了解析逻辑与查询逻辑,优化了触发器选择,添加了计划清除功能,添加了新的输入支持格式,添加了自动格式化去重功能,重写了支持文档,新增了软件封装脚本
  • Loading branch information
X-MQSI committed Feb 9, 2024
1 parent 0829021 commit 637d815
Show file tree
Hide file tree
Showing 7 changed files with 260 additions and 156 deletions.
226 changes: 127 additions & 99 deletions Custom_GUI.py

Large diffs are not rendered by default.

29 changes: 23 additions & 6 deletions Custom_Query.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
mainly used for processing specified parameters and querying data.
Author: BY7030SWL and BG7ZCM
Date: 2024/02/08
Version: 0.0.0 beta
Date: 2024/02/09
Version: 0.0.0 formal_edition
LICENSE: GNU General Public License v3.0
"""

Expand All @@ -17,6 +17,8 @@
import subprocess
import json
import concurrent.futures
import tkinter as tk
from tkinter import messagebox
from configparser import ConfigParser

# 错误处置
Expand Down Expand Up @@ -45,10 +47,13 @@ def read_save_path(config):
try:
save_path = config["Path"]["SavePath"]
except KeyError:
print(f"#*Error*# 2: 配置文件中的存储路径可能存在错误。\n\n如果无法解决,请在我们的GitHub仓库提交issue。")
print("#*Error*# 2: 配置文件中的存储路径可能存在错误,没有找到 'Path' 或 'SavePath'\n\n如果无法解决,请在我们的GitHub仓库提交issue。")
GUI_jump()
# 如果这里出错,确保退出函数或提前返回一个默认值
return "default_save_path"
return save_path


# 读取NORAD表
def read_norad_ids(config):
try:
Expand Down Expand Up @@ -90,11 +95,13 @@ def query_satellite(norad_id, tle_list, satellite_names):
print(f"#*Error*# 6: 返回数据有误:{cleaned_text}\n\n如果无法解决,请在我们的GitHub仓库提交issue。")
GUI_jump()

# 将 TLE 和卫星名分别附加到相应的列表中
tle_list.append(cleaned_text)
satellite_names.append(lines[0])

else:
print(f"#*Error*# 7: HTTP请求失败,状态码: {response.status_code}\n\n如果无法解决,请在我们的GitHub仓库提交issue。")
messagebox.showinfo("HTTP请求失败", f"状态码: {response.status_code}\n\n如果无法解决,请在我们的GitHub仓库提交issue。")
GUI_jump()

except Exception as e:
Expand All @@ -105,26 +112,36 @@ def query_satellite(norad_id, tle_list, satellite_names):
def run_query_script_parallel(norad_ids=None):
config = read_config()
save_path = read_save_path(config)
tle_list = []
satellite_names = []

try:
if not norad_ids:
norad_ids = read_norad_ids(config)

# 创建每个线程独立的列表
tle_lists = [[] for _ in norad_ids]
satellite_names_lists = [[] for _ in norad_ids]

with concurrent.futures.ThreadPoolExecutor() as executor:
futures = [executor.submit(query_satellite, norad_id, tle_list, satellite_names) for norad_id in norad_ids]
# 将 tle_list 和 satellite_names 作为参数传递给 query_satellite 函数
futures = [executor.submit(query_satellite, norad_id, tle_list, satellite_names)
for norad_id, tle_list, satellite_names in zip(norad_ids, tle_lists, satellite_names_lists)]
concurrent.futures.wait(futures)

except Exception as e:
print(f"#*Error*# 9: 多线程查询时发生错误:{e}\n\n如果无法解决,请在我们的GitHub仓库提交issue。")
GUI_jump()

# 合并每个线程的结果
tle_list = [tle for tle_list in tle_lists for tle in tle_list]
satellite_names = [name for names_list in satellite_names_lists for name in names_list]

custom_file_name = config["FileName"].get("FileName", "")
save_tle_to_file(tle_list, save_path, custom_file_name)

print(satellite_names)
sys.exit()


# 主事件
if __name__ == "__main__":
if len(sys.argv) < 2:
Expand Down
41 changes: 41 additions & 0 deletions Software_packaging.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
:: 软件封装调试专用
::
:: Author: BY7030SWL and BG7ZCM
:: Date: 2024/02/09
:: Version: 0.0.0 formal_edition
:: LICENSE: GNU General Public License v3.0

CHCP 65001

pyinstaller --onefile --clean -F -w -i "UI/CelesTrak.ico" "Custom_Query.py"
pyinstaller --onefile --clean --uac-admin -F -w -i "UI/Custom 3LE.ico" "Custom_GUI.py"

move .\dist\Custom_GUI.exe .\
move .\dist\Custom_Query.exe .\

del Custom_GUI.spec
echo 已删除文件: Custom_GUI.spec

del Custom_Query.spec
echo 已删除文件: Custom_Query.spec

rmdir /s /q dist
echo 已删除目录: dist

rmdir /s /q build
echo 已删除目录: build

(
echo ;0.0.0 official version configuration file.
echo [Path]
echo.
echo [FileName]
echo filename = Custom.txt
echo.
echo [Update]
echo.
echo [NORAD_List]
) > date.ini

:: 打包完成后启动 Custom_GUI.exe
start Custom_GUI.exe
51 changes: 0 additions & 51 deletions Task_Scheduler.bat

This file was deleted.

68 changes: 68 additions & 0 deletions Task_Scheduler.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Task Scheduler module for Custom 3LE
# This module is mainly used to create scheduled tasks (temporary solutions),
# which will be integrated into the GUI program later.
#
# Author: BY7030SWL and BG7ZCM
# Date: 2024/02/08
# Version: 0.0.0 beta
# LICENSE: GNU General Public License v3.0

# 设置输出编码为 UTF-8
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8

# 任务名称
$TaskName = "Custom_3LE_Query"

# 可执行文件路径
$ExePath = "$PSScriptRoot\Custom_Query.exe"
Write-Host "$ExePath"

# 检查任务是否已存在
$taskExists = Get-ScheduledTask -TaskName $TaskName -ErrorAction SilentlyContinue
if ($taskExists) {
# 如果任务已存在,则注销它
Unregister-ScheduledTask -TaskName $TaskName -Confirm:$false
Start-Sleep -Seconds 2
}

# 检查是否提供了参数
if (-not $args) {
Write-Host "Please provide parameters!"
exit 1
} else {
# 如果参数是 "Remove",则只执行移除任务计划的操作
if ($args[0] -eq "Remove") {
Write-Host "Remove scheduled tasks..."
exit 0
}

# 根据提供的参数设置触发器
switch ($args[0]) {
"OnLogon" {
$trigger = New-ScheduledTaskTrigger -AtLogon
$location = "$PSScriptRoot"
}
"Daily" {
$trigger = New-ScheduledTaskTrigger -Daily -At 11am
$location = "$PSScriptRoot"
}
"Weekly" {
$trigger = New-ScheduledTaskTrigger -Weekly -DaysOfWeek Monday -At 11am
$location = "$PSScriptRoot"
}
"Monthly" {
$trigger = New-ScheduledTaskTrigger -Monthly -At 11am -Months 1
$location = "$PSScriptRoot"
}
default {
Write-Host "Invalid parameter!"
exit 1
}
}

# 创建 Action 对象
$action = New-ScheduledTaskAction -Execute "$ExePath" -WorkingDirectory $location

# 注册计划任务
Register-ScheduledTask -Action $action -Trigger $trigger -TaskName $TaskName
}
1 change: 1 addition & 0 deletions date.ini
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
; Configuration file, Version: 0.0.0 formal_edition
[Path]

[FileName]
Expand Down
Binary file added 使用教程.pdf
Binary file not shown.

0 comments on commit 637d815

Please sign in to comment.