Im trying to read CSV files from ftp server in AppEngine, and I am able to connect to the ftp server. But it returned error when I tried to retrieve files. Here is my code to read the CSV files from server:
import ftplib
import cStringIO
import csv
session = ftplib.FTP('myftpserver.com')
session.login('username','pwd')
session.set_pasv(False)
output = cStringIO.StringIO()
session.retrbinary('RETR myfile.csv', output.write)
csvfile = csv.reader(output.getvalue().splitlines(), delimiter=',')
for i, row in enumerate(csvfile):
print row
And here is the traceback of the error I am getting:
Traceback (most recent call last):
File "/home/vikas/apps/myproj/django/core/handlers/base.py", line 111, in get_response
response = callback(request, *callback_args, **callback_kwargs)
File "/home/vikas/apps/myproj/admin/admin_actions.py", line 3528, in get_ftp_file
session.retrbinary('RETR myfile.csv', output.write)
File "/usr/lib/python2.7/ftplib.py", line 414, in retrbinary
conn = self.transfercmd(cmd, rest)
File "/usr/lib/python2.7/ftplib.py", line 376, in transfercmd
return self.ntransfercmd(cmd, rest)[0]
File "/usr/lib/python2.7/ftplib.py", line 354, in ntransfercmd
sock = self.makeport()
File "/usr/lib/python2.7/ftplib.py", line 283, in makeport
for res in socket.getaddrinfo(None, 0, self.af, socket.SOCK_STREAM, 0, socket.AI_PASSIVE):
File "/home/vikas/gcloud/google-cloud-sdk/platform/google_appengine/google/appengine/api/remote_socket/_remote_socket.py", line 318, in getaddrinfo
raise gaierror(EAI_NONAME, 'nodename nor servname provided, or not known')
gaierror: [Errno 8] nodename nor servname provided, or not known
I have no idea what I have done wrong, none of the commands like dir()
nlst()
etc is working, and the above error occurred as soon as I added them .