Joe Gregorio | ebd0b84 | 2012-06-15 14:14:17 -0400 | [diff] [blame] | 1 | <?xml version="1.0" encoding="ascii"?> |
| 2 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" |
| 3 | "DTD/xhtml1-transitional.dtd"> |
| 4 | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> |
| 5 | <head> |
| 6 | <title>apiclient.http.MediaIoBaseDownload</title> |
| 7 | <link rel="stylesheet" href="epydoc.css" type="text/css" /> |
| 8 | <script type="text/javascript" src="epydoc.js"></script> |
| 9 | </head> |
| 10 | |
| 11 | <body bgcolor="white" text="black" link="blue" vlink="#204080" |
| 12 | alink="#204080"> |
| 13 | <!-- ==================== NAVIGATION BAR ==================== --> |
| 14 | <table class="navbar" border="0" width="100%" cellpadding="0" |
| 15 | bgcolor="#a0c0ff" cellspacing="0"> |
| 16 | <tr valign="middle"> |
| 17 | |
| 18 | <!-- Tree link --> |
| 19 | <th> <a |
| 20 | href="module-tree.html">Trees</a> </th> |
| 21 | |
| 22 | <!-- Index link --> |
| 23 | <th> <a |
| 24 | href="identifier-index.html">Indices</a> </th> |
| 25 | |
| 26 | <!-- Help link --> |
| 27 | <th> <a |
| 28 | href="help.html">Help</a> </th> |
| 29 | |
| 30 | <th class="navbar" width="100%"></th> |
| 31 | </tr> |
| 32 | </table> |
| 33 | <table width="100%" cellpadding="0" cellspacing="0"> |
| 34 | <tr valign="top"> |
| 35 | <td width="100%"> |
| 36 | <span class="breadcrumbs"> |
| 37 | <a href="apiclient-module.html">Package apiclient</a> :: |
| 38 | <a href="apiclient.http-module.html">Module http</a> :: |
| 39 | Class MediaIoBaseDownload |
| 40 | </span> |
| 41 | </td> |
| 42 | <td> |
| 43 | <table cellpadding="0" cellspacing="0"> |
| 44 | <!-- hide/show private --> |
| 45 | <tr><td align="right"><span class="options">[<a href="javascript:void(0);" class="privatelink" |
| 46 | onclick="toggle_private();">hide private</a>]</span></td></tr> |
| 47 | <tr><td align="right"><span class="options" |
| 48 | >[<a href="frames.html" target="_top">frames</a |
| 49 | >] | <a href="apiclient.http.MediaIoBaseDownload-class.html" |
| 50 | target="_top">no frames</a>]</span></td></tr> |
| 51 | </table> |
| 52 | </td> |
| 53 | </tr> |
| 54 | </table> |
| 55 | <!-- ==================== CLASS DESCRIPTION ==================== --> |
| 56 | <h1 class="epydoc">Class MediaIoBaseDownload</h1><p class="nomargin-top"><span class="codelink"><a href="apiclient.http-pysrc.html#MediaIoBaseDownload">source code</a></span></p> |
| 57 | <center> |
Joe Gregorio | 37802c3 | 2013-08-06 12:24:05 -0400 | [diff] [blame^] | 58 | <center> <map id="uml_class_diagram_for_apiclien_27" name="uml_class_diagram_for_apiclien_27"> |
| 59 | <area shape="rect" id="node73" href="apiclient.http.MediaIoBaseDownload-class.html#__init__" title="Constructor." alt="" coords="17,39,397,57"/> |
| 60 | <area shape="rect" id="node73" href="apiclient.http.MediaIoBaseDownload-class.html#next_chunk" title="Get the next chunk of the download." alt="" coords="17,57,397,76"/> |
| 61 | <area shape="rect" id="node1" href="apiclient.http.MediaIoBaseDownload-class.html" title=""Download media resources." alt="" coords="5,6,408,82"/> |
Joe Gregorio | ebd0b84 | 2012-06-15 14:14:17 -0400 | [diff] [blame] | 62 | </map> |
Joe Gregorio | 37802c3 | 2013-08-06 12:24:05 -0400 | [diff] [blame^] | 63 | <img src="uml_class_diagram_for_apiclien_27.gif" alt='' usemap="#uml_class_diagram_for_apiclien_27" ismap="ismap" class="graph-without-title" /> |
Joe Gregorio | ebd0b84 | 2012-06-15 14:14:17 -0400 | [diff] [blame] | 64 | </center> |
| 65 | </center> |
| 66 | <hr /> |
| 67 | <pre class="literalblock"> |
| 68 | "Download media resources. |
| 69 | |
| 70 | Note that the Python file object is compatible with io.Base and can be used |
| 71 | with this class also. |
| 72 | |
| 73 | |
| 74 | Example: |
| 75 | request = farms.animals().get_media(id='cow') |
| 76 | fh = io.FileIO('cow.png', mode='wb') |
| 77 | downloader = MediaIoBaseDownload(fh, request, chunksize=1024*1024) |
| 78 | |
| 79 | done = False |
| 80 | while done is False: |
| 81 | status, done = downloader.next_chunk() |
| 82 | if status: |
| 83 | print "Download %d%%." % int(status.progress() * 100) |
| 84 | print "Download Complete!" |
| 85 | |
| 86 | </pre> |
| 87 | |
| 88 | <!-- ==================== INSTANCE METHODS ==================== --> |
| 89 | <a name="section-InstanceMethods"></a> |
| 90 | <table class="summary" border="1" cellpadding="3" |
| 91 | cellspacing="0" width="100%" bgcolor="white"> |
| 92 | <tr bgcolor="#70b0f0" class="table-header"> |
| 93 | <td colspan="2" class="table-header"> |
| 94 | <table border="0" cellpadding="0" cellspacing="0" width="100%"> |
| 95 | <tr valign="top"> |
| 96 | <td align="left"><span class="table-header">Instance Methods</span></td> |
| 97 | <td align="right" valign="top" |
| 98 | ><span class="options">[<a href="#section-InstanceMethods" |
| 99 | class="privatelink" onclick="toggle_private();" |
| 100 | >hide private</a>]</span></td> |
| 101 | </tr> |
| 102 | </table> |
| 103 | </td> |
| 104 | </tr> |
| 105 | <tr> |
| 106 | <td width="15%" align="right" valign="top" class="summary"> |
| 107 | <span class="summary-type"> </span> |
| 108 | </td><td class="summary"> |
| 109 | <table width="100%" cellpadding="0" cellspacing="0" border="0"> |
| 110 | <tr> |
Joe Gregorio | f4839b0 | 2012-09-06 13:47:24 -0400 | [diff] [blame] | 111 | <td><span class="summary-sig"><a href="apiclient.http.MediaIoBaseDownload-class.html#__init__" class="summary-sig-name">__init__</a>(<span class="summary-sig-arg">self</span>, |
| 112 | <span class="summary-sig-arg">fd</span>, |
| 113 | <span class="summary-sig-arg">request</span>, |
| 114 | <span class="summary-sig-arg">chunksize</span>=<span class="summary-sig-default">DEFAULT_CHUNK_SIZE</span>)</span><br /> |
Joe Gregorio | ebd0b84 | 2012-06-15 14:14:17 -0400 | [diff] [blame] | 115 | Constructor.</td> |
| 116 | <td align="right" valign="top"> |
Joe Gregorio | f4839b0 | 2012-09-06 13:47:24 -0400 | [diff] [blame] | 117 | <span class="codelink"><a href="apiclient.http-pysrc.html#MediaIoBaseDownload.__init__">source code</a></span> |
Joe Gregorio | ebd0b84 | 2012-06-15 14:14:17 -0400 | [diff] [blame] | 118 | |
| 119 | </td> |
| 120 | </tr> |
| 121 | </table> |
| 122 | |
| 123 | </td> |
| 124 | </tr> |
| 125 | <tr> |
| 126 | <td width="15%" align="right" valign="top" class="summary"> |
| 127 | <span class="summary-type"> </span> |
| 128 | </td><td class="summary"> |
| 129 | <table width="100%" cellpadding="0" cellspacing="0" border="0"> |
| 130 | <tr> |
Joe Gregorio | 37802c3 | 2013-08-06 12:24:05 -0400 | [diff] [blame^] | 131 | <td><span class="summary-sig"><a href="apiclient.http.MediaIoBaseDownload-class.html#next_chunk" class="summary-sig-name">next_chunk</a>(<span class="summary-sig-arg">self</span>, |
| 132 | <span class="summary-sig-arg">num_retries</span>=<span class="summary-sig-default">0</span>)</span><br /> |
Joe Gregorio | ebd0b84 | 2012-06-15 14:14:17 -0400 | [diff] [blame] | 133 | Get the next chunk of the download.</td> |
| 134 | <td align="right" valign="top"> |
| 135 | <span class="codelink"><a href="apiclient.http-pysrc.html#MediaIoBaseDownload.next_chunk">source code</a></span> |
| 136 | |
| 137 | </td> |
| 138 | </tr> |
| 139 | </table> |
| 140 | |
| 141 | </td> |
| 142 | </tr> |
| 143 | <tr> |
| 144 | <td colspan="2" class="summary"> |
| 145 | <p class="indent-wrapped-lines"><b>Inherited from <code>object</code></b>: |
| 146 | <code>__delattr__</code>, |
| 147 | <code>__format__</code>, |
| 148 | <code>__getattribute__</code>, |
| 149 | <code>__hash__</code>, |
| 150 | <code>__new__</code>, |
| 151 | <code>__reduce__</code>, |
| 152 | <code>__reduce_ex__</code>, |
| 153 | <code>__repr__</code>, |
| 154 | <code>__setattr__</code>, |
| 155 | <code>__sizeof__</code>, |
| 156 | <code>__str__</code>, |
| 157 | <code>__subclasshook__</code> |
| 158 | </p> |
| 159 | </td> |
| 160 | </tr> |
| 161 | </table> |
| 162 | <!-- ==================== PROPERTIES ==================== --> |
| 163 | <a name="section-Properties"></a> |
| 164 | <table class="summary" border="1" cellpadding="3" |
| 165 | cellspacing="0" width="100%" bgcolor="white"> |
| 166 | <tr bgcolor="#70b0f0" class="table-header"> |
| 167 | <td colspan="2" class="table-header"> |
| 168 | <table border="0" cellpadding="0" cellspacing="0" width="100%"> |
| 169 | <tr valign="top"> |
| 170 | <td align="left"><span class="table-header">Properties</span></td> |
| 171 | <td align="right" valign="top" |
| 172 | ><span class="options">[<a href="#section-Properties" |
| 173 | class="privatelink" onclick="toggle_private();" |
| 174 | >hide private</a>]</span></td> |
| 175 | </tr> |
| 176 | </table> |
| 177 | </td> |
| 178 | </tr> |
| 179 | <tr> |
| 180 | <td colspan="2" class="summary"> |
| 181 | <p class="indent-wrapped-lines"><b>Inherited from <code>object</code></b>: |
| 182 | <code>__class__</code> |
| 183 | </p> |
| 184 | </td> |
| 185 | </tr> |
| 186 | </table> |
| 187 | <!-- ==================== METHOD DETAILS ==================== --> |
| 188 | <a name="section-MethodDetails"></a> |
| 189 | <table class="details" border="1" cellpadding="3" |
| 190 | cellspacing="0" width="100%" bgcolor="white"> |
| 191 | <tr bgcolor="#70b0f0" class="table-header"> |
| 192 | <td colspan="2" class="table-header"> |
| 193 | <table border="0" cellpadding="0" cellspacing="0" width="100%"> |
| 194 | <tr valign="top"> |
| 195 | <td align="left"><span class="table-header">Method Details</span></td> |
| 196 | <td align="right" valign="top" |
| 197 | ><span class="options">[<a href="#section-MethodDetails" |
| 198 | class="privatelink" onclick="toggle_private();" |
| 199 | >hide private</a>]</span></td> |
| 200 | </tr> |
| 201 | </table> |
| 202 | </td> |
| 203 | </tr> |
| 204 | </table> |
| 205 | <a name="__init__"></a> |
| 206 | <div> |
| 207 | <table class="details" border="1" cellpadding="3" |
| 208 | cellspacing="0" width="100%" bgcolor="white"> |
| 209 | <tr><td> |
| 210 | <table width="100%" cellpadding="0" cellspacing="0" border="0"> |
| 211 | <tr valign="top"><td> |
Joe Gregorio | f4839b0 | 2012-09-06 13:47:24 -0400 | [diff] [blame] | 212 | <h3 class="epydoc"><span class="sig"><span class="sig-name">__init__</span>(<span class="sig-arg">self</span>, |
| 213 | <span class="sig-arg">fd</span>, |
| 214 | <span class="sig-arg">request</span>, |
| 215 | <span class="sig-arg">chunksize</span>=<span class="sig-default">DEFAULT_CHUNK_SIZE</span>)</span> |
Joe Gregorio | ebd0b84 | 2012-06-15 14:14:17 -0400 | [diff] [blame] | 216 | <br /><em class="fname">(Constructor)</em> |
| 217 | </h3> |
| 218 | </td><td align="right" valign="top" |
Joe Gregorio | f4839b0 | 2012-09-06 13:47:24 -0400 | [diff] [blame] | 219 | ><span class="codelink"><a href="apiclient.http-pysrc.html#MediaIoBaseDownload.__init__">source code</a></span> |
Joe Gregorio | ebd0b84 | 2012-06-15 14:14:17 -0400 | [diff] [blame] | 220 | </td> |
| 221 | </tr></table> |
| 222 | |
| 223 | <pre class="literalblock"> |
| 224 | Constructor. |
| 225 | |
| 226 | Args: |
Joe Gregorio | fa08c2e | 2012-07-23 16:52:03 -0400 | [diff] [blame] | 227 | fd: io.Base or file object, The stream in which to write the downloaded |
Joe Gregorio | ebd0b84 | 2012-06-15 14:14:17 -0400 | [diff] [blame] | 228 | bytes. |
| 229 | request: apiclient.http.HttpRequest, the media request to perform in |
| 230 | chunks. |
| 231 | chunksize: int, File will be downloaded in chunks of this many bytes. |
| 232 | |
| 233 | </pre> |
| 234 | <dl class="fields"> |
Joe Gregorio | 1b425aa | 2012-08-24 12:04:34 -0400 | [diff] [blame] | 235 | <dt>Decorators:</dt> |
| 236 | <dd><ul class="nomargin-top"> |
| 237 | <li><code>@util.positional(3)</code></li> |
| 238 | </ul></dd> |
Joe Gregorio | ebd0b84 | 2012-06-15 14:14:17 -0400 | [diff] [blame] | 239 | <dt>Overrides: |
| 240 | object.__init__ |
| 241 | </dt> |
| 242 | </dl> |
| 243 | </td></tr></table> |
| 244 | </div> |
| 245 | <a name="next_chunk"></a> |
| 246 | <div> |
| 247 | <table class="details" border="1" cellpadding="3" |
| 248 | cellspacing="0" width="100%" bgcolor="white"> |
| 249 | <tr><td> |
| 250 | <table width="100%" cellpadding="0" cellspacing="0" border="0"> |
| 251 | <tr valign="top"><td> |
Joe Gregorio | 37802c3 | 2013-08-06 12:24:05 -0400 | [diff] [blame^] | 252 | <h3 class="epydoc"><span class="sig"><span class="sig-name">next_chunk</span>(<span class="sig-arg">self</span>, |
| 253 | <span class="sig-arg">num_retries</span>=<span class="sig-default">0</span>)</span> |
Joe Gregorio | ebd0b84 | 2012-06-15 14:14:17 -0400 | [diff] [blame] | 254 | </h3> |
| 255 | </td><td align="right" valign="top" |
| 256 | ><span class="codelink"><a href="apiclient.http-pysrc.html#MediaIoBaseDownload.next_chunk">source code</a></span> |
| 257 | </td> |
| 258 | </tr></table> |
| 259 | |
| 260 | <pre class="literalblock"> |
| 261 | Get the next chunk of the download. |
| 262 | |
Joe Gregorio | 37802c3 | 2013-08-06 12:24:05 -0400 | [diff] [blame^] | 263 | Args: |
| 264 | num_retries: Integer, number of times to retry 500's with randomized |
| 265 | exponential backoff. If all retries fail, the raised HttpError |
| 266 | represents the last request. If zero (default), we attempt the |
| 267 | request only once. |
| 268 | |
Joe Gregorio | ebd0b84 | 2012-06-15 14:14:17 -0400 | [diff] [blame] | 269 | Returns: |
| 270 | (status, done): (MediaDownloadStatus, boolean) |
| 271 | The value of 'done' will be True when the media has been fully |
| 272 | downloaded. |
| 273 | |
| 274 | Raises: |
| 275 | apiclient.errors.HttpError if the response was not a 2xx. |
Joe Gregorio | ad8013f | 2012-08-03 08:44:02 -0400 | [diff] [blame] | 276 | httplib2.HttpLib2Error if a transport error has occured. |
Joe Gregorio | ebd0b84 | 2012-06-15 14:14:17 -0400 | [diff] [blame] | 277 | |
| 278 | </pre> |
| 279 | <dl class="fields"> |
Joe Gregorio | 37802c3 | 2013-08-06 12:24:05 -0400 | [diff] [blame^] | 280 | <dt>Decorators:</dt> |
| 281 | <dd><ul class="nomargin-top"> |
| 282 | <li><code>@util.positional(1)</code></li> |
| 283 | </ul></dd> |
Joe Gregorio | ebd0b84 | 2012-06-15 14:14:17 -0400 | [diff] [blame] | 284 | </dl> |
| 285 | </td></tr></table> |
| 286 | </div> |
| 287 | <br /> |
| 288 | <!-- ==================== NAVIGATION BAR ==================== --> |
| 289 | <table class="navbar" border="0" width="100%" cellpadding="0" |
| 290 | bgcolor="#a0c0ff" cellspacing="0"> |
| 291 | <tr valign="middle"> |
| 292 | |
| 293 | <!-- Tree link --> |
| 294 | <th> <a |
| 295 | href="module-tree.html">Trees</a> </th> |
| 296 | |
| 297 | <!-- Index link --> |
| 298 | <th> <a |
| 299 | href="identifier-index.html">Indices</a> </th> |
| 300 | |
| 301 | <!-- Help link --> |
| 302 | <th> <a |
| 303 | href="help.html">Help</a> </th> |
| 304 | |
| 305 | <th class="navbar" width="100%"></th> |
| 306 | </tr> |
| 307 | </table> |
| 308 | <table border="0" cellpadding="0" cellspacing="0" width="100%%"> |
| 309 | <tr> |
| 310 | <td align="left" class="footer"> |
Joe Gregorio | 37802c3 | 2013-08-06 12:24:05 -0400 | [diff] [blame^] | 311 | Generated by Epydoc 3.0.1 on Tue Aug 6 12:16:44 2013 |
Joe Gregorio | ebd0b84 | 2012-06-15 14:14:17 -0400 | [diff] [blame] | 312 | </td> |
| 313 | <td align="right" class="footer"> |
| 314 | <a target="mainFrame" href="http://epydoc.sourceforge.net" |
| 315 | >http://epydoc.sourceforge.net</a> |
| 316 | </td> |
| 317 | </tr> |
| 318 | </table> |
| 319 | |
| 320 | <script type="text/javascript"> |
| 321 | <!-- |
| 322 | // Private objects are initially displayed (because if |
| 323 | // javascript is turned off then we want them to be |
| 324 | // visible); but by default, we want to hide them. So hide |
| 325 | // them unless we have a cookie that says to show them. |
| 326 | checkCookie(); |
| 327 | // --> |
| 328 | </script> |
| 329 | </body> |
| 330 | </html> |