Project

General

Profile

Statistics
| Revision:

root / trunk / docs / uporaba.rst @ 7

History | View | Annotate | Download (914 Bytes)

1 5 andrej.cim
Uporaba
2
================
3
4 6 andrej.cim
Primeri uporabe web servisa za Python in SOAP knjižico `SUDS <https://fedorahosted.org/suds/>`_, ki jo namestimo z: ::
5 5 andrej.cim
6
    sudo easy_install suds
7
8 6 andrej.cim
Nadzorni modul
9
--------------
10
Nadozrni modul skrbi za dostop do naprave.
11 5 andrej.cim
::
12
13
    from suds.client import Client
14
    client = Client(url)
15
16 6 andrej.cim
    url = 'http://<webservice_host>/lidar/LIDAR?wsdl'
17
    api_key = 'api_key'
18
    username = 'username'
19
    password = 'password'
20
21
Avtentikacija
22
^^^^^^^^^^^^^
23
::
24
25
    auth_token = client.service.getAuthenticationToken(api_key, username, password)
26 5 andrej.cim
    if auth_token != None:
27
        print 'Authenticated! Auth token: %s' % auth_token
28
29
Zaklep
30 6 andrej.cim
^^^^^^
31 5 andrej.cim
::
32
33
    lock_token = client.service.getLockToken(auth_token)
34
    if lock_token != None:
35
        print 'Locked! Lock token: %s' % lock_token
36
37
Odklep
38 6 andrej.cim
^^^^^^
39 5 andrej.cim
::
40
41
    unlock = client.service.unlock(lock_token)
42
    if unlock:
43
        print 'Unlocked!'
44