Project

General

Profile

Statistics
| Revision:

root / trunk / docs / uporaba.rst @ 9

History | View | Annotate | Download (1.12 KB)

1
Uporaba
2
================
3

    
4
Primeri uporabe web servisa na Ubuntu 10.04 za Python in SOAP knjižico `SUDS <https://fedorahosted.org/suds/>`_, ki jo namestimo z: ::
5

    
6
    sudo easy_install suds
7

    
8
Nadzorni modul
9
--------------
10
Nadozrni modul skrbi za dostop do naprave.
11
::
12

    
13
    from suds.client import Client
14
    management = Client(url)
15

    
16
    url = 'http://<webservice_host>/lidar/Management?wsdl'
17
    api_key = 'api_key'
18
    username = 'username'
19
    password = 'password'
20

    
21
Avtentikacija
22
^^^^^^^^^^^^^
23
::
24

    
25
    auth_token = management.service.getAuthenticationToken(api_key, username, password)
26
    if auth_token != None:
27
        print 'Prijavljen! Auth token: %s' % auth_token
28
    
29
Zaklep
30
^^^^^^
31
::
32

    
33
    status = management.service.getStatus(auth_token)
34
    if status == 'unlocked':
35
        lock_token = management.service.getLockToken(auth_token)
36
        if lock_token != None:
37
            print 'Naprava zaklenjena! Lock token: %s' % lock_token
38
            
39
            # TODO: Uporaba zaklenjene naprave z uporabo lock_token
40

    
41
Odklep
42
^^^^^^
43
::
44

    
45
    unlock = management.service.unlock(lock_token)
46
    if unlock:
47
        print 'Naprava odklenjena!'
48

    
49