om去除root依赖

This commit is contained in:
liuheng
2023-11-21 18:07:10 +08:00
parent 66b09833af
commit 8e3fd58dfc
19 changed files with 390 additions and 205 deletions

View File

@ -233,7 +233,10 @@ class SshTool():
output: True/False
"""
ownerPath = os.path.split(filePath)[0]
cmd = "su - %s -c 'cd %s'" % (username, ownerPath)
if os.getuid() == 0:
cmd = "su - %s -c 'cd %s'" % (username, ownerPath)
else:
cmd = "cd %s" % ownerPath
(status, output) = subprocess.getstatusoutput(cmd)
if status != 0:
raise Exception(ErrorCode.GAUSS_500["GAUSS_50004"]