xtn-tools-pro 1.0.1.0.5__py3-none-any.whl → 1.0.1.0.7__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.
- xtn_tools_pro/utils/shell.py +62 -0
- {xtn_tools_pro-1.0.1.0.5.dist-info → xtn_tools_pro-1.0.1.0.7.dist-info}/METADATA +3 -2
- {xtn_tools_pro-1.0.1.0.5.dist-info → xtn_tools_pro-1.0.1.0.7.dist-info}/RECORD +7 -6
- {xtn_tools_pro-1.0.1.0.5.dist-info → xtn_tools_pro-1.0.1.0.7.dist-info}/LICENSE +0 -0
- {xtn_tools_pro-1.0.1.0.5.dist-info → xtn_tools_pro-1.0.1.0.7.dist-info}/WHEEL +0 -0
- {xtn_tools_pro-1.0.1.0.5.dist-info → xtn_tools_pro-1.0.1.0.7.dist-info}/entry_points.txt +0 -0
- {xtn_tools_pro-1.0.1.0.5.dist-info → xtn_tools_pro-1.0.1.0.7.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,62 @@
|
|
1
|
+
#!/usr/bin/env python
|
2
|
+
# -*- coding: utf-8 -*-
|
3
|
+
|
4
|
+
# 说明:
|
5
|
+
# 服务器批量操作
|
6
|
+
# History:
|
7
|
+
# Date Author Version Modification
|
8
|
+
# --------------------------------------------------------------------------------------------------
|
9
|
+
# 2025/4/2 xiatn V00.01.000 新建
|
10
|
+
# --------------------------------------------------------------------------------------------------
|
11
|
+
from fabric import Connection, Config
|
12
|
+
from xtn_tools_pro.utils.log import Log
|
13
|
+
|
14
|
+
|
15
|
+
class ShellPro:
|
16
|
+
def __init__(self, server_info_list):
|
17
|
+
self.server_info_list = server_info_list
|
18
|
+
self.__logger = Log('shell', './xxx.log', log_level='DEBUG', is_write_to_console=True,
|
19
|
+
is_write_to_file=False,
|
20
|
+
color=True, mode='a', save_time_log_path='./logs')
|
21
|
+
|
22
|
+
for _ in range(len(self.server_info_list)):
|
23
|
+
ip, pwd, tips = self.server_info_list[_]["ip"], \
|
24
|
+
self.server_info_list[_]["pwd"], \
|
25
|
+
self.server_info_list[_]["tips"]
|
26
|
+
self.__logger.info(f"{tips} 正在连接...")
|
27
|
+
config = Config(overrides={'sudo': {'password': pwd}})
|
28
|
+
conn = Connection(
|
29
|
+
host=ip,
|
30
|
+
user="root", # 根据实际情况修改用户名
|
31
|
+
connect_kwargs={"password": pwd},
|
32
|
+
config=config
|
33
|
+
)
|
34
|
+
self.server_info_list[_]["conn"] = conn
|
35
|
+
self.__logger.info(f"{tips} 连接成功!!!")
|
36
|
+
|
37
|
+
def run_shell(self, conn, cmd, warn=False):
|
38
|
+
"""
|
39
|
+
传入conn和命令执行
|
40
|
+
:param conn:
|
41
|
+
:param cmd:
|
42
|
+
:return:
|
43
|
+
"""
|
44
|
+
conn.run(cmd, warn=warn)
|
45
|
+
|
46
|
+
def update_file(self, LOCAL_FILE, REMOTE_FILE):
|
47
|
+
"""
|
48
|
+
覆盖远程文件
|
49
|
+
:param LOCAL_FILE: 本地文件
|
50
|
+
:param REMOTE_FILE: 远程文件
|
51
|
+
:return:
|
52
|
+
"""
|
53
|
+
for server_item in self.server_info_list:
|
54
|
+
conn = server_item["conn"]
|
55
|
+
conn.put(LOCAL_FILE, REMOTE_FILE)
|
56
|
+
|
57
|
+
|
58
|
+
if __name__ == '__main__':
|
59
|
+
server_info_list = [
|
60
|
+
{"ip": "xxx.xxx.xx.xxx", "pwd": "123456", "tips": "服务器_01"},
|
61
|
+
]
|
62
|
+
sh = ShellPro(server_info_list=server_info_list)
|
@@ -1,11 +1,11 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: xtn-tools-pro
|
3
|
-
Version: 1.0.1.0.
|
3
|
+
Version: 1.0.1.0.7
|
4
4
|
Summary: xtn 开发工具
|
5
5
|
Author: xtn
|
6
6
|
Author-email: czw011122@gmail.com
|
7
7
|
Classifier: Programming Language :: Python :: 3
|
8
|
-
Requires-Python: >=3
|
8
|
+
Requires-Python: >=3.7
|
9
9
|
Description-Content-Type: text/markdown
|
10
10
|
License-File: LICENSE
|
11
11
|
Requires-Dist: pymongo
|
@@ -17,5 +17,6 @@ Requires-Dist: requests
|
|
17
17
|
Requires-Dist: Faker
|
18
18
|
Requires-Dist: PyJWT
|
19
19
|
Requires-Dist: tqdm
|
20
|
+
Requires-Dist: fabric
|
20
21
|
|
21
22
|
xtnkk-tools
|
@@ -59,11 +59,12 @@ xtn_tools_pro/utils/helpers.py,sha256=OmPRxB6vDN1S7OhxQWgoOXnxs2YPorwSQKBVzYOiKo
|
|
59
59
|
xtn_tools_pro/utils/log.py,sha256=mf5huJDA8xVxxFWPG_tl_vOsAA2_ywGDFycYSGHIDCo,10202
|
60
60
|
xtn_tools_pro/utils/retry.py,sha256=0wjHsR5DBBKpv4naMfxiky8kprrZes4WURIfFQ4H708,1657
|
61
61
|
xtn_tools_pro/utils/set_data.py,sha256=BzCLbEDO83csDHBey8kP7SoE6kx6EjqE7OqRBY7k82s,17608
|
62
|
+
xtn_tools_pro/utils/shell.py,sha256=RSHILGuFzE0azs78VIPSLOi0E62yHQqGILyo9hnhlts,2293
|
62
63
|
xtn_tools_pro/utils/sql.py,sha256=EAKzbkZP7Q09j15Gm6o0_uq0qgQmcCQT6EAawbpp4v0,6263
|
63
64
|
xtn_tools_pro/utils/time_utils.py,sha256=TUtzG61PeVYXhaQd6pBrXAdlz7tBispNIRQRcGhE2No,4859
|
64
|
-
xtn_tools_pro-1.0.1.0.
|
65
|
-
xtn_tools_pro-1.0.1.0.
|
66
|
-
xtn_tools_pro-1.0.1.0.
|
67
|
-
xtn_tools_pro-1.0.1.0.
|
68
|
-
xtn_tools_pro-1.0.1.0.
|
69
|
-
xtn_tools_pro-1.0.1.0.
|
65
|
+
xtn_tools_pro-1.0.1.0.7.dist-info/LICENSE,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
66
|
+
xtn_tools_pro-1.0.1.0.7.dist-info/METADATA,sha256=02R4JkZuEF5v6Fa0X1ZyqTauxaUc1heYs9duK8zDL-c,523
|
67
|
+
xtn_tools_pro-1.0.1.0.7.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
68
|
+
xtn_tools_pro-1.0.1.0.7.dist-info/entry_points.txt,sha256=t8CtXWOgw7nRDW3XNlZh8MT_P4l8EzsFnyWi5b3ovrc,68
|
69
|
+
xtn_tools_pro-1.0.1.0.7.dist-info/top_level.txt,sha256=jyB3FLDEr8zE1U7wHczTgIbvUpALhR-ULF7RVEO7O2U,14
|
70
|
+
xtn_tools_pro-1.0.1.0.7.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|