Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.
  • Root
  • » Django
  • » I get an error when I used urllib2.urlopen() to open a remote file in a ftp server [RSS Feed]

#1 Jan. 6, 2011 17:33:40

A.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

I get an error when I used urllib2.urlopen() to open a remote file in a ftp server


Hi everybody:

I get an error when I used urllib2.urlopen() to open a remote file in a ftp
server, what I am trying to do is to make a view to force the browser to
download a file to disk instead of playing or displaying it. My code is the
following:

file = 'ftp:/16.168.250.14:2189/RTVE/VIDEOS/Thisisit.wmv'
mydata = urllib2.urlopen(file)
response = HttpResponse(mydata, mimetype='video/mpeg')
response = 'attachment; filename=video.wmv'
response = file
return response

But I get an error 'no host given':

File "/usr/lib/python2.6/urllib2.py", line 126, in urlopen
return _opener.open(url, data, timeout)
File "/usr/lib/python2.6/urllib2.py", line 391, in open
response = self._open(req, data)
File "/usr/lib/python2.6/urllib2.py", line 409, in _open
'_open', req)
File "/usr/lib/python2.6/urllib2.py", line 369, in _call_chain
result = func(*args)
File "/usr/lib/python2.6/urllib2.py", line 1316, in ftp_open
raise URLError('ftp error: no host given')
URLError: <urlopen error ftp error: no host given>

Any idea how to solve this ? Could you help me please ?
Regards
Ariel

--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

#2 Jan. 7, 2011 13:57:31

Scott H.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

I get an error when I used urllib2.urlopen() to open a remote file in a ftp server


>         file = 'ftp:/16.168.250.14:2189/RTVE/VIDEOS/Thisisit.wmv'

Looks like you are missing a second slash before the IP address there.

file = 'ftp://16.168.250.14:2189/RTVE/VIDEOS/Thisisit.wmv'

--
Scott Heberthttp://slaptijack.com/--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

#3 Jan. 7, 2011 14:00:41

D.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

I get an error when I used urllib2.urlopen() to open a remote file in a ftp server


Hi,
you only have 1 forward slash after the ftp: protocol string, you need two:
'ftp:*/*/16.168.250.14:2189/RTVE/VIDEOS/Thisisit.wmv'



--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

  • Root
  • » Django
  • » I get an error when I used urllib2.urlopen() to open a remote file in a ftp server [RSS Feed]

Board footer

Moderator control

Enjoy the 24th of October
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support