root / trunk / docs / uporaba.rst @ 10
History | View | Annotate | Download (1.12 KB)
| 1 | 5 | andrej.cim | Uporaba  | 
      
|---|---|---|---|
| 2 | ================  | 
      ||
| 3 | |||
| 4 | 8 | andrej.cim | Primeri uporabe web servisa na Ubuntu 10.04 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 | 8 | andrej.cim | management = Client(url)  | 
      
| 15 | 5 | andrej.cim | |
| 16 | 8 | andrej.cim | url = 'http://<webservice_host>/lidar/Management?wsdl'  | 
      
| 17 | 6 | andrej.cim | api_key = 'api_key'  | 
      
| 18 | username = 'username'  | 
      ||
| 19 | password = 'password'  | 
      ||
| 20 | |||
| 21 | Avtentikacija  | 
      ||
| 22 | ^^^^^^^^^^^^^  | 
      ||
| 23 | ::  | 
      ||
| 24 | |||
| 25 | 8 | andrej.cim | auth_token = management.service.getAuthenticationToken(api_key, username, password)  | 
      
| 26 | 5 | andrej.cim | if auth_token != None:  | 
      
| 27 | 8 | andrej.cim | print 'Prijavljen! Auth token: %s' % auth_token  | 
      
| 28 | 5 | andrej.cim | |
| 29 | Zaklep  | 
      ||
| 30 | 6 | andrej.cim | ^^^^^^  | 
      
| 31 | 5 | andrej.cim | ::  | 
      
| 32 | |||
| 33 | 8 | andrej.cim | 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 | 5 | andrej.cim | |
| 41 | Odklep  | 
      ||
| 42 | 6 | andrej.cim | ^^^^^^  | 
      
| 43 | 5 | andrej.cim | ::  | 
      
| 44 | |||
| 45 | 8 | andrej.cim | unlock = management.service.unlock(lock_token)  | 
      
| 46 | 5 | andrej.cim | if unlock:  | 
      
| 47 | 8 | andrej.cim | print 'Naprava odklenjena!'  | 
      
| 48 | 5 | andrej.cim |