Skip to content
Snippets Groups Projects
Commit 2c094917 authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

listrunner: Replace str.split with library functions


- str.split("/").pop() should be os.path.basename
- str.split("\n") should be str.splitlines()

Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent ccf5dcf5
No related branches found
No related tags found
No related merge requests found
...@@ -267,7 +267,7 @@ def UploadFiles(connection, executable, filelist, logfile): ...@@ -267,7 +267,7 @@ def UploadFiles(connection, executable, filelist, logfile):
sftp = paramiko.SFTPClient.from_transport(connection) sftp = paramiko.SFTPClient.from_transport(connection)
sftp.mkdir(remote_dir, mode=0700) sftp.mkdir(remote_dir, mode=0700)
for item in filelist: for item in filelist:
remote_file = "%s/%s" % (remote_dir, item.split("/").pop()) remote_file = "%s/%s" % (remote_dir, os.path.basename(item))
WriteLog("uploading %s to remote %s" % (item, remote_file), logfile) WriteLog("uploading %s to remote %s" % (item, remote_file), logfile)
sftp.put(item, remote_file) sftp.put(item, remote_file)
if item == executable: if item == executable:
...@@ -287,7 +287,7 @@ def CleanupRemoteDir(connection, upload_dir, filelist, logfile): ...@@ -287,7 +287,7 @@ def CleanupRemoteDir(connection, upload_dir, filelist, logfile):
try: try:
sftp = paramiko.SFTPClient.from_transport(connection) sftp = paramiko.SFTPClient.from_transport(connection)
for item in filelist: for item in filelist:
fullpath = "%s/%s" % (upload_dir, item.split("/").pop()) fullpath = "%s/%s" % (upload_dir, os.path.basename(item))
WriteLog("removing remote %s" % fullpath, logfile) WriteLog("removing remote %s" % fullpath, logfile)
sftp.remove(fullpath) sftp.remove(fullpath)
sftp.rmdir(upload_dir) sftp.rmdir(upload_dir)
...@@ -337,7 +337,7 @@ def RunRemoteCommand(connection, command, logfile): ...@@ -337,7 +337,7 @@ def RunRemoteCommand(connection, command, logfile):
select.select([], [], [], .1) select.select([], [], [], .1)
WriteLog("SUCCESS: command output follows", logfile) WriteLog("SUCCESS: command output follows", logfile)
for line in output.split("\n"): for line in output.splitlines():
WriteLog("output = %s" % line, logfile) WriteLog("output = %s" % line, logfile)
WriteLog("command execution completed", logfile) WriteLog("command execution completed", logfile)
session.close() session.close()
...@@ -375,8 +375,7 @@ def HostWorker(logdir, username, password, use_agent, hostname, ...@@ -375,8 +375,7 @@ def HostWorker(logdir, username, password, use_agent, hostname,
print " %s: uploading files" % hostname print " %s: uploading files" % hostname
upload_dir = UploadFiles(connection, executable, upload_dir = UploadFiles(connection, executable,
filelist, logfile) filelist, logfile)
command = "cd %s && ./%s" % (upload_dir, command = "cd %s && ./%s" % (upload_dir, os.path.basename(executable))
executable.split("/").pop())
print " %s: executing remote command" % hostname print " %s: executing remote command" % hostname
cmd_result = RunRemoteCommand(connection, command, logfile) cmd_result = RunRemoteCommand(connection, command, logfile)
if cmd_result is True: if cmd_result is True:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment