Skip to content

Commit

Permalink
added openWebBrowser key to dataserver.start - defaults to False.
Browse files Browse the repository at this point in the history
  • Loading branch information
itdaniher committed Jul 6, 2011
1 parent a136ee1 commit 03aa941
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
7 changes: 5 additions & 2 deletions pixelpulse.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from tornado.web import Application, RequestHandler, StaticFileHandler
from tornado.websocket import WebSocketHandler

import sys, os, glob, imp, time, json
import sys, os, glob, imp, time, json, webbrowser

class Device(object):
"""Base class for device drivers
Expand Down Expand Up @@ -143,11 +143,14 @@ def _onSet(self, message):
def _onStateChange(self, channel):
self._sendToAll(self._formJSON('state', {'channel':channel.id,'state':channel.state}))

def start(self):
def start(self, openWebBrowser=False):
"""Start the server and all associated devices. Gives control to the
Tornado IO loop and does not return until the server terminates"""
self.startT = time.time()

if openWebBrowser:
webbrowser.open("http://127.0.0.1:%i"%self.port)

for dev in self.devices:
dev.start(self)

Expand Down
3 changes: 1 addition & 2 deletions sine.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,4 @@ def update(self):
if __name__ == '__main__':
dev = SineDevice()
server = pixelpulse.DataServer(dev)
webbrowser.open("http://localhost:8888/?server=virtualrc")
server.start()
server.start(openWebBrowser=True)

0 comments on commit 03aa941

Please sign in to comment.