Project

General

Profile

Revision 6

View differences:

uporaba.html
46 46
            
47 47
  <div class="section" id="uporaba">
48 48
<h1>Uporaba<a class="headerlink" href="#uporaba" title="Povezava na naslov">¶</a></h1>
49
<p>Primeri uporabe web servisa za Python in SOAP knjižico Suds, ki jo namestimo z:</p>
49
<p>Primeri uporabe web servisa za Python in SOAP knjižico <a class="reference external" href="https://fedorahosted.org/suds/">SUDS</a>, ki jo namestimo z:</p>
50 50
<div class="highlight-python"><pre>sudo easy_install suds</pre>
51 51
</div>
52
<div class="section" id="avtentikacija">
53
<h2>Avtentikacija<a class="headerlink" href="#avtentikacija" title="Povezava na naslov">¶</a></h2>
52
<div class="section" id="nadzorni-modul">
53
<h2>Nadzorni modul<a class="headerlink" href="#nadzorni-modul" title="Povezava na naslov">¶</a></h2>
54
<p>Nadozrni modul skrbi za dostop do naprave.</p>
54 55
<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">suds.client</span> <span class="kn">import</span> <span class="n">Client</span>
55
<span class="n">url</span> <span class="o">=</span> <span class="s">&#39;http://&lt;webservice_host&gt;/lidar/LIDAR?wsdl&#39;</span>
56 56
<span class="n">client</span> <span class="o">=</span> <span class="n">Client</span><span class="p">(</span><span class="n">url</span><span class="p">)</span>
57 57

  
58
<span class="n">auth_token</span> <span class="o">=</span> <span class="n">client</span><span class="o">.</span><span class="n">service</span><span class="o">.</span><span class="n">getAuthenticationToken</span><span class="p">(</span><span class="s">&#39;&lt;api_key&gt;&#39;</span><span class="p">,</span> <span class="s">&#39;&lt;username&gt;&#39;</span><span class="p">,</span> <span class="s">&#39;&lt;password&gt;&#39;</span><span class="p">)</span>
58
<span class="n">url</span> <span class="o">=</span> <span class="s">&#39;http://&lt;webservice_host&gt;/lidar/LIDAR?wsdl&#39;</span>
59
<span class="n">api_key</span> <span class="o">=</span> <span class="s">&#39;api_key&#39;</span>
60
<span class="n">username</span> <span class="o">=</span> <span class="s">&#39;username&#39;</span>
61
<span class="n">password</span> <span class="o">=</span> <span class="s">&#39;password&#39;</span>
62
</pre></div>
63
</div>
64
<div class="section" id="avtentikacija">
65
<h3>Avtentikacija<a class="headerlink" href="#avtentikacija" title="Povezava na naslov">¶</a></h3>
66
<div class="highlight-python"><div class="highlight"><pre><span class="n">auth_token</span> <span class="o">=</span> <span class="n">client</span><span class="o">.</span><span class="n">service</span><span class="o">.</span><span class="n">getAuthenticationToken</span><span class="p">(</span><span class="n">api_key</span><span class="p">,</span> <span class="n">username</span><span class="p">,</span> <span class="n">password</span><span class="p">)</span>
59 67
<span class="k">if</span> <span class="n">auth_token</span> <span class="o">!=</span> <span class="bp">None</span><span class="p">:</span>
60 68
    <span class="k">print</span> <span class="s">&#39;Authenticated! Auth token: </span><span class="si">%s</span><span class="s">&#39;</span> <span class="o">%</span> <span class="n">auth_token</span>
61 69
</pre></div>
62 70
</div>
63 71
</div>
64 72
<div class="section" id="zaklep">
65
<h2>Zaklep<a class="headerlink" href="#zaklep" title="Povezava na naslov">¶</a></h2>
73
<h3>Zaklep<a class="headerlink" href="#zaklep" title="Povezava na naslov">¶</a></h3>
66 74
<div class="highlight-python"><div class="highlight"><pre><span class="n">lock_token</span> <span class="o">=</span> <span class="n">client</span><span class="o">.</span><span class="n">service</span><span class="o">.</span><span class="n">getLockToken</span><span class="p">(</span><span class="n">auth_token</span><span class="p">)</span>
67 75
<span class="k">if</span> <span class="n">lock_token</span> <span class="o">!=</span> <span class="bp">None</span><span class="p">:</span>
68 76
    <span class="k">print</span> <span class="s">&#39;Locked! Lock token: </span><span class="si">%s</span><span class="s">&#39;</span> <span class="o">%</span> <span class="n">lock_token</span>
......
70 78
</div>
71 79
</div>
72 80
<div class="section" id="odklep">
73
<h2>Odklep<a class="headerlink" href="#odklep" title="Povezava na naslov">¶</a></h2>
81
<h3>Odklep<a class="headerlink" href="#odklep" title="Povezava na naslov">¶</a></h3>
74 82
<div class="highlight-python"><div class="highlight"><pre><span class="n">unlock</span> <span class="o">=</span> <span class="n">client</span><span class="o">.</span><span class="n">service</span><span class="o">.</span><span class="n">unlock</span><span class="p">(</span><span class="n">lock_token</span><span class="p">)</span>
75 83
<span class="k">if</span> <span class="n">unlock</span><span class="p">:</span>
76 84
    <span class="k">print</span> <span class="s">&#39;Unlocked!&#39;</span>
......
78 86
</div>
79 87
</div>
80 88
</div>
89
</div>
81 90

  
82 91

  
83 92
          </div>
......
88 97
  <h3><a href="index.html">Seznam Vsebine</a></h3>
89 98
  <ul>
90 99
<li><a class="reference internal" href="#">Uporaba</a><ul>
100
<li><a class="reference internal" href="#nadzorni-modul">Nadzorni modul</a><ul>
91 101
<li><a class="reference internal" href="#avtentikacija">Avtentikacija</a></li>
92 102
<li><a class="reference internal" href="#zaklep">Zaklep</a></li>
93 103
<li><a class="reference internal" href="#odklep">Odklep</a></li>
94 104
</ul>
95 105
</li>
96 106
</ul>
107
</li>
108
</ul>
97 109

  
98 110
  <h4>Prejšnja tema</h4>
99 111
  <p class="topless"><a href="api.html"

Also available in: Unified diff