-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
47 changed files
with
1,893 additions
and
541 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Sphinx build info version 1 | ||
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. | ||
config: 864aef17626eb911700f18d511ce68de | ||
tags: 645f666f9bcd5a90fca523b33c5a78b7 | ||
config: c0831ea5325cface34c44033ee43d950 | ||
tags: fbb0d17656682115ca4d033fb2f83ba1 |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
|
||
|
||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" | ||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | ||
|
||
|
@@ -104,7 +106,7 @@ <h3>Navigation</h3> | |
</div> | ||
<div class="footer"> | ||
© Copyright 2013, Dennis Ploeger <[email protected]>. | ||
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2.3. | ||
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3. | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
|
||
|
||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" | ||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | ||
|
||
|
@@ -49,12 +51,24 @@ <h3>Navigation</h3> | |
<h1>Source code for pythonzimbra.communication</h1><div class="highlight"><pre> | ||
<span class="sd">""" Zimbra communication handler. """</span> | ||
|
||
<span class="kn">import</span> <span class="nn">urllib2</span> | ||
<span class="kn">from</span> <span class="nn">__future__</span> <span class="kn">import</span> <span class="n">unicode_literals</span> | ||
|
||
<span class="kn">import</span> <span class="nn">sys</span> | ||
|
||
<span class="c"># Py2-Compatibility</span> | ||
|
||
<span class="k">if</span> <span class="n">sys</span><span class="o">.</span><span class="n">version</span> <span class="o"><</span> <span class="s">'3'</span><span class="p">:</span> | ||
<span class="kn">import</span> <span class="nn">urllib2</span> <span class="kn">as</span> <span class="nn">ur</span> <span class="c"># pragma: no cover py3</span> | ||
<span class="kn">import</span> <span class="nn">urllib2</span> <span class="kn">as</span> <span class="nn">ue</span> <span class="c"># pragma: no cover py3</span> | ||
<span class="k">else</span><span class="p">:</span> | ||
<span class="kn">import</span> <span class="nn">urllib.request</span> <span class="kn">as</span> <span class="nn">ur</span> <span class="c"># pragma: no cover py2</span> | ||
<span class="kn">import</span> <span class="nn">urllib.error</span> <span class="kn">as</span> <span class="nn">ue</span> <span class="c"># pragma: no cover py2</span> | ||
|
||
<span class="kn">from</span> <span class="nn">pythonzimbra.request_json</span> <span class="kn">import</span> <span class="n">RequestJson</span> | ||
<span class="kn">from</span> <span class="nn">pythonzimbra.request_xml</span> <span class="kn">import</span> <span class="n">RequestXml</span> | ||
<span class="kn">from</span> <span class="nn">pythonzimbra.response_xml</span> <span class="kn">import</span> <span class="n">ResponseXml</span> | ||
<span class="kn">from</span> <span class="nn">pythonzimbra.response_json</span> <span class="kn">import</span> <span class="n">ResponseJson</span> | ||
<span class="kn">from</span> <span class="nn">exceptions.communication</span> <span class="kn">import</span> <span class="o">*</span> | ||
<span class="kn">from</span> <span class="nn">.exceptions.communication</span> <span class="kn">import</span> <span class="o">*</span> | ||
|
||
|
||
<div class="viewcode-block" id="Communication"><a class="viewcode-back" href="../../pythonzimbra.html#pythonzimbra.communication.Communication">[docs]</a><span class="k">class</span> <span class="nc">Communication</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span> | ||
|
@@ -82,8 +96,14 @@ <h1>Source code for pythonzimbra.communication</h1><div class="highlight"><pre> | |
<span class="bp">self</span><span class="o">.</span><span class="n">url</span> <span class="o">=</span> <span class="n">url</span> | ||
<span class="bp">self</span><span class="o">.</span><span class="n">timeout</span> <span class="o">=</span> <span class="n">timeout</span> | ||
|
||
<span class="k">if</span> <span class="n">sys</span><span class="o">.</span><span class="n">version</span> <span class="o"><</span> <span class="s">'3'</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">url</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s">"https"</span><span class="p">):</span> | ||
|
||
<span class="c"># Force tlsv1 on https-requests in Python 2</span> | ||
|
||
<span class="kn">import</span> <span class="nn">tools.urllib2_tls</span> <span class="c"># pragma: no cover py3</span> | ||
|
||
<div class="viewcode-block" id="Communication.gen_request"><a class="viewcode-back" href="../../pythonzimbra.html#pythonzimbra.communication.Communication.gen_request">[docs]</a> <span class="k">def</span> <span class="nf">gen_request</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">request_type</span><span class="o">=</span><span class="s">"json"</span><span class="p">,</span> <span class="n">token</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span> <span class="n">set_batch</span><span class="o">=</span><span class="bp">False</span><span class="p">,</span> | ||
<span class="n">batch_onerror</span><span class="o">=</span><span class="bp">None</span><span class="p">):</span> | ||
<span class="n">batch_onerror</span><span class="o">=</span><span class="bp">None</span><span class="p">):</span> | ||
|
||
<span class="sd">""" Convenience method to quickly generate a token</span> | ||
|
||
|
@@ -106,7 +126,7 @@ <h1>Source code for pythonzimbra.communication</h1><div class="highlight"><pre> | |
|
||
<span class="k">raise</span> <span class="n">UnknownRequestType</span><span class="p">()</span> | ||
|
||
<span class="k">if</span> <span class="ow">not</span> <span class="n">token</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span> | ||
<span class="k">if</span> <span class="n">token</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span> | ||
<span class="n">local_request</span><span class="o">.</span><span class="n">set_auth_token</span><span class="p">(</span><span class="n">token</span><span class="p">)</span> | ||
|
||
<span class="k">if</span> <span class="n">set_batch</span><span class="p">:</span> | ||
|
@@ -150,33 +170,47 @@ <h1>Source code for pythonzimbra.communication</h1><div class="highlight"><pre> | |
|
||
<span class="k">try</span><span class="p">:</span> | ||
|
||
<span class="n">server_request</span> <span class="o">=</span> <span class="n">urllib2</span><span class="o">.</span><span class="n">urlopen</span><span class="p">(</span> | ||
<span class="n">server_request</span> <span class="o">=</span> <span class="n">ur</span><span class="o">.</span><span class="n">urlopen</span><span class="p">(</span> | ||
<span class="bp">self</span><span class="o">.</span><span class="n">url</span><span class="p">,</span> | ||
<span class="n">request</span><span class="o">.</span><span class="n">get_request</span><span class="p">(),</span> | ||
<span class="n">request</span><span class="o">.</span><span class="n">get_request</span><span class="p">()</span><span class="o">.</span><span class="n">encode</span><span class="p">(</span><span class="s">"utf-8"</span><span class="p">),</span> | ||
<span class="bp">self</span><span class="o">.</span><span class="n">timeout</span> | ||
<span class="p">)</span> | ||
|
||
<span class="n">server_response</span> <span class="o">=</span> <span class="n">server_request</span><span class="o">.</span><span class="n">read</span><span class="p">()</span> | ||
|
||
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">server_response</span><span class="p">,</span> <span class="nb">bytes</span><span class="p">):</span> | ||
|
||
<span class="n">server_response</span> <span class="o">=</span> <span class="n">server_response</span><span class="o">.</span><span class="n">decode</span><span class="p">(</span><span class="s">"utf-8"</span><span class="p">)</span> | ||
|
||
<span class="k">if</span> <span class="n">response</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span> | ||
|
||
<span class="n">local_response</span><span class="o">.</span><span class="n">set_response</span><span class="p">(</span><span class="n">server_request</span><span class="o">.</span><span class="n">read</span><span class="p">())</span> | ||
<span class="n">local_response</span><span class="o">.</span><span class="n">set_response</span><span class="p">(</span> | ||
<span class="n">server_response</span> | ||
<span class="p">)</span> | ||
|
||
<span class="k">else</span><span class="p">:</span> | ||
|
||
<span class="n">response</span><span class="o">.</span><span class="n">set_response</span><span class="p">(</span><span class="n">server_request</span><span class="o">.</span><span class="n">read</span><span class="p">())</span> | ||
<span class="n">response</span><span class="o">.</span><span class="n">set_response</span><span class="p">(</span><span class="n">server_response</span><span class="p">)</span> | ||
|
||
<span class="k">except</span> <span class="n">urllib2</span><span class="o">.</span><span class="n">HTTPError</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span> | ||
<span class="k">except</span> <span class="n">ue</span><span class="o">.</span><span class="n">HTTPError</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span> | ||
|
||
<span class="k">if</span> <span class="n">e</span><span class="o">.</span><span class="n">code</span> <span class="o">==</span> <span class="mi">500</span><span class="p">:</span> | ||
|
||
<span class="c"># 500 codes normally returns a SoapFault, that we can use</span> | ||
|
||
<span class="n">server_response</span> <span class="o">=</span> <span class="n">e</span><span class="o">.</span><span class="n">fp</span><span class="o">.</span><span class="n">read</span><span class="p">()</span> | ||
|
||
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">server_response</span><span class="p">,</span> <span class="nb">bytes</span><span class="p">):</span> | ||
|
||
<span class="n">server_response</span> <span class="o">=</span> <span class="n">server_response</span><span class="o">.</span><span class="n">decode</span><span class="p">(</span><span class="s">"utf-8"</span><span class="p">)</span> | ||
|
||
<span class="k">if</span> <span class="n">response</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span> | ||
|
||
<span class="n">local_response</span><span class="o">.</span><span class="n">set_response</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">fp</span><span class="o">.</span><span class="n">read</span><span class="p">())</span> | ||
<span class="n">local_response</span><span class="o">.</span><span class="n">set_response</span><span class="p">(</span><span class="n">server_response</span><span class="p">)</span> | ||
|
||
<span class="k">else</span><span class="p">:</span> | ||
|
||
<span class="n">response</span><span class="o">.</span><span class="n">set_response</span><span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="n">fp</span><span class="o">.</span><span class="n">read</span><span class="p">())</span> | ||
<span class="n">response</span><span class="o">.</span><span class="n">set_response</span><span class="p">(</span><span class="n">server_response</span><span class="p">)</span> | ||
|
||
<span class="k">else</span><span class="p">:</span> | ||
|
||
|
@@ -223,7 +257,7 @@ <h3>Navigation</h3> | |
</div> | ||
<div class="footer"> | ||
© Copyright 2013, Dennis Ploeger <[email protected]>. | ||
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2.3. | ||
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3. | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
|
||
|
||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" | ||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | ||
|
||
|
@@ -49,24 +51,22 @@ <h3>Navigation</h3> | |
<h1>Source code for pythonzimbra.exceptions.request</h1><div class="highlight"><pre> | ||
<span class="sd">""" Request exceptions """</span> | ||
|
||
<span class="kn">import</span> <span class="nn">exceptions</span> | ||
|
||
|
||
<div class="viewcode-block" id="RequestHeaderContextException"><a class="viewcode-back" href="../../../pythonzimbra.exceptions.html#pythonzimbra.exceptions.request.RequestHeaderContextException">[docs]</a><span class="k">class</span> <span class="nc">RequestHeaderContextException</span><span class="p">(</span><span class="n">exceptions</span><span class="o">.</span><span class="n">BaseException</span><span class="p">):</span> | ||
<div class="viewcode-block" id="RequestHeaderContextException"><a class="viewcode-back" href="../../../pythonzimbra.exceptions.html#pythonzimbra.exceptions.request.RequestHeaderContextException">[docs]</a><span class="k">class</span> <span class="nc">RequestHeaderContextException</span><span class="p">(</span><span class="ne">Exception</span><span class="p">):</span> | ||
|
||
<span class="sd">""" Invalid context parameter specified</span> | ||
|
||
<span class="sd"> """</span> | ||
|
||
<span class="k">pass</span> | ||
<span class="k">pass</span> <span class="c"># pragma: no cover</span> | ||
|
||
</div> | ||
<div class="viewcode-block" id="NoNamespaceGiven"><a class="viewcode-back" href="../../../pythonzimbra.exceptions.html#pythonzimbra.exceptions.request.NoNamespaceGiven">[docs]</a><span class="k">class</span> <span class="nc">NoNamespaceGiven</span><span class="p">(</span><span class="n">exceptions</span><span class="o">.</span><span class="n">BaseException</span><span class="p">):</span> | ||
<div class="viewcode-block" id="NoNamespaceGiven"><a class="viewcode-back" href="../../../pythonzimbra.exceptions.html#pythonzimbra.exceptions.request.NoNamespaceGiven">[docs]</a><span class="k">class</span> <span class="nc">NoNamespaceGiven</span><span class="p">(</span><span class="ne">Exception</span><span class="p">):</span> | ||
|
||
<span class="sd">""" No namespace specified, when it should be</span> | ||
<span class="sd"> """</span> | ||
|
||
<span class="k">pass</span></div> | ||
<span class="k">pass</span> <span class="c"># pragma: no cover</span></div> | ||
</pre></div> | ||
|
||
</div> | ||
|
@@ -106,7 +106,7 @@ <h3>Navigation</h3> | |
</div> | ||
<div class="footer"> | ||
© Copyright 2013, Dennis Ploeger <[email protected]>. | ||
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2.3. | ||
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3. | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
|
||
|
||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" | ||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | ||
|
||
|
@@ -98,7 +100,7 @@ <h1>Source code for pythonzimbra.request</h1><div class="highlight"><pre> | |
<span class="sd"> :param params: A Dict containing context parameters.</span> | ||
<span class="sd"> """</span> | ||
|
||
<span class="k">for</span> <span class="n">key</span><span class="p">,</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">params</span><span class="o">.</span><span class="n">iteritems</span><span class="p">():</span> | ||
<span class="k">for</span> <span class="n">key</span><span class="p">,</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">params</span><span class="o">.</span><span class="n">items</span><span class="p">():</span> | ||
|
||
<span class="k">if</span> <span class="n">key</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">valid_context_params</span><span class="p">:</span> | ||
|
||
|
@@ -144,7 +146,7 @@ <h1>Source code for pythonzimbra.request</h1><div class="highlight"><pre> | |
<span class="sd"> The params are like in enable_batch</span> | ||
<span class="sd"> """</span> | ||
|
||
<span class="k">pass</span> | ||
<span class="k">pass</span> <span class="c"># pragma: no cover</span> | ||
|
||
<div class="viewcode-block" id="Request.add_request"><a class="viewcode-back" href="../../pythonzimbra.html#pythonzimbra.request.Request.add_request">[docs]</a> <span class="k">def</span> <span class="nf">add_request</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">request_name</span><span class="p">,</span> <span class="n">request_dict</span><span class="p">,</span> <span class="n">namespace</span><span class="p">):</span> | ||
|
||
|
@@ -167,20 +169,20 @@ <h1>Source code for pythonzimbra.request</h1><div class="highlight"><pre> | |
|
||
<span class="c"># Currently no checks</span> | ||
|
||
<span class="k">pass</span> | ||
<span class="k">pass</span> <span class="c"># pragma: no cover</span> | ||
</div> | ||
<div class="viewcode-block" id="Request.get_request"><a class="viewcode-back" href="../../pythonzimbra.html#pythonzimbra.request.Request.get_request">[docs]</a> <span class="k">def</span> <span class="nf">get_request</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> | ||
|
||
<span class="sd">""" Return the request in the native form.</span> | ||
<span class="sd"> """</span> | ||
|
||
<span class="k">pass</span> | ||
<span class="k">pass</span> <span class="c"># pragma: no cover</span> | ||
</div> | ||
<span class="k">def</span> <span class="nf">__str__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> | ||
<span class="k">return</span> <span class="nb">unicode</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="n">encode</span><span class="p">(</span><span class="s">'utf-8'</span><span class="p">)</span> | ||
<span class="k">return</span> <span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="n">encode</span><span class="p">(</span><span class="s">'utf-8'</span><span class="p">)</span> <span class="c"># pragma: no cover</span> | ||
|
||
<span class="k">def</span> <span class="nf">__unicode__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> | ||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_request</span><span class="p">()</span></div> | ||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_request</span><span class="p">()</span> <span class="c"># pragma: no cover</span></div> | ||
</pre></div> | ||
|
||
</div> | ||
|
@@ -220,7 +222,7 @@ <h3>Navigation</h3> | |
</div> | ||
<div class="footer"> | ||
© Copyright 2013, Dennis Ploeger <[email protected]>. | ||
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2.3. | ||
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3. | ||
</div> | ||
</body> | ||
</html> |
Oops, something went wrong.