bcmd 0.0.26__py3-none-any.whl → 0.0.27__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.
- bcmd/tasks/bin.py +63 -25
- bcmd/tasks/lib.py +6 -6
- bcmd/tasks/task.py +29 -33
- {bcmd-0.0.26.dist-info → bcmd-0.0.27.dist-info}/METADATA +3 -4
- {bcmd-0.0.26.dist-info → bcmd-0.0.27.dist-info}/RECORD +8 -8
- {bcmd-0.0.26.dist-info → bcmd-0.0.27.dist-info}/WHEEL +0 -0
- {bcmd-0.0.26.dist-info → bcmd-0.0.27.dist-info}/entry_points.txt +0 -0
- {bcmd-0.0.26.dist-info → bcmd-0.0.27.dist-info}/top_level.txt +0 -0
bcmd/tasks/bin.py
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import os
|
|
2
|
+
from datetime import datetime
|
|
2
3
|
from pathlib import Path
|
|
3
4
|
from typing import Final
|
|
4
5
|
|
|
5
6
|
import typer
|
|
6
|
-
from beni import bcolor, bfile, bfunc, bstore, btask
|
|
7
|
+
from beni import bcolor, bfile, bfunc, bstore, btable, btask
|
|
7
8
|
from beni.bqiniu import QiniuBucket
|
|
8
9
|
|
|
9
|
-
|
|
10
10
|
app: Final = btask.newSubApp('bin 工具')
|
|
11
11
|
|
|
12
|
+
_PREFIX = 'bin/'
|
|
13
|
+
|
|
12
14
|
|
|
13
15
|
@app.command()
|
|
14
16
|
@bfunc.syncCall
|
|
@@ -18,6 +20,15 @@ async def init(
|
|
|
18
20
|
):
|
|
19
21
|
'初始化七牛云服务'
|
|
20
22
|
await bstore.set(__file__, (ak, sk))
|
|
23
|
+
bcolor.printGreen('OK')
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
@app.command()
|
|
27
|
+
@bfunc.syncCall
|
|
28
|
+
async def clear():
|
|
29
|
+
'清空 token'
|
|
30
|
+
await bstore.clear(__file__)
|
|
31
|
+
bcolor.printGreen('OK')
|
|
21
32
|
|
|
22
33
|
|
|
23
34
|
@app.command()
|
|
@@ -28,29 +39,56 @@ async def download(
|
|
|
28
39
|
output: Path = typer.Option(None, '--output', '-o', help="本地保存路径"),
|
|
29
40
|
):
|
|
30
41
|
'从七牛云下载执行文件'
|
|
42
|
+
bucket = await _getBucket()
|
|
43
|
+
if bucket:
|
|
44
|
+
if output is None:
|
|
45
|
+
output = Path(os.curdir)
|
|
46
|
+
output = output.resolve()
|
|
47
|
+
targetList: list[str] = []
|
|
48
|
+
if names:
|
|
49
|
+
targetList.extend(names.split(','))
|
|
50
|
+
if file:
|
|
51
|
+
content = await bfile.readText(Path(file))
|
|
52
|
+
targetList.extend(content.split('\n'))
|
|
53
|
+
targetList = [x.strip() for x in targetList]
|
|
54
|
+
targetList = [x for x in targetList if x]
|
|
55
|
+
for target in targetList:
|
|
56
|
+
binFile = output / target
|
|
57
|
+
if binFile.exists():
|
|
58
|
+
bcolor.printYellow(f'已存在 {binFile}')
|
|
59
|
+
else:
|
|
60
|
+
key = f'bin/{target}.zip'
|
|
61
|
+
await bucket.downloadPrivateFileUnzip(key, output)
|
|
62
|
+
bcolor.printGreen(f'added {binFile}')
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
@app.command('list')
|
|
66
|
+
@bfunc.syncCall
|
|
67
|
+
async def getList():
|
|
68
|
+
'列出可下载的文件'
|
|
69
|
+
bucket = await _getBucket()
|
|
70
|
+
if bucket:
|
|
71
|
+
datas = (await bucket.getFileList(_PREFIX, limit=1000))[0]
|
|
72
|
+
datas = [x for x in datas if x.key != _PREFIX and x.key.endswith('.zip')]
|
|
73
|
+
print(
|
|
74
|
+
btable.get(
|
|
75
|
+
datas,
|
|
76
|
+
fields=[
|
|
77
|
+
('名称<', lambda x: x.key[len(_PREFIX):-len('.zip')]),
|
|
78
|
+
('时间<', lambda x: datetime.fromtimestamp(x.time / 10000000).strftime('%Y-%m-%d %H:%M:%S')),
|
|
79
|
+
]
|
|
80
|
+
)
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
async def _getBucket():
|
|
31
85
|
try:
|
|
32
86
|
(ak, sk) = await bstore.get(__file__)
|
|
87
|
+
return QiniuBucket(
|
|
88
|
+
'pytask',
|
|
89
|
+
'http://qiniu-cdn.pytask.com',
|
|
90
|
+
ak,
|
|
91
|
+
sk,
|
|
92
|
+
)
|
|
33
93
|
except:
|
|
34
|
-
|
|
35
|
-
bucketName = 'pytask'
|
|
36
|
-
bucketUrl = 'http://qiniu-cdn.pytask.com'
|
|
37
|
-
if output is None:
|
|
38
|
-
output = Path(os.curdir)
|
|
39
|
-
output = output.resolve()
|
|
40
|
-
bucket = QiniuBucket(bucketName, bucketUrl, ak, sk)
|
|
41
|
-
targetList: list[str] = []
|
|
42
|
-
if names:
|
|
43
|
-
targetList.extend(names.split(','))
|
|
44
|
-
if file:
|
|
45
|
-
content = await bfile.readText(Path(file))
|
|
46
|
-
targetList.extend(content.split('\n'))
|
|
47
|
-
targetList = [x.strip() for x in targetList]
|
|
48
|
-
targetList = [x for x in targetList if x]
|
|
49
|
-
for target in targetList:
|
|
50
|
-
binFile = output / target
|
|
51
|
-
if binFile.exists():
|
|
52
|
-
bcolor.printYellow(f'已存在 {binFile}')
|
|
53
|
-
else:
|
|
54
|
-
key = f'bin/{target}.zip'
|
|
55
|
-
await bucket.downloadPrivateFileUnzip(key, output)
|
|
56
|
-
bcolor.printGreen(f'added {binFile}')
|
|
94
|
+
bcolor.printRed('请先执行 beni bin init 进行初始化')
|
bcmd/tasks/lib.py
CHANGED
|
@@ -11,13 +11,13 @@ app: Final = btask.newSubApp('lib 工具')
|
|
|
11
11
|
@app.command()
|
|
12
12
|
@bfunc.syncCall
|
|
13
13
|
async def version(
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
workspace_path: Path = typer.Argument(None, help='workspace 路径'),
|
|
15
|
+
disabled_commit: bool = typer.Option(False, '--disabled-commit', '-d', help='是否提交git'),
|
|
16
16
|
):
|
|
17
17
|
'修改 pyproject.toml 版本号'
|
|
18
|
-
if
|
|
19
|
-
|
|
20
|
-
file =
|
|
18
|
+
if workspace_path is None:
|
|
19
|
+
workspace_path = Path.cwd()
|
|
20
|
+
file = workspace_path / 'pyproject.toml'
|
|
21
21
|
assert file.is_file(), f'文件不存在 {file}'
|
|
22
22
|
data = await bfile.readToml(file)
|
|
23
23
|
version = data['project']['version']
|
|
@@ -32,7 +32,7 @@ async def version(
|
|
|
32
32
|
else:
|
|
33
33
|
raise Exception('版本号修改失败,先检查文件中定义的版本号格式是否正常')
|
|
34
34
|
await bfile.writeText(file, content)
|
|
35
|
-
if not
|
|
35
|
+
if not disabled_commit:
|
|
36
36
|
os.system(
|
|
37
37
|
rf'TortoiseGitProc.exe /command:commit /path:{file} /logmsg:"更新版本号 {newVersion}"'
|
|
38
38
|
)
|
bcmd/tasks/task.py
CHANGED
|
@@ -81,15 +81,19 @@ async def tidy(
|
|
|
81
81
|
tasks_path: Path = typer.Argument(None, help="tasks 路径"),
|
|
82
82
|
):
|
|
83
83
|
'整理 tasks 文件'
|
|
84
|
+
initFile = tasks_path / '__init__.py'
|
|
85
|
+
assert initFile.is_file(), f'文件不存在 {initFile}'
|
|
84
86
|
files = await bpath.listFile(tasks_path)
|
|
85
87
|
files = [x for x in files if not x.name.startswith('_')]
|
|
86
88
|
contents = [f'from . import {x.stem}' for x in files]
|
|
87
89
|
contents.insert(0, '# type: ignore')
|
|
88
90
|
contents.append('')
|
|
91
|
+
content = '\n'.join(contents)
|
|
89
92
|
await bfile.writeText(
|
|
90
|
-
|
|
91
|
-
|
|
93
|
+
initFile,
|
|
94
|
+
content,
|
|
92
95
|
)
|
|
96
|
+
print(content)
|
|
93
97
|
|
|
94
98
|
|
|
95
99
|
_files = '''
|
|
@@ -203,70 +207,61 @@ venv/
|
|
|
203
207
|
],
|
|
204
208
|
},
|
|
205
209
|
{
|
|
206
|
-
"label": "
|
|
210
|
+
"label": "tasks tidy",
|
|
207
211
|
"type": "shell",
|
|
208
212
|
"problemMatcher": [],
|
|
209
213
|
"command": "beni",
|
|
210
214
|
"args": [
|
|
211
|
-
"
|
|
212
|
-
"
|
|
213
|
-
"${workspaceFolder}"
|
|
215
|
+
"task",
|
|
216
|
+
"tidy",
|
|
217
|
+
"${workspaceFolder}/tasks"
|
|
214
218
|
],
|
|
215
219
|
},
|
|
216
220
|
],
|
|
217
221
|
}
|
|
218
222
|
|
|
219
223
|
|
|
220
|
-
>>> src/dev.py
|
|
221
|
-
import main
|
|
222
|
-
from beni import btask
|
|
223
|
-
|
|
224
|
-
main.init()
|
|
225
|
-
|
|
226
|
-
btask.dev('sub.haha')
|
|
227
|
-
|
|
228
|
-
|
|
229
224
|
>>> src/main.py
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
def init():
|
|
234
|
-
btask.options.tasksPath = bpath.get(__file__, '../tasks')
|
|
235
|
-
btask.options.lock = 'xxxxxx'
|
|
225
|
+
import asyncio
|
|
236
226
|
|
|
227
|
+
from beni import btask
|
|
237
228
|
|
|
238
|
-
|
|
239
|
-
init()
|
|
240
|
-
btask.main()
|
|
229
|
+
from tasks import *
|
|
241
230
|
|
|
231
|
+
btask.options.lock = 'bcmd'
|
|
232
|
+
asyncio.run(btask.main())
|
|
242
233
|
|
|
243
|
-
if __name__ == '__main__':
|
|
244
|
-
run()
|
|
245
234
|
|
|
246
235
|
|
|
247
236
|
>>> src/tasks/__init__.py
|
|
237
|
+
# type: ignore
|
|
238
|
+
from . import hello
|
|
239
|
+
from . import sub
|
|
248
240
|
|
|
249
241
|
|
|
250
242
|
|
|
251
243
|
>>> src/tasks/hello.py
|
|
244
|
+
from typing import Final
|
|
245
|
+
|
|
252
246
|
from beni import bfunc, btask
|
|
253
247
|
|
|
248
|
+
app: Final = btask.app
|
|
249
|
+
|
|
254
250
|
|
|
255
|
-
@
|
|
251
|
+
@app.command()
|
|
256
252
|
@bfunc.syncCall
|
|
257
253
|
async def hello():
|
|
258
254
|
'打印 hello'
|
|
259
255
|
print('hello')
|
|
260
256
|
|
|
261
257
|
|
|
258
|
+
|
|
262
259
|
>>> src/tasks/sub.py
|
|
263
260
|
from typing import Final
|
|
264
261
|
|
|
265
|
-
import
|
|
266
|
-
from beni import bfunc
|
|
267
|
-
|
|
262
|
+
from beni import bfunc, btask
|
|
268
263
|
|
|
269
|
-
app: Final =
|
|
264
|
+
app: Final = btask.newSubApp('子工具集')
|
|
270
265
|
|
|
271
266
|
|
|
272
267
|
@app.command()
|
|
@@ -283,13 +278,14 @@ async def bye():
|
|
|
283
278
|
print('bye')
|
|
284
279
|
|
|
285
280
|
|
|
281
|
+
|
|
286
282
|
>>> venv.list
|
|
287
283
|
aioconsole
|
|
288
284
|
aiofiles
|
|
289
285
|
aiohttp
|
|
290
286
|
aiosqlite
|
|
291
287
|
autopep8
|
|
292
|
-
benimang==0.4.
|
|
288
|
+
benimang==0.4.13
|
|
293
289
|
nest-asyncio
|
|
294
290
|
orjson
|
|
295
291
|
portalocker
|
|
@@ -300,4 +296,4 @@ pyinstaller
|
|
|
300
296
|
pyyaml
|
|
301
297
|
qiniu
|
|
302
298
|
typer
|
|
303
|
-
'''
|
|
299
|
+
'''
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: bcmd
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.27
|
|
4
4
|
Summary: Commands for Beni
|
|
5
|
-
Author: Beni Mang
|
|
6
|
-
Author-email: benimang@126.com
|
|
5
|
+
Author-email: Beni Mang <benimang@126.com>
|
|
7
6
|
Maintainer-email: Beni Mang <benimang@126.com>
|
|
8
7
|
Keywords: benimang,beni,bcmd
|
|
9
8
|
Requires-Python: >=3.10
|
|
@@ -11,7 +10,7 @@ Requires-Dist: aioconsole
|
|
|
11
10
|
Requires-Dist: aiofiles
|
|
12
11
|
Requires-Dist: aiohttp
|
|
13
12
|
Requires-Dist: autopep8
|
|
14
|
-
Requires-Dist: benimang (
|
|
13
|
+
Requires-Dist: benimang (<0.5)
|
|
15
14
|
Requires-Dist: build
|
|
16
15
|
Requires-Dist: colorama
|
|
17
16
|
Requires-Dist: nest-asyncio
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
bcmd/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
2
|
bcmd/main.py,sha256=_ycMuR_Opl2muPSZAQYTLk9wGM20x_4I0o7eF_HV848,136
|
|
3
3
|
bcmd/tasks/__init__.py,sha256=38xSWPovSYYIhFcAcRBUoob6PC65Do-88KTIWFCxnQs,168
|
|
4
|
-
bcmd/tasks/bin.py,sha256=
|
|
4
|
+
bcmd/tasks/bin.py,sha256=htkV2tUwq_AuXrr-iEM5pGJWZlGKu-oi70n9uW_0Wf4,2748
|
|
5
5
|
bcmd/tasks/json.py,sha256=ZGhtApi_IYoPoTKluiw4NKc1Pmc5aD8Dd9uv4BdIYsM,490
|
|
6
|
-
bcmd/tasks/lib.py,sha256=
|
|
6
|
+
bcmd/tasks/lib.py,sha256=KMlpu6T1uV8S37XcFJLZP2Jsedrzakltzz8J0A6Tj0Y,2566
|
|
7
7
|
bcmd/tasks/mirror.py,sha256=2IUeno1voK4TduwymIGxjkG1Q1IN-Jw3sfuRZkKSYHc,1384
|
|
8
8
|
bcmd/tasks/proxy.py,sha256=DLIklFMRWUNBKE_0i8pciQdBE5bvAHCejXzzIYp4Ng8,641
|
|
9
|
-
bcmd/tasks/task.py,sha256=
|
|
9
|
+
bcmd/tasks/task.py,sha256=A7NUEoxivjMypr3fQqmsbA3bbU3O37Omx0NpwT097-o,6449
|
|
10
10
|
bcmd/tasks/time.py,sha256=LqwDQL_CvEFs6qgocGzXR00ZwR5yZQ4x-BZ2UD7YWUc,2565
|
|
11
11
|
bcmd/tasks/venv.py,sha256=awS5PDCkuf3itj1He8_nmajo9TxdKUhIiaMuqOOmeoI,3082
|
|
12
|
-
bcmd-0.0.
|
|
13
|
-
bcmd-0.0.
|
|
14
|
-
bcmd-0.0.
|
|
15
|
-
bcmd-0.0.
|
|
16
|
-
bcmd-0.0.
|
|
12
|
+
bcmd-0.0.27.dist-info/METADATA,sha256=HCrLVDRmmTUdsplOPMroFI_OEaliCV6Y75P9u_UmULM,634
|
|
13
|
+
bcmd-0.0.27.dist-info/WHEEL,sha256=AtBG6SXL3KF_v0NxLf0ehyVOh0cold-JbJYXNGorC6Q,92
|
|
14
|
+
bcmd-0.0.27.dist-info/entry_points.txt,sha256=rHJrP6KEQpB-YaQqDFzEL2v88r03rxSfnzAayRvAqHU,39
|
|
15
|
+
bcmd-0.0.27.dist-info/top_level.txt,sha256=-KrvhhtBcYsm4XhcjQvEcFbBB3VXeep7d3NIfDTrXKQ,5
|
|
16
|
+
bcmd-0.0.27.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|