/usr/share/doc/python-nwsclient/examples/nwsExample.py is in python-nwsclient 1.6.4-8build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | #!/usr/bin/env python
import sys
try:
from nws.client import NetWorkSpace
except ImportError, e:
print >> sys.stderr, "unable to import the nws.client python module"
print >> sys.stderr, "make sure you have nwsclient installed on this machine"
sys.exit(1)
try:
ws = NetWorkSpace('snake pit')
except ImportError, e:
print >> sys.stderr, "make sure you're running the NWS server on this machine"
print >> sys.stderr, str(e)
sys.exit(1)
print 'connected, listing contents of netWorkSpace (should be nothing there).'
print ws.listVars()
ws.store('x', 1)
print 'should now see x.'
print ws.listVars()
print 'find (but don\'t consume) x.'
print ws.find('x')
print 'check that it is still there.'
print ws.listVars()
print 'associate another value with x.'
ws.store('x', 2)
print ws.listVars()
print 'consume values for x, should see them in order saved.'
print ws.fetch('x')
print ws.fetch('x')
print 'no more values for x... .'
print ws.listVars()
print 'so try to fetch and see what happens... .'
print ws.fetchTry('x', 'no go')
print 'create a single-value variable.'
ws.declare('pi', 'single')
print ws.listVars()
print 'get rid of x.'
ws.deleteVar('x')
print ws.listVars()
print 'try to store two values to pi.'
ws.store('pi', 2.171828182)
ws.store('pi', 3.141592654)
print ws.listVars()
print 'check that the right one was kept.'
print ws.find('pi')
print "store a dictionary."
ws.store('dict', {'foo': 'spam', 'bar': 'eggs'})
d = ws.find('dict')
print d
print "store a list."
ws.store('list', ['foo', 1, 'spam', 3.14159, 'bar', 42, 'eggs', 32764])
l = ws.find('list')
print l
print 'what about the rest of the world?'
print ws.server.listWss()
|