HOPStudio commited on
Commit
7c85f70
·
verified ·
1 Parent(s): 17f9e19

Delete download.py

Browse files
Files changed (1) hide show
  1. download.py +0 -71
download.py DELETED
@@ -1,71 +0,0 @@
1
- import os
2
- import subprocess
3
-
4
- # 安装 aria2
5
- def install_aria2():
6
- print("正在安装 aria2...")
7
- try:
8
- subprocess.run(['sudo', 'apt', 'update'], check=True)
9
- subprocess.run(['sudo', 'apt', 'install', '-y', 'aria2'], check=True)
10
- print("aria2 安装完成。")
11
- except subprocess.CalledProcessError as e:
12
- print(f"安装 aria2 失败: {e}")
13
- exit(1)
14
-
15
- # 下载文件使用 aria2
16
- def download_files():
17
- download_list = [
18
- "https://hf-mirror.com/HOPStudio/modelscope/resolve/main/frp.py?download=true",
19
- "https://hf-mirror.com/HOPStudio/modelscope/resolve/main/jupyterlab.sh?download=true",
20
- "https://hf-mirror.com/HOPStudio/modelscope/resolve/main/frpc?download=true"
21
- ]
22
-
23
- download_dir = "/root" # 文件下载路径
24
- os.makedirs(download_dir, exist_ok=True)
25
-
26
- print("准备开始下载文件...")
27
-
28
- for file_url in download_list:
29
- print(f"下载中: {file_url}")
30
- try:
31
- # 使用 aria2 下载文件
32
- subprocess.run(['aria2c', '--dir', download_dir, file_url], check=True)
33
- except subprocess.CalledProcessError as e:
34
- print(f"下载文件失败: {e}")
35
-
36
- print("所有文件下载完成。")
37
-
38
- # 运行脚本:先运行 jupyterlab.sh,再运行 frp.py
39
- def run_scripts():
40
- shell_script = os.path.join("/root", "jupyterlab.sh")
41
- python_script = os.path.join("/root", "frp.py")
42
-
43
- # 运行 Shell 脚本
44
- if os.path.isfile(shell_script):
45
- print(f"运行 Shell 脚本: {shell_script}")
46
- try:
47
- subprocess.run(['chmod', '+x', shell_script], check=True) # 确保脚本具有执行权限
48
- subprocess.run([shell_script], check=True)
49
- except subprocess.CalledProcessError as e:
50
- print(f"运行 Shell 脚本失败: {e}")
51
- else:
52
- print(f"找不到 Shell 脚本: {shell_script}")
53
-
54
- # 运行 Python 脚本
55
- if os.path.isfile(python_script):
56
- print(f"运行 Python 脚本: {python_script}")
57
- try:
58
- subprocess.run(['python3', python_script], check=True)
59
- except subprocess.CalledProcessError as e:
60
- print(f"运行 Python 脚本失败: {e}")
61
- else:
62
- print(f"找不到 Python 脚本: {python_script}")
63
-
64
- # 主函数
65
- def main():
66
- install_aria2() # 安装 aria2
67
- download_files() # 下载文件
68
- run_scripts() # 运行脚本
69
-
70
- if __name__ == "__main__":
71
- main()