bcmd 0.6.19__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/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 btask, bpath
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.19
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>
@@ -15,7 +15,7 @@ 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=q3bK8depPwZoEGqe9fX2ol-DGsLNZgUxrwhVp4PEF68,928
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
@@ -26,8 +26,8 @@ test/conftest.py,sha256=grlPunlsvrkt_8QPckmF4POiKUPVxIxm2TPAh_ZB-zs,405
26
26
  test/test_pdf.py,sha256=7yYlfydyhy2dmVYdTA5Vir2AI8TUdzEi55fL-AqJmio,1533
27
27
  test/test_proxy.py,sha256=UMF2hFFGUEbJR1jT2mO_wdo-7Rfp0NDqIdTRnOmwtjY,164
28
28
  test/test_wasabi.py,sha256=qqXG1Kb9hKH6t624R173j6LagkgmejN0CFYt7kL0nNs,1066
29
- bcmd-0.6.19.dist-info/METADATA,sha256=vJz5ZMevCIpE4RER7CVUN0VL--qIn86UKAPPFsHMUsw,845
30
- bcmd-0.6.19.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
31
- bcmd-0.6.19.dist-info/entry_points.txt,sha256=mriCeYh3wksKcqq3-LtzyFkSCIdN1uZc1IJwom-SW1s,34
32
- bcmd-0.6.19.dist-info/top_level.txt,sha256=fYY6tRrJ_G7tn24RXAG0M5ZKbcuaQznodfX1toFPSKs,10
33
- bcmd-0.6.19.dist-info/RECORD,,
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,,
File without changes