sftp = paramiko.SFTPClient.from_transport(connection)
sftp.mkdir(remote_dir, mode=0700)
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)
sftp.put(item, remote_file)
if item == executable:
try:
sftp = paramiko.SFTPClient.from_transport(connection)
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)
sftp.remove(fullpath)
sftp.rmdir(upload_dir)
select.select([], [], [], .1)
WriteLog("SUCCESS: command output follows", logfile)
- for line in output.split("\n"):
+ for line in output.splitlines():
WriteLog("output = %s" % line, logfile)
WriteLog("command execution completed", logfile)
session.close()
print " %s: uploading files" % hostname
upload_dir = UploadFiles(connection, executable,
filelist, logfile)
- command = "cd %s && ./%s" % (upload_dir,
- executable.split("/").pop())
+ command = "cd %s && ./%s" % (upload_dir, os.path.basename(executable))
print " %s: executing remote command" % hostname
cmd_result = RunRemoteCommand(connection, command, logfile)
if cmd_result is True: