自动压缩的脚本

This commit is contained in:
naibo 2023-07-01 04:48:06 +08:00
parent 199af8ac40
commit 71c751a8cd
15 changed files with 118 additions and 14 deletions

View File

@ -2,7 +2,7 @@ To open the EasySpider, please open your terminal, and then type:
./easy-spider.sh ./easy-spider.sh
Then EasySpider will be opened, and don't close the terminal when running EasySpider. Then EasySpider will be opened, and don't close the terminal when running EasySpider.
Official Site: https://github.com/NaiboWang/EasySpider Official Site: https://www.easyspider.net
Welcome to promote this software to other friends. Welcome to promote this software to other friends.
@ -13,9 +13,10 @@ Video Tutorial: https://youtube.com/playlist?list=PL0kEFEkWrT7mt9MUlEBV2DTo1Qsaa
Tasks can be imported from other machines by simply placing the .json files from the "tasks" folder of those machines into the "tasks" folder of this directory. Similarly, execution instance files can be imported by copying the .json files from the "execution_instances" folder. Note that only files named with a number greater than 0 are supported in both folders. Tasks can be imported from other machines by simply placing the .json files from the "tasks" folder of those machines into the "tasks" folder of this directory. Similarly, execution instance files can be imported by copying the .json files from the "execution_instances" folder. Note that only files named with a number greater than 0 are supported in both folders.
======Version Update Instruction====== ======Version Update Instruction======
Please see more new features for version greater than v0.3.2 at github release page: https://github.com/NaiboWang/EasySpider/releases
-----v0.3.2----- -----v0.3.2-----
## Update Instruction ## Update Instruction

View File

@ -4,7 +4,7 @@
./easy-spider.sh ./easy-spider.sh
注意软件运行过程中不要关闭terminal。 注意软件运行过程中不要关闭terminal。
官方网址: https://github.com/NaiboWang/EasySpider 官方网址: https://www.easyspider.cn
支持Ubuntu 20.04, Debian, Deepin x64及以上版本。 支持Ubuntu 20.04, Debian, Deepin x64及以上版本。
@ -15,6 +15,8 @@
======版本更新说明====== ======版本更新说明======
v0.3.2以上版本更新说明请查看Github Release Pages页面https://github.com/NaiboWang/EasySpider/releases
-----v0.3.2----- -----v0.3.2-----
## 更新说明 ## 更新说明

View File

@ -1,4 +1,4 @@
Official Site: https://github.com/NaiboWang/EasySpider Official Site: https://www.easyspider.net
Welcome to promote this software to other friends. Welcome to promote this software to other friends.
@ -12,6 +12,8 @@ You can import tasks from other machines by simply opening the EasySpider softwa
======Version Update Instruction====== ======Version Update Instruction======
Please see more new features for version greater than v0.3.2 at github release page: https://github.com/NaiboWang/EasySpider/releases
-----v0.3.2----- -----v0.3.2-----
## Update Instruction ## Update Instruction

View File

@ -1,6 +1,6 @@
欢迎将软件宣传给更多需要的朋友! 欢迎将软件宣传给更多需要的朋友!
官方网址: https://github.com/NaiboWang/EasySpider 官方网址: https://www.easyspider.cn
支持MacOS系统包括Intel芯片和Arm芯片如酷睿i7和M1芯片最低MacOS系统版本为11.x。 支持MacOS系统包括Intel芯片和Arm芯片如酷睿i7和M1芯片最低MacOS系统版本为11.x。
@ -13,6 +13,8 @@
======版本更新说明====== ======版本更新说明======
v0.3.2以上版本更新说明请查看Github Release Pages页面https://github.com/NaiboWang/EasySpider/releases
-----v0.3.2----- -----v0.3.2-----
## 更新说明 ## 更新说明

View File

