[Tutor] glob paramiko

Kent Johnson kent37 at tds.net
Fri May 8 21:26:07 CEST 2009


On Fri, May 8, 2009 at 2:56 PM, Matt Herzog <msh at blisses.org> wrote:
> On Fri, May 08, 2009 at 02:30:22PM -0400, Kent Johnson wrote:
>> On Fri, May 8, 2009 at 1:04 PM, Matt Herzog <msh at blisses.org> wrote:
>> > Hey All.
>> >
>> > All I need to do in this script is scp or sftp a bunch of files to a remote server. This script will run from a cron job eventually.
>> >
>> > For whatever reason, paramiko can't cope with a list.
>> >
>> > ---------------------------------------------------------------------------
>> > AttributeError ? ? ? ? ? ? ? ? ? ? ? ? ? ?Traceback (most recent call last)
>> >
>> > /Users/msh/<ipython console> in <module>()
>> >
>> > AttributeError: 'NoneType' object has no attribute 'put'
>>
>> It would be helpful to see the full stack trace.
>
> Here it is, unless I can give you something more verbose. Not sure how to produce "full stack trace."
> Do you mean this: http://docs.python.org/library/traceback.html ?
>
> (15)[datasvcs at iggy ~/AIG]$ ./parameek0.py
> Traceback (most recent call last):
>  File "./parameek0.py", line 24, in ?
>      sftp.put(localpath, filepath)
>        File "build/bdist.linux-x86_64/egg/paramiko/sftp_client.py", line 547, in put
>        TypeError: coercing to Unicode: need string or buffer, list found

That's what I was asking for. Note that this is completely different
from the first error you posted!

It is telling you the problem, it just doesn't support a list as the
first argument. And in fact there is nothing in the docs to indicate
that it should work with a list. Just put the put() call in a loop and
do each file separately.
>
>>
>> > sftp = paramiko.SFTPClient.from_transport(transport)
>> >
>> > os.chdir("/home/fatcat/")
>> > filepath = '/'
>> > localpath = glob.glob("*.tab")
>> > sftp.put(localpath, filepath)
>>
>> It looks like sftp is None. That is why it has no attribute "put".
>
> Yeah, it shows up as a type list. I haven't been doing any python thinking in a couple months.

No, localpath is a list.

Kent


More information about the Tutor mailing list