bcmd 0.6.18__py3-none-any.whl → 0.6.20__py3-none-any.whl
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/tasks/docs.py +6 -13
- bcmd/tasks/project.py +38 -1
- {bcmd-0.6.18.dist-info → bcmd-0.6.20.dist-info}/METADATA +2 -2
- {bcmd-0.6.18.dist-info → bcmd-0.6.20.dist-info}/RECORD +7 -8
- bcmd/utils/utils.py +0 -9
- {bcmd-0.6.18.dist-info → bcmd-0.6.20.dist-info}/WHEEL +0 -0
- {bcmd-0.6.18.dist-info → bcmd-0.6.20.dist-info}/entry_points.txt +0 -0
- {bcmd-0.6.18.dist-info → bcmd-0.6.20.dist-info}/top_level.txt +0 -0
bcmd/tasks/docs.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import asyncio
|
|
2
1
|
import datetime
|
|
2
|
+
import json
|
|
3
3
|
import pickle
|
|
4
4
|
import tkinter as tk
|
|
5
5
|
from contextlib import asynccontextmanager
|
|
@@ -14,8 +14,6 @@ from beni.bform import BForm
|
|
|
14
14
|
from beni.bfunc import syncCall
|
|
15
15
|
from typer import Argument
|
|
16
16
|
|
|
17
|
-
from bcmd.utils.utils import decryptFileIgnoreError
|
|
18
|
-
|
|
19
17
|
app: Final = btask.newSubApp('Vitepress 网站相关')
|
|
20
18
|
conf: dict[str, Any] = {}
|
|
21
19
|
isUpload: bool = False
|
|
@@ -90,7 +88,7 @@ async def userInput():
|
|
|
90
88
|
def onBtn(self):
|
|
91
89
|
password = self.varPassword.get()
|
|
92
90
|
try:
|
|
93
|
-
|
|
91
|
+
bcrypto.decryptJson(conf['server_info'], password)
|
|
94
92
|
self.destroy()
|
|
95
93
|
except:
|
|
96
94
|
messagebox.showerror('密码错误', '密码错误,请重新输入')
|
|
@@ -103,12 +101,10 @@ async def userInput():
|
|
|
103
101
|
btask.abort('用户取消操作')
|
|
104
102
|
isUpload, password = result
|
|
105
103
|
|
|
106
|
-
#
|
|
104
|
+
# 将里面加密的内容解密
|
|
107
105
|
for k, v in conf.items():
|
|
108
|
-
|
|
106
|
+
if str(v).startswith(bcrypto.FLAG):
|
|
109
107
|
conf[k] = bcrypto.decryptText(v, password)
|
|
110
|
-
except:
|
|
111
|
-
pass
|
|
112
108
|
|
|
113
109
|
|
|
114
110
|
async def vitepressBuild(outputPath: Path):
|
|
@@ -131,7 +127,6 @@ async def makeDeploy(outputPath: Path):
|
|
|
131
127
|
|
|
132
128
|
# 文件名以及内容调整
|
|
133
129
|
fileList = bpath.listFile(outputPath, True)
|
|
134
|
-
await asyncio.gather(*[decryptFileIgnoreError(x, password) for x in fileList])
|
|
135
130
|
for file in fileList:
|
|
136
131
|
|
|
137
132
|
# 替换文件名
|
|
@@ -145,10 +140,8 @@ async def makeDeploy(outputPath: Path):
|
|
|
145
140
|
# 替换文件内容
|
|
146
141
|
content = await bfile.readText(file)
|
|
147
142
|
oldContent = content
|
|
148
|
-
|
|
143
|
+
if content.startswith(bcrypto.FLAG):
|
|
149
144
|
content = bcrypto.decryptText(content, password)
|
|
150
|
-
except:
|
|
151
|
-
pass
|
|
152
145
|
for k, v in dataDict.items():
|
|
153
146
|
content = content.replace(f'{{{k}}}', str(v))
|
|
154
147
|
if oldContent != content:
|
|
@@ -168,7 +161,7 @@ async def sshClient():
|
|
|
168
161
|
with bpath.useTempFile() as tempFile:
|
|
169
162
|
await bfile.writeText(tempFile, conf['server_key'])
|
|
170
163
|
client.connect(
|
|
171
|
-
**conf['server_info'],
|
|
164
|
+
**json.loads(conf['server_info']),
|
|
172
165
|
key_filename=str(tempFile),
|
|
173
166
|
)
|
|
174
167
|
yield client
|
bcmd/tasks/project.py
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import getpass
|
|
1
2
|
import os
|
|
2
3
|
from pathlib import Path
|
|
3
4
|
from typing import Final
|
|
4
5
|
|
|
5
|
-
from beni import
|
|
6
|
+
from beni import bcolor, bcrypto, bexecute, bfile, bpath, btask
|
|
6
7
|
from beni.bfunc import syncCall
|
|
7
8
|
from typer import Argument, Option
|
|
8
9
|
|
|
@@ -20,6 +21,42 @@ async def init(
|
|
|
20
21
|
initSubFolder(path, deep)
|
|
21
22
|
|
|
22
23
|
|
|
24
|
+
@app.command()
|
|
25
|
+
@syncCall
|
|
26
|
+
async def https_cert(
|
|
27
|
+
path: Path = Argument(Path.cwd(), help='https证书路径'),
|
|
28
|
+
no_commit: bool = Option(False, '--no-commit', help='不执行提交操作'),
|
|
29
|
+
):
|
|
30
|
+
'更新 https 证书,将证书文件加密并且改名为 {domain}.key 或 {domain}.pem,将下载下来的文件直接放到目录后执行'
|
|
31
|
+
fileList = list(path.glob('**/*.key')) + list(path.glob('**/*.pem'))
|
|
32
|
+
fileList = list(filter(lambda x: x.stem != '{domain}', fileList))
|
|
33
|
+
btask.assertTrue(fileList, '没有找到需要处理的证书文件')
|
|
34
|
+
|
|
35
|
+
# 处理密码输入
|
|
36
|
+
while True:
|
|
37
|
+
password = getpass.getpass('请输入密码:')
|
|
38
|
+
if not password:
|
|
39
|
+
continue
|
|
40
|
+
repassword = getpass.getpass('请重复输入密码:')
|
|
41
|
+
if password == repassword:
|
|
42
|
+
break
|
|
43
|
+
else:
|
|
44
|
+
bcolor.printRed('两次密码输入不一样')
|
|
45
|
+
|
|
46
|
+
# 文件加密处理
|
|
47
|
+
for file in fileList:
|
|
48
|
+
content = await bfile.readText(file)
|
|
49
|
+
content = bcrypto.encryptText(content, password)
|
|
50
|
+
toFile = file.parent / f'{{domain}}{file.suffix}'
|
|
51
|
+
bcolor.printGreen('更新文件', toFile)
|
|
52
|
+
await bfile.writeText(toFile, content)
|
|
53
|
+
bcolor.printYellow('删除文件', file)
|
|
54
|
+
bpath.remove(file)
|
|
55
|
+
|
|
56
|
+
if not no_commit:
|
|
57
|
+
await bexecute.run(f'TortoiseGitProc.exe /command:commit /path:{path}/ /logmsg:"更新https证书文件"')
|
|
58
|
+
|
|
59
|
+
|
|
23
60
|
def initSubFolder(path: Path, deep: int):
|
|
24
61
|
uvLockFile = path / 'uv.lock'
|
|
25
62
|
pnpmLockFile = path / 'pnpm-lock.yaml'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: bcmd
|
|
3
|
-
Version: 0.6.
|
|
3
|
+
Version: 0.6.20
|
|
4
4
|
Summary: Commands for Beni
|
|
5
5
|
Author-email: Beni Mang <benimang@126.com>
|
|
6
6
|
Maintainer-email: Beni Mang <benimang@126.com>
|
|
@@ -8,7 +8,7 @@ Keywords: benimang,beni,bcmd
|
|
|
8
8
|
Requires-Python: >=3.10
|
|
9
9
|
Requires-Dist: aioconsole==0.8.1
|
|
10
10
|
Requires-Dist: async-lru==2.0.5
|
|
11
|
-
Requires-Dist: benimang==0.8.
|
|
11
|
+
Requires-Dist: benimang==0.8.9
|
|
12
12
|
Requires-Dist: cryptography==45.0.4
|
|
13
13
|
Requires-Dist: nest-asyncio==1.6.0
|
|
14
14
|
Requires-Dist: paramiko==3.5.1
|
|
@@ -7,7 +7,7 @@ bcmd/tasks/__init__.py,sha256=shEJe1E9NlJhVWF0GpRLNDqdCVyJ91WYVKTGc1hrgkw,334
|
|
|
7
7
|
bcmd/tasks/bin.py,sha256=DufZGRX7b2zclSaZM-zUPGwOiycN9RsV8KxF8tfSyqs,3240
|
|
8
8
|
bcmd/tasks/code.py,sha256=IUs_ClZuSsBk2gavlitC8mkRrQQX9rvNDgR8cFxduBA,3992
|
|
9
9
|
bcmd/tasks/crypto.py,sha256=LKvgsMPLvsi1wlt66TinYiN-oV2IPAfaN9y7hWaVpHs,2951
|
|
10
|
-
bcmd/tasks/docs.py,sha256=
|
|
10
|
+
bcmd/tasks/docs.py,sha256=nmEZgb1KGSUCgnep2nCL7NgIsQYU5JoHvgIvggIGGtM,5912
|
|
11
11
|
bcmd/tasks/download.py,sha256=XdZYKi8zQTNYWEgUxeTNDqPgP7IGYJkMmlDDC9u93Vk,2315
|
|
12
12
|
bcmd/tasks/image.py,sha256=_ck-WVfUlyQ2fZTpVPcpcurWSud7AkANKUuFjMW7MwA,14283
|
|
13
13
|
bcmd/tasks/json.py,sha256=WWOyvcZPYaqQgp-Tkm-uIJschNMBKPKtZN3yXz_SC5s,635
|
|
@@ -15,20 +15,19 @@ bcmd/tasks/lib.py,sha256=AjB_Qx_eZakJQNpo_OQ796RKVNyUAR0m3S-fF9DXF-k,3070
|
|
|
15
15
|
bcmd/tasks/math.py,sha256=xbl5UdaDMyAjiLodDPleP4Cutrk2S3NOAgurzAgOEAE,2862
|
|
16
16
|
bcmd/tasks/mirror.py,sha256=nAe8NYftMKzht16MFBj7RqXwvVhR6Jh2uuAyJLh87og,1098
|
|
17
17
|
bcmd/tasks/pdf.py,sha256=fkHRgxqzrRxdb4_-9pL9wp2roqAHJPS_dVqAGJvRUsM,1504
|
|
18
|
-
bcmd/tasks/project.py,sha256=
|
|
18
|
+
bcmd/tasks/project.py,sha256=Hg9zz2LXqzPKYRiIp3ZkibZJKL-NGD_XORw3F62ghNs,2401
|
|
19
19
|
bcmd/tasks/proxy.py,sha256=B85ebW_XPo_21j0YKf3oOK-8Crr85ezaPeZZnbnvO4E,1896
|
|
20
20
|
bcmd/tasks/time.py,sha256=ZiqA1jdgl-TBtFSOxxP51nwv4g9iZItmkFKpf9MKelk,2453
|
|
21
21
|
bcmd/tasks/upgrade.py,sha256=nyhcl5oGAUnOOR8JJZW2jfepcVJ6O9gufK8VgxUeil0,543
|
|
22
22
|
bcmd/tasks/wasabi.py,sha256=xWFAxprSIlBqDDMGaNXZFb-SahnW1d_R9XxSKRYIhnM,3110
|
|
23
23
|
bcmd/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
24
|
-
bcmd/utils/utils.py,sha256=Oyf5ubxaCD_T2GOz3zJkR4AJzfVcfBqtmL8Gk8_gOJs,202
|
|
25
24
|
test/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
26
25
|
test/conftest.py,sha256=grlPunlsvrkt_8QPckmF4POiKUPVxIxm2TPAh_ZB-zs,405
|
|
27
26
|
test/test_pdf.py,sha256=7yYlfydyhy2dmVYdTA5Vir2AI8TUdzEi55fL-AqJmio,1533
|
|
28
27
|
test/test_proxy.py,sha256=UMF2hFFGUEbJR1jT2mO_wdo-7Rfp0NDqIdTRnOmwtjY,164
|
|
29
28
|
test/test_wasabi.py,sha256=qqXG1Kb9hKH6t624R173j6LagkgmejN0CFYt7kL0nNs,1066
|
|
30
|
-
bcmd-0.6.
|
|
31
|
-
bcmd-0.6.
|
|
32
|
-
bcmd-0.6.
|
|
33
|
-
bcmd-0.6.
|
|
34
|
-
bcmd-0.6.
|
|
29
|
+
bcmd-0.6.20.dist-info/METADATA,sha256=bQIJyAQSjUcpdsVezAjdlF2q3kSmofTdaReQ6uv4CuU,845
|
|
30
|
+
bcmd-0.6.20.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
31
|
+
bcmd-0.6.20.dist-info/entry_points.txt,sha256=mriCeYh3wksKcqq3-LtzyFkSCIdN1uZc1IJwom-SW1s,34
|
|
32
|
+
bcmd-0.6.20.dist-info/top_level.txt,sha256=fYY6tRrJ_G7tn24RXAG0M5ZKbcuaQznodfX1toFPSKs,10
|
|
33
|
+
bcmd-0.6.20.dist-info/RECORD,,
|
bcmd/utils/utils.py
DELETED
|
File without changes
|
|
File without changes
|
|
File without changes
|