@ -1,4 +1,4 @@
Official Site: https://github.com/NaiboWang/EasySpider Official Site: https://www.easyspider.net
Welcome to promote this software to other friends. Welcome to promote this software to other friends.
@ -15,6 +15,8 @@ Tasks can be imported from other machines by simply placing the .json files from
======Version Update Instructions====== ======Version Update Instructions======
Please see more new features for version greater than v0.3.2 at github release page: https://github.com/NaiboWang/EasySpider/releases
-----v0.3.2----- -----v0.3.2-----
## Update Instruction ## Update Instruction

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
欢迎将软件宣传给更多需要的朋友! 欢迎将软件宣传给更多需要的朋友!
官方网址: https://github.com/NaiboWang/EasySpider 官方网址: https://www.easyspider.cn
支持Windows 10 x64及以上版本。 支持Windows 10 x64及以上版本。
@ -15,6 +15,8 @@ Windows 7此版本无直接可用版本因为Chrome 109是最后一个支持W
======版本更新说明====== ======版本更新说明======
v0.3.2以上版本更新说明请查看Github Release Pages页面https://github.com/NaiboWang/EasySpider/releases
-----v0.3.2----- -----v0.3.2-----
## 更新说明 ## 更新说明

View File

@ -1,4 +1,4 @@
Official Site: https://github.com/NaiboWang/EasySpider Official Site: https://www.easyspider.net
Welcome to promote this software to other friends. Welcome to promote this software to other friends.
@ -15,6 +15,8 @@ Tasks can be imported from other machines by simply placing the .json files from
======Version New Features====== ======Version New Features======
Please see more new features for version greater than v0.3.2 at github release page: https://github.com/NaiboWang/EasySpider/releases
-----v0.3.2----- -----v0.3.2-----
## Update Instruction ## Update Instruction

View File

@ -1,6 +1,6 @@
欢迎将软件宣传给更多需要的朋友! 欢迎将软件宣传给更多需要的朋友!
官方网址: https://github.com/NaiboWang/EasySpider 官方网址: https://www.easyspider.cn
支持Windows 10 x32及以上版本。 支持Windows 10 x32及以上版本。
@ -15,6 +15,8 @@ Windows 7此版本无直接可用版本因为Chrome 109是最后一个支持W
======版本更新说明====== ======版本更新说明======
v0.3.2以上版本更新说明请查看Github Release Pages页面https://github.com/NaiboWang/EasySpider/releases
-----v0.3.2----- -----v0.3.2-----
## 更新说明 ## 更新说明

80
.temp_to_pub/compress.py Normal file
View File

@ -0,0 +1,80 @@
import glob
import json
import os
import re
import subprocess
import sys
import requests
import platform
import shutil
import zipfile
import urllib.request
import py7zr
def compress_folder_to_7z(folder_path, output_file):
if os.path.exists(output_file):
os.remove(output_file)
with py7zr.SevenZipFile(output_file, 'w') as archive:
archive.writeall(folder_path, output_file)
def compress_folder_to_7z_split(folder_path, output_file):
if os.path.exists(output_file):
os.remove(output_file)
file_name = os.path.basename(output_file)
file_dir = os.path.dirname(output_file)
# 获取文件名的前缀
file_prefix = os.path.splitext(file_name)[0]
# 构建分卷文件的路径模式
split_file_pattern = os.path.join(file_dir, file_prefix + ".7z.*")
# 获取匹配的分卷文件列表
split_files = glob.glob(split_file_pattern)
# 删除分卷文件
for split_file in split_files:
os.remove(split_file)
# 压缩文件夹
subprocess.call(["7z", "a", "-v95m", output_file, folder_path])
easyspider_version = "0.3.3"
if __name__ == "__main__":
if sys.platform == "win32" and platform.architecture()[0] == "64bit":
file_name = f"EasySpider_{easyspider_version}_windows_x64.7z"
if os.path.exists("./EasySpider_windows_x64/user_data"):
shutil.rmtree("./EasySpider_windows_x64/user_data")
shutil.rmtree("./EasySpider_windows_x64/Data")
shutil.rmtree("./EasySpider_windows_x64/execution_instances")
os.mkdir("./EasySpider_windows_x64/Data")
os.mkdir("./EasySpider_windows_x64/execution_instances")
compress_folder_to_7z_split("./EasySpider_windows_x64", file_name)
print(f"Compress {file_name} Split successfully!")
compress_folder_to_7z("./EasySpider_windows_x64", file_name)
print(f"Compress {file_name} successfully!")
elif sys.platform == "win32" and platform.architecture()[0] == "32bit":
file_name = f"EasySpider_{easyspider_version}_windows_x86.7z"
if os.path.exists("./EasySpider_windows_x86/user_data"):
shutil.rmtree("./EasySpider_windows_x86/user_data")
shutil.rmtree("./EasySpider_windows_x86/Data")
shutil.rmtree("./EasySpider_windows_x86/execution_instances")
os.mkdir("./EasySpider_windows_x86/Data")
os.mkdir("./EasySpider_windows_x86/execution_instances")
compress_folder_to_7z("./EasySpider_windows_x64", file_name)
print(f"Compress {file_name} successfully!")
elif sys.platform == "linux" and platform.architecture()[0] == "64bit":
file_name = f"EasySpider_{easyspider_version}_Linux_x64.7z"
if os.path.exists("./EasySpider_Linux_x64/user_data"):
shutil.rmtree("./EasySpider_Linux_x64/user_data")
shutil.rmtree("./EasySpider_Linux_x64/Data")
shutil.rmtree("./EasySpider_Linux_x64/execution_instances")
os.mkdir("./EasySpider_Linux_x64/Data")
os.mkdir("./EasySpider_Linux_x64/execution_instances")
# compress_folder_to_7z("./EasySpider_Linux_x64", file_name)
print(f"Compress {file_name} successfully!")
elif sys.platform == "darwin" and platform.architecture()[0] == "64bit":
pass

