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