xtn-tools-pro 1.0.1.1.7__py3-none-any.whl → 1.0.1.1.9__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 +17 -4
- {xtn_tools_pro-1.0.1.1.7.dist-info → xtn_tools_pro-1.0.1.1.9.dist-info}/METADATA +1 -1
- {xtn_tools_pro-1.0.1.1.7.dist-info → xtn_tools_pro-1.0.1.1.9.dist-info}/RECORD +7 -7
- {xtn_tools_pro-1.0.1.1.7.dist-info → xtn_tools_pro-1.0.1.1.9.dist-info}/LICENSE +0 -0
- {xtn_tools_pro-1.0.1.1.7.dist-info → xtn_tools_pro-1.0.1.1.9.dist-info}/WHEEL +0 -0
- {xtn_tools_pro-1.0.1.1.7.dist-info → xtn_tools_pro-1.0.1.1.9.dist-info}/entry_points.txt +0 -0
- {xtn_tools_pro-1.0.1.1.7.dist-info → xtn_tools_pro-1.0.1.1.9.dist-info}/top_level.txt +0 -0
xtn_tools_pro/utils/shell.py
CHANGED
@@ -36,6 +36,8 @@ class ShellPro:
|
|
36
36
|
self.server_info_list[_]["conn"] = conn
|
37
37
|
self.__logger.info(f"{tips} 连接成功!!!")
|
38
38
|
|
39
|
+
self.__retry_cnt = 9999999
|
40
|
+
|
39
41
|
def run_shell(self, conn, cmd, warn=False, hide=True, tips="", retry_cnt=5):
|
40
42
|
"""
|
41
43
|
传入conn和命令执行
|
@@ -46,15 +48,16 @@ class ShellPro:
|
|
46
48
|
:param tips: 备注信息
|
47
49
|
:return:
|
48
50
|
"""
|
51
|
+
retry_cnt = self.__retry_cnt if not retry_cnt else retry_cnt
|
49
52
|
for _ in range(retry_cnt):
|
50
53
|
try:
|
51
54
|
conn.run(cmd, warn=warn, hide=hide)
|
52
55
|
self.__logger.info(f"{tips} {cmd}")
|
53
56
|
return
|
54
57
|
except Exception as e:
|
55
|
-
self.__logger.critical(f"{tips} {cmd} {e}
|
58
|
+
self.__logger.critical(f"失败-正在重试 {tips} {cmd} {e}")
|
56
59
|
|
57
|
-
def update_file(self, local_file, remote_file, mkdir=False):
|
60
|
+
def update_file(self, local_file, remote_file, mkdir=False, retry_cnt=5, chmod=""):
|
58
61
|
"""
|
59
62
|
覆盖远程文件
|
60
63
|
:param local_file: 本地文件
|
@@ -62,6 +65,7 @@ class ShellPro:
|
|
62
65
|
:param mkdir: 是否先在远程创建该路径的文件夹
|
63
66
|
:return:
|
64
67
|
"""
|
68
|
+
retry_cnt = self.__retry_cnt if not retry_cnt else retry_cnt
|
65
69
|
for server_item in self.server_info_list:
|
66
70
|
ip = server_item["ip"]
|
67
71
|
tips = server_item["tips"]
|
@@ -70,8 +74,17 @@ class ShellPro:
|
|
70
74
|
remote_dir = os.path.dirname(remote_file)
|
71
75
|
cmd = f"mkdir -p {remote_dir}"
|
72
76
|
self.run_shell(conn, cmd=cmd, warn=True, tips=tips)
|
73
|
-
|
74
|
-
|
77
|
+
|
78
|
+
for _ in range(retry_cnt):
|
79
|
+
try:
|
80
|
+
conn.put(local_file, remote_file)
|
81
|
+
if chmod:
|
82
|
+
cmd = f"chmod {chmod} {remote_file}"
|
83
|
+
self.run_shell(conn, cmd, tips=f"设置文件权限 {chmod}")
|
84
|
+
self.__logger.info(f"{tips}-{ip} 覆盖远程文件成功!!!")
|
85
|
+
break
|
86
|
+
except Exception as e:
|
87
|
+
self.__logger.critical(f"覆盖远程文件-失败-正在重试 {tips} {e}")
|
75
88
|
|
76
89
|
|
77
90
|
if __name__ == '__main__':
|
@@ -59,12 +59,12 @@ xtn_tools_pro/utils/helpers.py,sha256=0CTMY7wfSQR_DC9-v1lkKQLpWcB1FL9V_kw_5DOcZ4
|
|
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=
|
62
|
+
xtn_tools_pro/utils/shell.py,sha256=s6sJedxLLQokcI1hF5YSD3qgGUPK0brNcP-D3-yv54I,3790
|
63
63
|
xtn_tools_pro/utils/sql.py,sha256=EAKzbkZP7Q09j15Gm6o0_uq0qgQmcCQT6EAawbpp4v0,6263
|
64
64
|
xtn_tools_pro/utils/time_utils.py,sha256=TUtzG61PeVYXhaQd6pBrXAdlz7tBispNIRQRcGhE2No,4859
|
65
|
-
xtn_tools_pro-1.0.1.1.
|
66
|
-
xtn_tools_pro-1.0.1.1.
|
67
|
-
xtn_tools_pro-1.0.1.1.
|
68
|
-
xtn_tools_pro-1.0.1.1.
|
69
|
-
xtn_tools_pro-1.0.1.1.
|
70
|
-
xtn_tools_pro-1.0.1.1.
|
65
|
+
xtn_tools_pro-1.0.1.1.9.dist-info/LICENSE,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
66
|
+
xtn_tools_pro-1.0.1.1.9.dist-info/METADATA,sha256=2j4vwVw6ZR7mAJKz-4XftYVN0qPa6HUd_6qbRq_ZPM4,545
|
67
|
+
xtn_tools_pro-1.0.1.1.9.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
68
|
+
xtn_tools_pro-1.0.1.1.9.dist-info/entry_points.txt,sha256=t8CtXWOgw7nRDW3XNlZh8MT_P4l8EzsFnyWi5b3ovrc,68
|
69
|
+
xtn_tools_pro-1.0.1.1.9.dist-info/top_level.txt,sha256=jyB3FLDEr8zE1U7wHczTgIbvUpALhR-ULF7RVEO7O2U,14
|
70
|
+
xtn_tools_pro-1.0.1.1.9.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|