0

for transfer entire folder to server using sftp with paramiko. I copy this code from stackoverflow

but my doubt is how to call that function, I put like this ..

sftp = paramiko.SFTPClient.from_transport(t)
M = MySFTPClient()
M.put_dir()
M.mkdir()

but Its throwing this error:

*** Caught exception: <type 'exceptions.TypeError'>: __init__() takes exactly 2 arguments (1 given)
Community
  • 1
  • 1
Raja Simon
  • 10,126
  • 5
  • 43
  • 74

2 Answers2

1

I haven't used Paramiko, but reading the source code it seems that you can already use the sftp object returned from the from_transport method. So no need to create another MySFTPClient()

In a Python console try reading help(paramiko.SFTPClient) and help(paramiko.SFTPClient.from_transport). Also browsing sftp.py seems helpful as the list of available commands is in the beginning (put_dir does not seem to be one of them).

Bemmu
  • 17,849
  • 16
  • 76
  • 93
1

The error message indicates that the function you are calling takes two arguments while you are sending zero. Try doing something like this instead:

t = paramiko.Transport(("ftpexample.com", 22))
t.connect(username = myusername, password = mypassword)

sftp = paramiko.SFTPClient.from_transport(t)

Use the sftp client to upload your file at localpath (e.g. /usr/tmp/test.png") to your remote path:

sftp.put("localpath","remotepath")
Trond Kristiansen
  • 2,379
  • 23
  • 48