Classes | |
| class | UpdateXMLIndex_Handler |
Functions | |
| def | open_gzurl |
| def | retrieve_from_mirror |
| def | gzretrieve_from_mirror |
| def | read_XMLIndex |
| def py::qo::network::gzretrieve_from_mirror | ( | mirrors, | ||
| uri, | ||||
| dest | ||||
| ) |
00063 : 00064 mirror = mirrors[0].strip('/') 00065 orig = open_gzurl("%s%s" % (mirror, uri)) 00066 try : 00067 fd = open(dest, 'wb') 00068 try : 00069 shutil.copyfileobj(orig, fd) 00070 finally : 00071 fd.close() 00072 finally : 00073 orig.close() 00074 00075 class UpdateXMLIndex_Handler( ContentHandler ) :
| def py::qo::network::open_gzurl | ( | url | ) |
Open a gziped file at url \param url url to open \return a file-like object ( GzipFile )
00032 : 00033 """Open a gziped file at url 00034 00035 \param url url to open 00036 \return a file-like object ( GzipFile ) 00037 """ 00038 00039 fd = urllib2.urlopen( url ) 00040 buf = StringIO() 00041 buf.write( fd.read() ) 00042 buf.seek( 0, 0 ) 00043 fd.close() 00044 00045 gfd = GzipFile( fileobj = copy.deepcopy( buf ) ) 00046 buf.close() 00047 00048 return gfd 00049 00050 def retrieve_from_mirror( mirrors, uri, dest ) :
| def py::qo::network::read_XMLIndex | ( | path, | ||
| mirrors | ||||
| ) |
00110 : 00111 00112 # change mirror 00113 mirror = mirrors[0] 00114 00115 parser = make_parser() 00116 content = UpdateXMLIndex_Handler() 00117 parser.setContentHandler( content ) 00118 00119 fd = open_gzurl( mirror+path ) 00120 00121 parser.parse( fd ) 00122 fd.close() 00123 del parser 00124 00125 return ( content.version, content.obsolete == "1", content.files, content.fix ) 00126 00127
| def py::qo::network::retrieve_from_mirror | ( | mirrors, | ||
| uri, | ||||
| dest | ||||
| ) |
00051 : 00052 mirror = mirrors[0].strip('/') 00053 orig = urllib2.urlopen("%s%s" % (mirror,uri)) 00054 try : 00055 fd = open(dest, 'wb') 00056 try : 00057 shutil.copyfileobj(orig, fd) 00058 finally : 00059 fd.close() 00060 finally : 00061 orig.close() 00062 def gzretrieve_from_mirror( mirrors, uri, dest ) :
1.5.3