Могу ли я использовать SFTP для распаковки .tar.gz
на удаленном сервере?
def untarFile(self,fileName,hostname,username,key_filename):
self.connect(hostname, username, key_filename)
self.username = username
self.key_filename = key_filename
self.fileName = fileName
sftp_client = self.ssh.open_sftp()
if (fileName.endswith("tar.gz")):
print "Extracting files"
tar = sftp_client.tarfile.open(fileName)
tar.extractall()
tar.close()
print "Files extracted to %s" %self.autoRemote
else:
print "Could not extract test code"
Ошибка, которую я вижу:
Connection with server succesfully established with user test...
Extracting files
Traceback (most recent call last):
File "test.py", line 181, in <module>
ssh_obj.untarFile(ssh_obj.testCode, ssh_obj.hostname, ssh_obj.autouser, ssh_obj.autoSSHK)
File "test.py", line 164, in untarFile
tar = sftp_client.tarfile.open(fileName)
AttributeError: 'SFTPClient' object has no attribute 'tarfile'```