wille.client

Wille Client Module

Using Wille Client.

Firstly, import it:

>>> import client

Instantiate a client:

>>> client = client.Client()

If we want to use local services, we need to tell client where they are:

>>> client.load_dir('../tests')

See what services we found from local folder:

>>> client.services()
[LocalWilleService(timeout_test), LocalWilleService(data), LocalWilleService(stub), LocalWilleService(upload_test)]

Services can be searched by their name:

>>> client.services(name='stub')
[LocalWilleService(stub)]

Services can be also search by their type:

>>> client.services(type='test')
[LocalWilleService(timeout_test), LocalWilleService(upload_test)]

Similarly, services can be executed (note that we need to prepare parameters):

>>> params = {'raw_data': file('../tests/data/data.txt','rb').read(), 'checksum': '525'}
>>> result = client.execute_service(name='upload_test',params=params)

You can also run a group of services. First we need to prepare a service description for every unique service/data combination:

>>> desc1 = {'name': 'upload_test', 'params': params}

Pass a list of these descriptions to grouped service execution

>>> results = client.execute_services([desc1,desc1,])

Results are available in a dictionary, indexed in the order they were given as arguments:

>>> results[0].data
'OK - checksum match (525)\r\n'
>>> results[1].data
'OK - checksum match (525)\r\n'

Hint: You can turn on debugging mode in Wille client by setting debug:

>>> client.debug = True
class wille.client.Client(servicepool=None, keyring=None, debug=False, profiles=None, userdata_dir=None)

Wille Client

Parameters (all optional):

servicepool - Servicepool (default=None, recommended)

keyring - Init with given keyring

debug - Enable debug mode

profiles - Enable only given profiles (default=all enabled)

userdata_dir = Directory to store user/session data

execute_service(name=None, type=None, uri=None, params=None, prefer_index=0)

Execute a service by given description

execute_services(service_descriptions)

Execute multiple services by given descriptions

launch_viewer(type='webbrowser', location='')

Launch viewer. Parameters: type - Type of the viewer:

webbrowser - Launch system’s web browser

location - Location/arguments to pass to the viewer

load_dir(services_dir='../services', libs_dir=None)

Load services from given directory (with given libs directory)

load_keyring(filename=None)

Load keyring (optionally from given file)

save_keyring()

Save keyring

services(name=None, type=None, uri=None, pooltype=None)

Find services

Previous topic

wille.auth

Next topic

wille.server

This Page