View File

@ -30,6 +30,9 @@ version = "0.3.3"
if __name__ == "__main__": if __name__ == "__main__":
file_path = "../.temp_to_pub/compress.py"
update_file_version(file_path, version, key='easyspider_version = "')
file_path = "./src/taskGrid/logic.js" file_path = "./src/taskGrid/logic.js"
update_file_version(file_path, version, key='"version": "') update_file_version(file_path, version, key='"version": "')

View File

@ -93,4 +93,4 @@ if __name__ == "__main__":
elif sys.platform == "darwin" and platform.architecture()[0] == "64bit": elif sys.platform == "darwin" and platform.architecture()[0] == "64bit":
pass pass
print("Done!") print("Done and don't forget to generate executestage EXEcutable program!")

View File

@ -0,0 +1,7 @@
1. python change_version.py 更改版本号。
2. python generate_chrome.py 更新最新的chrome及chromedriver。
3. 在ExecuteStage目录下执行generateEXE生成运行阶段可执行文件。
4. 在当前目录下执行package_操作系统版本打包。
5. 对windows需要额外执行clean_and_release*.cmd打包。
6. 在.temp_to_pub目录下执行python compress.py压缩成最终发布包。

View File

@ -1,2 +0,0 @@
- python generate_chrome.py 更新最新的chrome及chromedriver
- python change_version.py 更改版本号

View File

@ -263,7 +263,7 @@ class BrowserThread(Thread):
elif int(codeMode) == 1: elif int(codeMode) == 1:
self.recordLog("Execute System Call:" + code) self.recordLog("Execute System Call:" + code)
self.recordLog("执行系统命令:" + code) self.recordLog("执行系统命令:" + code)
# 执行系统命令超时时间为5秒 # 执行系统命令
try: try:
# output = subprocess.run(code, capture_output=True, text=True, timeout=max_wait_time, encoding="utf-8", shell=True) # output = subprocess.run(code, capture_output=True, text=True, timeout=max_wait_time, encoding="utf-8", shell=True)
output = subprocess.run(code, capture_output=True, text=True, timeout=max_wait_time, shell=True) output = subprocess.run(code, capture_output=True, text=True, timeout=max_wait_time, shell=True)
@ -271,7 +271,7 @@ class BrowserThread(Thread):
output = output.stdout output = output.stdout
print(output) print(output)
except subprocess.TimeoutExpired: except subprocess.TimeoutExpired:
# 命令执行时间超过5秒,抛出异常 # 命令执行时间超过指定值,抛出异常
self.recordLog("Command timed out") self.recordLog("Command timed out")
self.recordLog("命令执行超时") self.recordLog("命令执行超时")
except Exception as e: except Exception as e: