bcmd 0.0.56__py3-none-any.whl → 0.0.58__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/__init__.py CHANGED
@@ -1,5 +1,6 @@
1
1
  # type: ignore
2
2
  from . import bin
3
+ from . import download
3
4
  from . import json
4
5
  from . import lib
5
6
  from . import math
@@ -7,5 +8,6 @@ from . import mirror
7
8
  from . import proxy
8
9
  from . import pwd
9
10
  from . import task
11
+ from . import temp
10
12
  from . import time
11
13
  from . import venv
bcmd/tasks/download.py ADDED
@@ -0,0 +1,34 @@
1
+ import asyncio
2
+ import os
3
+ from pathlib import Path
4
+ from typing import Final
5
+
6
+ import pyperclip
7
+ import typer
8
+ from beni import bcolor, bhttp, bpath, btask
9
+ from beni.bfunc import syncCall
10
+
11
+ app: Final = btask.newSubApp('下载')
12
+
13
+
14
+ @app.command()
15
+ @syncCall
16
+ async def urls(
17
+ path: Path = typer.Option(None, '--path', '-p', help='指定路径,默认当前目录'),
18
+ ):
19
+ '下载文件'
20
+ path = path or Path(os.getcwd())
21
+ content = pyperclip.paste()
22
+ urlSet = set([x.strip() for x in content.strip().split('\n') if x.strip()])
23
+
24
+ async def download(url: str):
25
+ file = bpath.get(path, '/'.join([x for x in url.replace('://', '/').split('/') if x]))
26
+ try:
27
+ bcolor.printGreen(url)
28
+ await bhttp.download(url, file)
29
+ except:
30
+ bcolor.printRed(url)
31
+
32
+ await asyncio.gather(*[download(x) for x in urlSet])
33
+
34
+ bcolor.printYellow('Done')
bcmd/tasks/pwd.py CHANGED
@@ -9,7 +9,7 @@ from beni import bcolor, btask
9
9
  from beni.bfunc import magicSequence, syncCall
10
10
  from rich.console import Console
11
11
 
12
- app: Final = btask.newSubApp('lib 工具')
12
+ app: Final = btask.newSubApp('密钥')
13
13
 
14
14
 
15
15
  _KEY_SALT = '_salt_@#%@#xafDGAz.nq'
bcmd/tasks/temp.py ADDED
@@ -0,0 +1,31 @@
1
+ from pathlib import Path
2
+ from typing import Final
3
+
4
+ import typer
5
+ from beni import bcolor, bpath, btask
6
+ from beni.bfunc import syncCall
7
+ from beni.bqiniu import QiniuBucket
8
+
9
+ from bcmd.common import password
10
+
11
+ app: Final = btask.newSubApp('temp 工具')
12
+
13
+
14
+ @app.command()
15
+ @syncCall
16
+ async def upload_qiniu(
17
+ local_path: Path = typer.Argument(..., help="本地路径"),
18
+ bucket_name: str = typer.Argument(None, help="七牛云空间名称"),
19
+ ):
20
+ ak, sk = await password.getQiniu()
21
+ bucket = QiniuBucket(
22
+ 'pytask-doc',
23
+ '',
24
+ ak,
25
+ sk,
26
+ )
27
+ for file in bpath.listFile(local_path, True):
28
+ key = file.relative_to(local_path).as_posix()
29
+ await bucket.uploadFile(key, file)
30
+ print(key)
31
+ bcolor.printGreen('OK')
bcmd/tasks/venv.py CHANGED
@@ -23,7 +23,11 @@ async def venv(
23
23
  quiet: bool = typer.Option(False, '--quiet', '-q', help='是否安静模式'),
24
24
  ):
25
25
  'python 虚拟环境配置'
26
- await password.getQiniu()
26
+
27
+ path = path or Path(os.getcwd())
28
+ binPath = path / 'bin'
29
+ binListFile = bpath.get(path, 'bin.list')
30
+ await _inputQiniuPassword(binListFile, binPath)
27
31
  packages = packages or []
28
32
  for i in range(len(packages)):
29
33
  package = packages[i]
