|
1 | | -# Copyright 2024, LxHTT. |
| 1 | +# Copyright 2025, LxHTT. |
2 | 2 | # |
3 | 3 | # Part of "MEFrp-Launcher-Qt", a frpc launcher for ME Frp. |
4 | 4 | # |
|
11 | 11 | # |
12 | 12 | ################################################################################ |
13 | 13 |
|
14 | | -import os |
15 | | -from os import path as osp, remove |
16 | | -from shutil import move, rmtree |
17 | | -from platform import system, architecture |
| 14 | +# from shutil import move, rmtree |
| 15 | +# from platform import system, architecture |
| 16 | +# from zipfile import ZipFile |
| 17 | +# from ..AppController.Settings import cfg |
| 18 | +# import os |
| 19 | +# from os import path as osp, remove |
| 20 | +from os import path as osp |
| 21 | +from platform import system |
18 | 22 | from PyQt5.QtCore import QProcess |
19 | | -from zipfile import ZipFile |
20 | 23 | from .. import FRPC_VERSION |
21 | | -from ..AppController.Settings import cfg |
| 24 | + |
22 | 25 |
|
23 | 26 | frpcDownloadInfo = { |
24 | 27 | "darwin_amd64": f"MirrorEdgeFrp_{FRPC_VERSION}_darwin_amd64.tar.gz", |
|
30 | 33 | } |
31 | 34 |
|
32 | 35 |
|
33 | | -def downloadFrpc(parent): |
34 | | - arch = architecture()[0] |
35 | | - if arch == "64bit": |
36 | | - arch = "amd64" |
37 | | - elif arch == "32bit": |
38 | | - arch = "386" |
39 | | - else: |
40 | | - arch = "arm64" |
41 | | - if system().lower() == "macos": |
42 | | - systemType = "darwin" |
43 | | - else: |
44 | | - systemType = system().lower() |
45 | | - try: |
46 | | - url = ( |
47 | | - cfg.get(cfg.frpcCompletionSrc) |
48 | | - + frpcDownloadInfo["{systemType}_{arch}".format(systemType=systemType, arch=arch)] |
49 | | - ) |
50 | | - except KeyError: |
51 | | - raise LookupError("Not support this platform!") |
52 | | - parent.systemTrayIcon.showMessage("MEFrp Launcher", "正在补全Frpc,请耐心等待...", 5) |
53 | | - if osp.exists(f"frpc/{osp.basename(url)}"): |
54 | | - remove(f"frpc/{osp.basename(url)}") |
55 | | - os.system(f"aria2c.exe -d frpc {url}") |
56 | | - extractFrpc(file_name=osp.basename(url)) |
57 | | - parent.systemTrayIcon.showMessage("MEFrp Launcher", "Frpc补全完毕", 5) |
| 36 | +# def downloadFrpc(parent): |
| 37 | +# arch = architecture()[0] |
| 38 | +# if arch == "64bit": |
| 39 | +# arch = "amd64" |
| 40 | +# elif arch == "32bit": |
| 41 | +# arch = "386" |
| 42 | +# else: |
| 43 | +# arch = "arm64" |
| 44 | +# if system().lower() == "macos": |
| 45 | +# systemType = "darwin" |
| 46 | +# else: |
| 47 | +# systemType = system().lower() |
| 48 | +# try: |
| 49 | +# url = ( |
| 50 | +# cfg.get(cfg.frpcCompletionSrc) |
| 51 | +# + frpcDownloadInfo["{systemType}_{arch}".format(systemType=systemType, arch=arch)] |
| 52 | +# ) |
| 53 | +# except KeyError: |
| 54 | +# raise LookupError("Not support this platform!") |
| 55 | +# parent.systemTrayIcon.showMessage("MEFrp Launcher", "正在补全Frpc,请耐心等待...", 5) |
| 56 | +# if osp.exists(f"frpc/{osp.basename(url)}"): |
| 57 | +# remove(f"frpc/{osp.basename(url)}") |
| 58 | +# os.system(f"aria2c.exe -d frpc {url}") |
| 59 | +# extractFrpc(file_name=osp.basename(url)) |
| 60 | +# parent.systemTrayIcon.showMessage("MEFrp Launcher", "Frpc补全完毕", 5) |
58 | 61 |
|
59 | 62 |
|
60 | | -def extractFrpc(file_name): |
61 | | - frpcProcessName = "frpc.exe" if system().lower() == "windows" else "frpc" |
62 | | - if osp.exists(f"frpc/{frpcProcessName}"): |
63 | | - remove(f"frpc/{frpcProcessName}") |
64 | | - with ZipFile(f"frpc/{file_name}", "r") as frpcArchive: |
65 | | - frpcArchive.extract( |
66 | | - f"{file_name.replace('.zip', '').replace('.tar.gz', '')}/{frpcProcessName}", "frpc" |
67 | | - ) |
68 | | - move( |
69 | | - f"frpc/{file_name.replace('.zip', '').replace('.tar.gz', '')}/{frpcProcessName}", |
70 | | - f"frpc/{frpcProcessName}", |
71 | | - ) |
72 | | - remove(f"frpc/{file_name}") |
73 | | - rmtree(f"frpc/{file_name.replace('.zip', '').replace('.tar.gz', '')}") |
| 63 | +# def extractFrpc(file_name): |
| 64 | +# frpcProcessName = "frpc.exe" if system().lower() == "windows" else "frpc" |
| 65 | +# if osp.exists(f"frpc/{frpcProcessName}"): |
| 66 | +# remove(f"frpc/{frpcProcessName}") |
| 67 | +# with ZipFile(f"frpc/{file_name}", "r") as frpcArchive: |
| 68 | +# frpcArchive.extract( |
| 69 | +# f"{file_name.replace('.zip', '').replace('.tar.gz', '')}/{frpcProcessName}", "frpc" |
| 70 | +# ) |
| 71 | +# move( |
| 72 | +# f"frpc/{file_name.replace('.zip', '').replace('.tar.gz', '')}/{frpcProcessName}", |
| 73 | +# f"frpc/{frpcProcessName}", |
| 74 | +# ) |
| 75 | +# remove(f"frpc/{file_name}") |
| 76 | +# rmtree(f"frpc/{file_name.replace('.zip', '').replace('.tar.gz', '')}") |
74 | 77 |
|
75 | 78 |
|
76 | 79 | def checkFrpc(getVersion): |
|
0 commit comments