O'Reilly logo

Python Testing Cookbook. by Bhaskar N. Das, Greg L. Turnquist

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How to do it...

With these steps, we will see how to record and play back data in real-time pace:

  1. Write a script called recipe64_livedata.py that simulates live data being sent every one to ten seconds, as shown here:
import randomimport sysimport timefrom network import *from springpython.remoting.pyro import *print "Sending events to live network app. Ctrl+C to exit..."proxy = PyroProxyFactory()proxy.service_url = "PYROLOC://127.0.0.1:7766/network_advised"while True:hostname = random.choice(["pyhost1","pyhost2","pyhost3"])condition = random.choice(["serverRestart", "lineStatus"])severity = random.choice([1,5])evt = Event(hostname, condition, severity)stored_event, is_active, updated_services,updated_equipment = proxy.process(evt)print ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required