@@ -35,7 +39,6 @@ async def venv(
35
39
  if disabled_mirror and pipIniFile.is_file():
36
40
  bpath.move(pipIniFile, tempFile)
37
41
  try:
38
- path = path or Path(os.getcwd())
39
42
  venvPath = bpath.get(path, 'venv')
40
43
  assertPath(venvPath)
41
44
  if not venvPath.exists() and not quiet:
@@ -59,12 +62,11 @@ async def venv(
59
62
  await bexecute.run(f'{pip} freeze > {venvLockFile}')
60
63
 
61
64
  # 下载 bin 文件
62
- binListFile = bpath.get(path, 'bin.list')
63
65
  if binListFile.exists():
64
66
  bin.download(
65
67
  names=Null,
66
68
  file=binListFile,
67
- output=path / 'bin',
69
+ output=binPath,
68
70
  )
69
71
 
70
72
  finally:
@@ -111,3 +113,12 @@ async def _getPackageLatestVersion(package: str):
111
113
  f'https://pypi.org/pypi/{package}/json'
112
114
  )
113
115
  return data['info']['version']
116
+
117
+
118
+ async def _inputQiniuPassword(binListFile: Path, binPath: Path) -> None:
119
+ '根据需要输入七牛云密码'
120
+ if binListFile.exists():
121
+ aaSet = set([x.strip() for x in (await bfile.readText(binListFile)).strip().split('\n') if x.strip()])
122
+ bbSet = set([x.name for x in bpath.listFile(binPath)])
123
+ if aaSet != bbSet:
124
+ await password.getQiniu()
@@ -1,12 +1,12 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: bcmd
3
- Version: 0.0.56
3
+ Version: 0.0.58
4
4
  Summary: Commands for Beni
5
5
  Author-email: Beni Mang <benimang@126.com>
6
6
  Maintainer-email: Beni Mang <benimang@126.com>
7
7
  Keywords: benimang,beni,bcmd
8
8
  Requires-Python: >=3.10
9
- Requires-Dist: benimang ==0.4.34
9
+ Requires-Dist: benimang ==0.5.3
10
10
  Requires-Dist: pathspec
11
11
  Requires-Dist: pyjwt
12
12
 
@@ -2,19 +2,21 @@ bcmd/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
2
  bcmd/main.py,sha256=_ycMuR_Opl2muPSZAQYTLk9wGM20x_4I0o7eF_HV848,136
3
3
  bcmd/common/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  bcmd/common/password.py,sha256=O2TL7S7wLMtatII2N-z68dkX6Y3vF-NKccMffcb69sU,1562
5
- bcmd/tasks/__init__.py,sha256=JQomljtTMPQbpLv-y0vKSzwFm4_WZdtWzutCAoXq6Ok,205
5
+ bcmd/tasks/__init__.py,sha256=piOWctJyZ0fdaLk3vnuztxCGv4wysgVPfhCN-yZSgBY,247
6
6
  bcmd/tasks/bin.py,sha256=4O9Doak-ecOTGvyriZf6v31bhTI66s5IsIKV3wW_cu4,3082
7
+ bcmd/tasks/download.py,sha256=pDumCQum93899yN5mawI1aNumWatH1K1QQztLOdK0-4,893
7
8
  bcmd/tasks/json.py,sha256=WWOyvcZPYaqQgp-Tkm-uIJschNMBKPKtZN3yXz_SC5s,635
8
9
  bcmd/tasks/lib.py,sha256=l4v9JnsSFicnWfd6lOMa9TIKZn14ybYsIiPX1vCWaho,4350
9
10
  bcmd/tasks/math.py,sha256=jDLIEhy9Dbz7yHlZQIr7rps6C-rNamiVM7_9tVYdMJk,4302
10
11
  bcmd/tasks/mirror.py,sha256=PLRI5XPG9CV44rgQn1mB5U-GRJYnp5wl3Xwsd0_df_Y,1448
11
12
  bcmd/tasks/proxy.py,sha256=nAxF9yzk-2O6TeEczGRc3vS3dfe2ZZR1hcGOFU1DS3g,660
12
- bcmd/tasks/pwd.py,sha256=-j6HcZcfKz7U2XhEDAsomY0FdXZwnwqE_yXD5RRZtX0,2885
13
+ bcmd/tasks/pwd.py,sha256=0-sQ140rIWaLG0NlH-nDmmwdpScFWZaglLgVDaLf_Go,2881
13
14
  bcmd/tasks/task.py,sha256=7AelyK8mTVTfERaagkaUUggP8Md3XC9gurgoakMYf_I,4738
15
+ bcmd/tasks/temp.py,sha256=xLyYo2q6BX6OiaWG8NuyNmUCroVYrmtLzR2cZOUyFow,766
14
16
  bcmd/tasks/time.py,sha256=nSIVYov2LsGdxsZAtC91UKXcUtVAqR9o-JmzeuevFhA,2586
15
- bcmd/tasks/venv.py,sha256=VU34ZZlvqUc4EIlOHayOiJNW4L7v8wsz1Mc-FPfdGVI,4015
16
- bcmd-0.0.56.dist-info/METADATA,sha256=whlDDZ3rwGvlTZgKF35pjtH7bAjU76BCF67Vc5Fq0mQ,310
17
- bcmd-0.0.56.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
18
- bcmd-0.0.56.dist-info/entry_points.txt,sha256=rHJrP6KEQpB-YaQqDFzEL2v88r03rxSfnzAayRvAqHU,39
19
- bcmd-0.0.56.dist-info/top_level.txt,sha256=-KrvhhtBcYsm4XhcjQvEcFbBB3VXeep7d3NIfDTrXKQ,5
20
- bcmd-0.0.56.dist-info/RECORD,,
17
+ bcmd/tasks/venv.py,sha256=VKLOlaArbEd0w16_1RraqDkK8Cbs1yoIgzYzWiRjVaA,4427
18
+ bcmd-0.0.58.dist-info/METADATA,sha256=TTTmFbE6VKtCIRV3qBPLlPPehA8hFccgk2YLW7G-QJM,309
19
+ bcmd-0.0.58.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
20
+ bcmd-0.0.58.dist-info/entry_points.txt,sha256=rHJrP6KEQpB-YaQqDFzEL2v88r03rxSfnzAayRvAqHU,39
21
+ bcmd-0.0.58.dist-info/top_level.txt,sha256=-KrvhhtBcYsm4XhcjQvEcFbBB3VXeep7d3NIfDTrXKQ,5
22
+ bcmd-0.0.58.dist-info/RECORD,,
File without changes