def index(): client = OVSDBClient('localhost', 6640) query = { 'id': 1, 'method': 'transact', 'params': ['stamps', { 'op': 'select', 'table': 'Stamp', 'where': [] }] } response = client.request(query) return render_template('index.html', stamps=response['result'][0]['rows'])
def index(): client = OVSDBClient('localhost', 6640) query = { 'id': 1, 'method': 'transact', 'params': [ 'stamps', { 'op': 'select', 'table': 'Stamp', 'where': [] } ] } response = client.request(query) return render_template('index.html', stamps=response['result'][0]['rows'])
def view(): client = OVSDBClient('localhost', 6640) query = { 'id': 2, 'method': 'transact', 'params': [ 'stamps', { 'op': 'select', 'table': 'Stamp', 'where': [ ['_uuid', '==', ['uuid', request.args.get('id')]] ] } ] } response = client.request(query) return render_template('view.html', stamp=response['result'][0]['rows'][0])
def view(): client = OVSDBClient('localhost', 6640) query = { 'id': 2, 'method': 'transact', 'params': [ 'stamps', { 'op': 'select', 'table': 'Stamp', 'where': [['_uuid', '==', ['uuid', request.args.get('id')]]] } ] } response = client.request(query) return render_template('view.html', stamp=response['result'][0]['rows'][0])
import sys from ovsdb_client import OVSDBClient client = OVSDBClient(sys.argv[1], 6640) print "Connecting to chat room..." response = client.request({ 'id': 1, 'method': 'monitor', 'params': [ 'chat', 1, { 'Message': {} } ] }) if response['error']: raise "Could not connect to chat room!" else: print "Connected." while True: # Check for messages from server message = None try: message = client.receive() except OVSDBClient.ReceiveTimeoutError: pass
import sys from ovsdb_client import OVSDBClient nickname = sys.argv[2] message_id = 0 while True: message = raw_input('Your message: ') client = OVSDBClient(sys.argv[1], 6640) message_id += 1 response = client.request({ 'id': message_id, 'method': 'transact', 'params': [ 'chat', { 'op': 'insert', 'table': 'Message', 'row': { 'sender': nickname, 'message': message } } ] }) if response and response['error']: raise "Could not send message!"
operations = ['stamps'] for stamp in stamps: operations.append({ 'op': 'insert', 'table': 'Stamp', 'row': { 'name': stamp['name'], 'url': stamp['url'], 'categories': [ 'set', stamp['categories'] ] } }) client = OVSDBClient('localhost', 6640) response = client.request({ 'id': 1, 'method': 'transact', 'params': operations }) if response['error'] is None: print "Stamps database seeded" else: print response
'url': 'http://s08214.biss.wikispaces.net/file/' 'view/homer-stamp-14.jpg/125737775/homer-stamp-14.jpg', 'categories': ['cartoons'] }] operations = ['stamps'] for stamp in stamps: operations.append({ 'op': 'insert', 'table': 'Stamp', 'row': { 'name': stamp['name'], 'url': stamp['url'], 'categories': ['set', stamp['categories']] } }) client = OVSDBClient('localhost', 6640) response = client.request({ 'id': 1, 'method': 'transact', 'params': operations }) if response['error'] is None: print "Stamps database seeded" else: print response
import sys from ovsdb_client import OVSDBClient client = OVSDBClient(sys.argv[1], 6640) print "Connecting to chat room..." response = client.request({ 'id': 1, 'method': 'monitor', 'params': ['chat', 1, { 'Message': {} }] }) if response['error']: raise "Could not connect to chat room!" else: print "Connected." while True: # Check for messages from server message = None try: message = client.receive() except OVSDBClient.ReceiveTimeoutError: pass # Skip the rest if no message received if not message: continue