ginkgo-tools-batchssh 0.1.0__py3-none-any.whl → 0.1.2__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.
- ginkgo_tools_batchssh/module_SSHwrapper.py +11 -2
- {ginkgo_tools_batchssh-0.1.0.dist-info → ginkgo_tools_batchssh-0.1.2.dist-info}/METADATA +1 -1
- ginkgo_tools_batchssh-0.1.2.dist-info/RECORD +8 -0
- ginkgo_tools_batchssh-0.1.0.dist-info/RECORD +0 -8
- {ginkgo_tools_batchssh-0.1.0.dist-info → ginkgo_tools_batchssh-0.1.2.dist-info}/WHEEL +0 -0
- {ginkgo_tools_batchssh-0.1.0.dist-info → ginkgo_tools_batchssh-0.1.2.dist-info}/top_level.txt +0 -0
|
@@ -10,6 +10,7 @@ from typing import Optional
|
|
|
10
10
|
from . import module_logger
|
|
11
11
|
import os
|
|
12
12
|
import stat
|
|
13
|
+
from pathlib import PurePosixPath, Path
|
|
13
14
|
|
|
14
15
|
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
|
|
15
16
|
|
|
@@ -515,7 +516,7 @@ class SSHWrapper:
|
|
|
515
516
|
logger.warning(f"命令封装执行前流程,shell操作文件封装失败,未提供命令列表或命令字符串")
|
|
516
517
|
return response_dict
|
|
517
518
|
|
|
518
|
-
def commands_to_shell_run(self, trans_result: dict, sudo_to_user = False, timeout: int = 30) -> dict:
|
|
519
|
+
def commands_to_shell_run(self, trans_result: dict, sudo_to_user = False, timeout: int = 30 , transfer_directory:str = "") -> dict:
|
|
519
520
|
"""
|
|
520
521
|
运行已传输的shell文件
|
|
521
522
|
|
|
@@ -535,9 +536,17 @@ class SSHWrapper:
|
|
|
535
536
|
if sudo_to_user:
|
|
536
537
|
logger.debug(f"命令封装执行前流程,触发sudo切换执行操作")
|
|
537
538
|
# 执行转移和变更操作
|
|
538
|
-
|
|
539
|
+
if transfer_directory:
|
|
540
|
+
sudoers_shell_path = PurePosixPath(transfer_directory, file_name)
|
|
541
|
+
logger.debug(f"命令封装执行前流程,触发sudo切换执行操作,指定转移目录为:{transfer_directory}")
|
|
542
|
+
else:
|
|
543
|
+
if sudo_to_user == "root":sudoers_shell_path = f"/root/{file_name}"
|
|
544
|
+
else:sudoers_shell_path = f"/home/{sudo_to_user}/{file_name}"
|
|
545
|
+
logger.debug(f"命令封装执行前流程,触发sudo切换执行操作,未指定转移目录,使用账户关联目录:{sudoers_shell_path}")
|
|
546
|
+
|
|
539
547
|
logger.info(f"命令封装执行后流程,开始将shell文件{shell_path}转移至用户{sudo_to_user},目标路径为:{sudoers_shell_path}")
|
|
540
548
|
mv_result = self.execute_command(f'sudo su - root -c "chown {sudo_to_user} {shell_path};mv {shell_path} {sudoers_shell_path}"')
|
|
549
|
+
logger.debug(mv_result)
|
|
541
550
|
if not mv_result["result"]:
|
|
542
551
|
logger.warning(f"命令封装执行后流程,将shell文件{shell_path}转移至用户{sudo_to_user}失败,请检查反馈异常为:{mv_result['stderr']}")
|
|
543
552
|
return mv_result
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
ginkgo_tools_batchssh/__init__.py,sha256=S01AOuZJzGcIWh9XU_KL1xqHGh-xgmX44Rus8HwHGW4,1126
|
|
2
|
+
ginkgo_tools_batchssh/moduel_convenient_tools.py,sha256=srhVAx43J8gl9RVK3ZYWolJ6HgPEi0claxgPZwRu-zU,1653
|
|
3
|
+
ginkgo_tools_batchssh/module_SSHwrapper.py,sha256=SWXbt8sQu2fEBPJFT2XRNlT84b_gO4-MOpe9SG0kkk4,36237
|
|
4
|
+
ginkgo_tools_batchssh/module_logger.py,sha256=SFnxCKgyFZmzUl3Tr7nMrNdEkiotjU2cN0oCTZEgWuo,2039
|
|
5
|
+
ginkgo_tools_batchssh-0.1.2.dist-info/METADATA,sha256=MTkzovHDu6GipqFgVoSGBy2xtE3sQYIVMx7wGjrBpM4,5938
|
|
6
|
+
ginkgo_tools_batchssh-0.1.2.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
7
|
+
ginkgo_tools_batchssh-0.1.2.dist-info/top_level.txt,sha256=LRf7tgGqGRB41Cit0RPETr5gjljt8IS2k5bl2SEPKxY,22
|
|
8
|
+
ginkgo_tools_batchssh-0.1.2.dist-info/RECORD,,
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
ginkgo_tools_batchssh/__init__.py,sha256=S01AOuZJzGcIWh9XU_KL1xqHGh-xgmX44Rus8HwHGW4,1126
|
|
2
|
-
ginkgo_tools_batchssh/moduel_convenient_tools.py,sha256=srhVAx43J8gl9RVK3ZYWolJ6HgPEi0claxgPZwRu-zU,1653
|
|
3
|
-
ginkgo_tools_batchssh/module_SSHwrapper.py,sha256=-yJe7X7iKIyjsoAdowUoiGDNCtOn1z6ISXlrBgYb4ho,35597
|
|
4
|
-
ginkgo_tools_batchssh/module_logger.py,sha256=SFnxCKgyFZmzUl3Tr7nMrNdEkiotjU2cN0oCTZEgWuo,2039
|
|
5
|
-
ginkgo_tools_batchssh-0.1.0.dist-info/METADATA,sha256=MV52rpktac3X7vBpnZ35ex9lrIYOEaxe4ZpGdPEWO1Q,5938
|
|
6
|
-
ginkgo_tools_batchssh-0.1.0.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
7
|
-
ginkgo_tools_batchssh-0.1.0.dist-info/top_level.txt,sha256=LRf7tgGqGRB41Cit0RPETr5gjljt8IS2k5bl2SEPKxY,22
|
|
8
|
-
ginkgo_tools_batchssh-0.1.0.dist-info/RECORD,,
|
|
File without changes
|
{ginkgo_tools_batchssh-0.1.0.dist-info → ginkgo_tools_batchssh-0.1.2.dist-info}/top_level.txt
RENAMED
|
File without changes
|