Exemplo n.º 1
0
def __extract_host_path( host, filename ):
   """
   <Purpose>
      Extracts the path components from the host and prepends them to the filename.

   <Arguments>
       host:
         'host' holds two things, a server name and target directory.
         For example, if you want to retrieve files from '/tmp/' directory
         in 'quadrus.cs.arizona.edu' server, the 'host' will be
         'quadrus.cs.arizona.edu/tmp'.
      filename:
         'filename' holds the base name of the file

   <Exceptions>
      None.

   <Side Effects>
      None.

   <Returns>
      The hostname and the path + filename strings
   """
   
   # remove the protocol if there is one
   host = arizonageneral.lcut(host, "http://")
   host = arizonageneral.lcut(host, "https://")
   host = arizonageneral.lcut(host, "ftp://")
   
   index=host.find("/")

   hostname = ""
   pathname = ""
   
   # set hostname to hold only a server name
   if index != -1:
      hostname = host[:index]
      pathname = host[index:]
   else :
      hostname = host

   return (hostname, os.path.join( pathname, filename ))
Exemplo n.º 2
0
def __extract_hostname(host):
   """
   <Purpose>
      Extracts the hostname from a host string

   <Arguments>
       host:
         'host' holds two things, a server name and target directory.
         For example, if you want to retrieve files from '/tmp/' directory
         in 'quadrus.cs.arizona.edu' server, the 'host' will be
         'quadrus.cs.arizona.edu/tmp'.

   <Exceptions>
      None.

   <Side Effects>
      None.

   <Returns>
      The hostname
   """

   # remove the protocol if there is one
   host = arizonageneral.lcut(host, "http://")
   host = arizonageneral.lcut(host, "https://")
   host = arizonageneral.lcut(host, "ftp://")

   index=host.find("/")

   # set hostname to hold only a server name
   if index != -1:
      hostname = host[:index]
   else :
      hostname = host

   return hostname
Exemplo n.º 3
0
def _strip_protocol(s):
   s = arizonageneral.lcut(s, "http://")
   s = arizonageneral.lcut(s, "https://")
   s = arizonageneral.lcut(s, "ftp://")
   return s