bcmd 0.6.13__tar.gz → 0.6.15__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of bcmd might be problematic. Click here for more details.
- {bcmd-0.6.13 → bcmd-0.6.15}/PKG-INFO +1 -1
- {bcmd-0.6.13 → bcmd-0.6.15}/bcmd/tasks/__init__.py +1 -1
- {bcmd-0.6.13 → bcmd-0.6.15}/bcmd/tasks/proxy.py +15 -6
- {bcmd-0.6.13 → bcmd-0.6.15}/bcmd/tasks/upgrade.py +3 -6
- bcmd-0.6.15/bcmd/tasks/wslProxy.py +59 -0
- {bcmd-0.6.13 → bcmd-0.6.15}/bcmd.egg-info/PKG-INFO +1 -1
- {bcmd-0.6.13 → bcmd-0.6.15}/bcmd.egg-info/SOURCES.txt +2 -2
- {bcmd-0.6.13 → bcmd-0.6.15}/pyproject.toml +1 -1
- bcmd-0.6.13/bcmd/tasks/debian.py +0 -78
- {bcmd-0.6.13 → bcmd-0.6.15}/MANIFEST.in +0 -0
- {bcmd-0.6.13 → bcmd-0.6.15}/README.md +0 -0
- {bcmd-0.6.13 → bcmd-0.6.15}/bcmd/__init__.py +0 -0
- {bcmd-0.6.13 → bcmd-0.6.15}/bcmd/common/__init__.py +0 -0
- {bcmd-0.6.13 → bcmd-0.6.15}/bcmd/common/func.py +0 -0
- {bcmd-0.6.13 → bcmd-0.6.15}/bcmd/common/secret.py +0 -0
- {bcmd-0.6.13 → bcmd-0.6.15}/bcmd/resources/project/main.py +0 -0
- {bcmd-0.6.13 → bcmd-0.6.15}/bcmd/tasks/bin.py +0 -0
- {bcmd-0.6.13 → bcmd-0.6.15}/bcmd/tasks/code.py +0 -0
- {bcmd-0.6.13 → bcmd-0.6.15}/bcmd/tasks/crypto.py +0 -0
- {bcmd-0.6.13 → bcmd-0.6.15}/bcmd/tasks/docs.py +0 -0
- {bcmd-0.6.13 → bcmd-0.6.15}/bcmd/tasks/download.py +0 -0
- {bcmd-0.6.13 → bcmd-0.6.15}/bcmd/tasks/image.py +0 -0
- {bcmd-0.6.13 → bcmd-0.6.15}/bcmd/tasks/json.py +0 -0
- {bcmd-0.6.13 → bcmd-0.6.15}/bcmd/tasks/lib.py +0 -0
- {bcmd-0.6.13 → bcmd-0.6.15}/bcmd/tasks/math.py +0 -0
- {bcmd-0.6.13 → bcmd-0.6.15}/bcmd/tasks/mirror.py +0 -0
- {bcmd-0.6.13 → bcmd-0.6.15}/bcmd/tasks/pdf.py +0 -0
- {bcmd-0.6.13 → bcmd-0.6.15}/bcmd/tasks/time.py +0 -0
- {bcmd-0.6.13 → bcmd-0.6.15}/bcmd/tasks/wasabi.py +0 -0
- {bcmd-0.6.13 → bcmd-0.6.15}/bcmd/utils/__init__.py +0 -0
- {bcmd-0.6.13 → bcmd-0.6.15}/bcmd/utils/utils.py +0 -0
- {bcmd-0.6.13 → bcmd-0.6.15}/bcmd.egg-info/dependency_links.txt +0 -0
- {bcmd-0.6.13 → bcmd-0.6.15}/bcmd.egg-info/entry_points.txt +0 -0
- {bcmd-0.6.13 → bcmd-0.6.15}/bcmd.egg-info/requires.txt +0 -0
- {bcmd-0.6.13 → bcmd-0.6.15}/bcmd.egg-info/top_level.txt +0 -0
- {bcmd-0.6.13 → bcmd-0.6.15}/setup.cfg +0 -0
- {bcmd-0.6.13 → bcmd-0.6.15}/test/__init__.py +0 -0
- {bcmd-0.6.13 → bcmd-0.6.15}/test/conftest.py +0 -0
- {bcmd-0.6.13 → bcmd-0.6.15}/test/test_pdf.py +0 -0
- {bcmd-0.6.13 → bcmd-0.6.15}/test/test_proxy.py +0 -0
- {bcmd-0.6.13 → bcmd-0.6.15}/test/test_wasabi.py +0 -0
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
from . import bin
|
|
3
3
|
from . import code
|
|
4
4
|
from . import crypto
|
|
5
|
-
from . import debian
|
|
6
5
|
from . import docs
|
|
7
6
|
from . import download
|
|
8
7
|
from . import image
|
|
@@ -15,3 +14,4 @@ from . import proxy
|
|
|
15
14
|
from . import time
|
|
16
15
|
from . import upgrade
|
|
17
16
|
from . import wasabi
|
|
17
|
+
from . import wslProxy
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import platform
|
|
3
2
|
from typing import Final
|
|
4
3
|
|
|
5
4
|
import psutil
|
|
@@ -25,10 +24,14 @@ async def proxy(
|
|
|
25
24
|
template = ''
|
|
26
25
|
|
|
27
26
|
# 针对不同的终端使用不同的模板
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
match platform.system():
|
|
28
|
+
case 'Windows':
|
|
29
|
+
if 'cmd.exe' in processNameAry:
|
|
30
|
+
template = cmdTemplate
|
|
31
|
+
elif set(['powershell.exe', 'pwsh.exe']) & set(processNameAry):
|
|
32
|
+
template = powerShellTemplate
|
|
33
|
+
case 'Linux':
|
|
34
|
+
template = linuxShellTemplate
|
|
32
35
|
|
|
33
36
|
btask.assertTrue(template, f'不支持当前终端({processNameAry})')
|
|
34
37
|
lineAry = textToAry(template.format(port))
|
|
@@ -54,3 +57,9 @@ powerShellTemplate = '''
|
|
|
54
57
|
$env:https_proxy="http://localhost:{0}"
|
|
55
58
|
$env:all_proxy="http://localhost:{0}"
|
|
56
59
|
'''
|
|
60
|
+
|
|
61
|
+
linuxShellTemplate = '''
|
|
62
|
+
export http_proxy="http://localhost:{0}"
|
|
63
|
+
export https_proxy="http://localhost:{0}"
|
|
64
|
+
export all_proxy="http://localhost:{0}"
|
|
65
|
+
'''
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
from typing import Final
|
|
2
2
|
|
|
3
|
-
import pyperclip
|
|
4
3
|
import typer
|
|
5
|
-
from beni import bcolor, btask
|
|
4
|
+
from beni import bcolor, btask, brun
|
|
6
5
|
from beni.bfunc import syncCall
|
|
7
6
|
|
|
8
7
|
app: Final = btask.app
|
|
@@ -15,7 +14,5 @@ async def upgrade(
|
|
|
15
14
|
):
|
|
16
15
|
'使用 uv 官方源更新指定包到最新版本'
|
|
17
16
|
cmd = f'uv tool install -U --index https://pypi.org/simple {name}'
|
|
18
|
-
|
|
19
|
-
bcolor.printGreen(
|
|
20
|
-
bcolor.printGreen('已复制到剪贴板(需要手动执行)')
|
|
21
|
-
bcolor.printGreen('OK')
|
|
17
|
+
await brun.run(cmd)
|
|
18
|
+
bcolor.printGreen('OK')
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
from typing import Final
|
|
2
|
+
|
|
3
|
+
import pyperclip
|
|
4
|
+
import typer
|
|
5
|
+
from beni import bcolor, btask
|
|
6
|
+
from beni.bfunc import syncCall, textToAry
|
|
7
|
+
|
|
8
|
+
app: Final = btask.newSubApp('WSL2 代理服务')
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@app.command()
|
|
12
|
+
@syncCall
|
|
13
|
+
async def linux(
|
|
14
|
+
port: int = typer.Argument(15236, help="代理服务器端口"),
|
|
15
|
+
):
|
|
16
|
+
'生成终端设置代理服务器的命令'
|
|
17
|
+
ip = "$(ip route | grep default | awk '{print $3}')"
|
|
18
|
+
lineAry = textToAry(f'''
|
|
19
|
+
export HTTP_PROXY=http://{ip}:{port}
|
|
20
|
+
export HTTPS_PROXY=http://{ip}:{port}
|
|
21
|
+
export ALL_PROXY=http://{ip}:{port}
|
|
22
|
+
curl https://google.com.hk
|
|
23
|
+
''')
|
|
24
|
+
msg = '\r\n' + '\n'.join(lineAry) + '\n'
|
|
25
|
+
pyperclip.copy(msg.strip() + '\n')
|
|
26
|
+
bcolor.printMagenta(msg)
|
|
27
|
+
bcolor.printYellow('已复制,可直接粘贴使用')
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
@app.command()
|
|
31
|
+
@syncCall
|
|
32
|
+
async def windows(
|
|
33
|
+
port: int = typer.Argument(15236, help="代理服务器端口"),
|
|
34
|
+
off: bool = typer.Option(False, '--off', help='关闭代理'),
|
|
35
|
+
):
|
|
36
|
+
'设置防火墙以及端口转发'
|
|
37
|
+
|
|
38
|
+
firewallName = 'Allow Veee from WSL'
|
|
39
|
+
|
|
40
|
+
if not off:
|
|
41
|
+
template = f'''
|
|
42
|
+
New-NetFirewallRule -DisplayName "{firewallName}" -Direction Inbound -Action Allow -Protocol TCP -LocalPort {port} -RemoteAddress 172.0.0.0/8 -Profile Any
|
|
43
|
+
netsh interface portproxy add v4tov4 listenaddress=0.0.0.0 listenport={port} connectaddress=127.0.0.1 connectport={port}
|
|
44
|
+
netstat -ano | findstr :{port} | findstr 0.0.0.0
|
|
45
|
+
'''
|
|
46
|
+
else:
|
|
47
|
+
template = f'''
|
|
48
|
+
netsh interface portproxy delete v4tov4 listenaddress=0.0.0.0 listenport={port}
|
|
49
|
+
Remove-NetFirewallRule -DisplayName "{firewallName}"
|
|
50
|
+
'''
|
|
51
|
+
lineAry = textToAry(template)
|
|
52
|
+
msg = '\r\n' + '\n'.join(lineAry) + '\n'
|
|
53
|
+
pyperclip.copy(msg.strip() + '\n')
|
|
54
|
+
bcolor.printMagenta(msg)
|
|
55
|
+
if not off:
|
|
56
|
+
bcolor.printYellow('开启防火墙以及端口转发')
|
|
57
|
+
else:
|
|
58
|
+
bcolor.printYellow('关闭防火墙以及端口转发')
|
|
59
|
+
bcolor.printYellow('已复制,可直接粘贴使用')
|
|
@@ -10,7 +10,6 @@ pyproject.toml
|
|
|
10
10
|
./bcmd/tasks/bin.py
|
|
11
11
|
./bcmd/tasks/code.py
|
|
12
12
|
./bcmd/tasks/crypto.py
|
|
13
|
-
./bcmd/tasks/debian.py
|
|
14
13
|
./bcmd/tasks/docs.py
|
|
15
14
|
./bcmd/tasks/download.py
|
|
16
15
|
./bcmd/tasks/image.py
|
|
@@ -23,6 +22,7 @@ pyproject.toml
|
|
|
23
22
|
./bcmd/tasks/time.py
|
|
24
23
|
./bcmd/tasks/upgrade.py
|
|
25
24
|
./bcmd/tasks/wasabi.py
|
|
25
|
+
./bcmd/tasks/wslProxy.py
|
|
26
26
|
./bcmd/utils/__init__.py
|
|
27
27
|
./bcmd/utils/utils.py
|
|
28
28
|
./test/__init__.py
|
|
@@ -45,7 +45,6 @@ bcmd/tasks/__init__.py
|
|
|
45
45
|
bcmd/tasks/bin.py
|
|
46
46
|
bcmd/tasks/code.py
|
|
47
47
|
bcmd/tasks/crypto.py
|
|
48
|
-
bcmd/tasks/debian.py
|
|
49
48
|
bcmd/tasks/docs.py
|
|
50
49
|
bcmd/tasks/download.py
|
|
51
50
|
bcmd/tasks/image.py
|
|
@@ -58,5 +57,6 @@ bcmd/tasks/proxy.py
|
|
|
58
57
|
bcmd/tasks/time.py
|
|
59
58
|
bcmd/tasks/upgrade.py
|
|
60
59
|
bcmd/tasks/wasabi.py
|
|
60
|
+
bcmd/tasks/wslProxy.py
|
|
61
61
|
bcmd/utils/__init__.py
|
|
62
62
|
bcmd/utils/utils.py
|
bcmd-0.6.13/bcmd/tasks/debian.py
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import os
|
|
2
|
-
from typing import Final
|
|
3
|
-
|
|
4
|
-
from beni import bcolor, bfile, bpath, btask, binput
|
|
5
|
-
from beni.bfunc import syncCall
|
|
6
|
-
|
|
7
|
-
app: Final = btask.newSubApp('Debian 系统管理')
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
@app.command()
|
|
11
|
-
@syncCall
|
|
12
|
-
async def install_python():
|
|
13
|
-
'安装python脚本'
|
|
14
|
-
pythonZipFile = ''
|
|
15
|
-
pythonName = ''
|
|
16
|
-
pythonVersion = ''
|
|
17
|
-
bcolor.printYellow(f'官网地址:https://www.python.org/downloads/source/')
|
|
18
|
-
bcolor.printYellow(f'先从官网上下载 python 源码压缩包(.tar.xz)')
|
|
19
|
-
while True:
|
|
20
|
-
pythonZipFile = input('输入python压缩文件名(如:Python-3.12.1.tar.xz):').strip()
|
|
21
|
-
if pythonZipFile.endswith('.tar.xz'):
|
|
22
|
-
pythonName = pythonZipFile.replace('.tar.xz', '')
|
|
23
|
-
pythonVersion = '.'.join(pythonName.split('-')[-1].split('.')[:-1])
|
|
24
|
-
break
|
|
25
|
-
else:
|
|
26
|
-
print('输入有误,请重新输入')
|
|
27
|
-
cmdList: list[str] = [
|
|
28
|
-
f'apt update',
|
|
29
|
-
f'apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libsqlite3-dev libreadline-dev libffi-dev libbz2-dev -y',
|
|
30
|
-
f'tar -xf {pythonZipFile}',
|
|
31
|
-
f'cd {pythonName}',
|
|
32
|
-
f'./configure --enable-optimizations', # 配置编译选项
|
|
33
|
-
f'make -j `nproc`', # 编译源代码,`nproc` 会利用所有可用的 CPU 核心加快编译速度
|
|
34
|
-
f'make altinstall', # 安装 Python,altinstall 避免替换默认的 python 命令
|
|
35
|
-
f'cd ..',
|
|
36
|
-
f'rm -rf {pythonName}',
|
|
37
|
-
f'rm -rf /usr/local/bin/python',
|
|
38
|
-
f'ln -s /usr/local/bin/python{pythonVersion} /usr/local/bin/python',
|
|
39
|
-
f'rm -rf /usr/local/bin/pip',
|
|
40
|
-
f'ln -s /usr/local/bin/pip{pythonVersion} /usr/local/bin/pip',
|
|
41
|
-
f'python --version',
|
|
42
|
-
f'pip --version',
|
|
43
|
-
f'pip install pipx',
|
|
44
|
-
f'pipx install bcmd',
|
|
45
|
-
]
|
|
46
|
-
shFile = bpath.desktop(f'install-python-{pythonName}.sh')
|
|
47
|
-
await bfile.writeText(shFile, '\n'.join(cmdList))
|
|
48
|
-
bcolor.printGreen(f'将以下两个文件拷贝到服务器上,然后执行 sh {shFile.name} 即可安装 python')
|
|
49
|
-
print(pythonZipFile)
|
|
50
|
-
print(shFile)
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
@app.command()
|
|
54
|
-
@syncCall
|
|
55
|
-
async def install_software():
|
|
56
|
-
'安装常用软件'
|
|
57
|
-
await binput.confirm('即将安装这些软件(7z nginx mariadb),是否确认?')
|
|
58
|
-
cmdList: list[str] = [
|
|
59
|
-
f'echo 更新软件包列表',
|
|
60
|
-
f'apt update',
|
|
61
|
-
f'echo 安装 7z',
|
|
62
|
-
f'apt install p7zip-full -y',
|
|
63
|
-
f'echo 安装 nginx',
|
|
64
|
-
f'apt install nginx -y',
|
|
65
|
-
f'systemctl start nginx',
|
|
66
|
-
f'systemctl enable nginx',
|
|
67
|
-
f'systemctl status nginx',
|
|
68
|
-
f'echo 安装 MariaDB',
|
|
69
|
-
f'apt install mariadb-server -y',
|
|
70
|
-
f'systemctl start mariadb',
|
|
71
|
-
f'systemctl enable mariadb',
|
|
72
|
-
f"sed -i 's/bind-address/# bind-address/' /etc/mysql/mariadb.conf.d/50-server.cnf"
|
|
73
|
-
f'systemctl restart mariadb',
|
|
74
|
-
f'systemctl status mariadb',
|
|
75
|
-
|
|
76
|
-
]
|
|
77
|
-
for cmd in cmdList:
|
|
78
|
-
os.system(cmd)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|