[Tutor] sftp get single file

Matt Herzog msh at blisses.org
Mon Jul 20 21:53:38 CEST 2009


On Fri, Jul 17, 2009 at 12:12:52PM -0400, Kent Johnson wrote:
> On Fri, Jul 17, 2009 at 11:42 AM, Sander Sweers<sander.sweers at gmail.com> wrote:
> 
> > import time
> >
> > today = time.localtime()
> > datestr = time.strftime("%Y%m%d",today)
> > ext = ".tab"
> >
> > print datestr + ext
> 
> You can include literal characters in the format string:
> 
> In [4]: time.strftime("%Y%m%d.tab",today)
> Out[4]: '20090717.tab'

That does work and is compact while being intelligible.
I'm still not getting the file. I thought this would work:

if __name__ == "__main__":
    t = paramiko.Transport((hostname, port))
    t.connect(username=username, password=password)
    sftp = paramiko.SFTPClient.from_transport(t)
    sftp(remotepath,localpath)
    t.close()

 . . . but obviously something is missing. 

Traceback (most recent call last):
  File "./scpgetter.py", line 20, in ?
      sftp(remotepath,localpath)
      TypeError: 'SFTPClient' object is not callable

I tried using the paramiko.SFTP.get method too. Failed.

-- Matt H


> 
> Kent

-- 
I fear you speak upon the rack,
Where men enforced do speak anything.

- William Shakespeare


More information about the Tutor mailing list