Vega strike Python Modules doc  0.5.1
Documentation of the " Modules " folder of Vega strike
 All Data Structures Namespaces Files Functions Variables
FTPHandler Class Reference
Inheritance diagram for FTPHandler:
BaseHandler CacheFTPHandler

Public Member Functions

def ftp_open
 
def connect_ftp
 
- Public Member Functions inherited from BaseHandler
def add_parent
 
def close
 

Additional Inherited Members

- Data Fields inherited from BaseHandler
 parent
 

Detailed Description

Definition at line 895 of file urllib2.py.

Member Function Documentation

def connect_ftp (   self,
  user,
  passwd,
  host,
  port,
  dirs 
)

Definition at line 936 of file urllib2.py.

937  def connect_ftp(self, user, passwd, host, port, dirs):
fw = ftpwrapper(user, passwd, host, port, dirs)
def ftp_open (   self,
  req 
)

Definition at line 896 of file urllib2.py.

References FTPHandler.connect_ftp(), mimetypes.guess_type(), urllib.splitattr(), urllib.splitport(), and rfc822.unquote().

897  def ftp_open(self, req):
898  host = req.get_host()
899  if not host:
900  raise IOError, ('ftp error', 'no host given')
901  # XXX handle custom username & password
902  try:
903  host = socket.gethostbyname(host)
904  except socket.error, msg:
905  raise URLError(msg)
906  host, port = splitport(host)
907  if port is None:
908  port = ftplib.FTP_PORT
909  path, attrs = splitattr(req.get_selector())
910  path = unquote(path)
911  dirs = path.split('/')
912  dirs, file = dirs[:-1], dirs[-1]
913  if dirs and not dirs[0]:
914  dirs = dirs[1:]
915  user = passwd = '' # XXX
916  try:
917  fw = self.connect_ftp(user, passwd, host, port, dirs)
918  type = file and 'I' or 'D'
919  for attr in attrs:
920  attr, value = splitattr(attr)
921  if attr.lower() == 'type' and \
922  value in ('a', 'A', 'i', 'I', 'd', 'D'):
923  type = value.upper()
924  fp, retrlen = fw.retrfile(file, type)
925  headers = ""
926  mtype = mimetypes.guess_type(req.get_full_url())[0]
927  if mtype:
928  headers += "Content-Type: %s\n" % mtype
929  if retrlen is not None and retrlen >= 0:
930  headers += "Content-Length: %d\n" % retrlen
931  sf = StringIO(headers)
932  headers = mimetools.Message(sf)
933  return addinfourl(fp, headers, req.get_full_url())
934  except ftplib.all_errors, msg:
935  raise IOError, ('ftp error', msg), sys.exc_info()[2]

The documentation for this class was generated from the following file: