def get(self): params = self.request.arguments writer_class = writer_types[params['writer_type'][0]]['class'] writer_params = writer_types[params['writer_type'][0]]['defaults'] device = params['port'][0] new_writer = writer_class(device, **writer_params) print "Adding writer", new_writer controller.add_writer(new_writer)
(r'/autoplay_off', AutoplayOff), (r'/add', AddPattern), (r'/pause', Pause), (r'/next', Next), (r'/pattern_groups',PatternGroups), (r'/status',Status) ] application = tornado.web.Application(handlers=handlers, static_path='static') for d in config['devices']: writer_class = writer_types[d['type']]['class'] writer_params = writer_types[d['type']]['defaults'] path = d['path'] new_writer = writer_class(path, **writer_params) print "Adding writer", new_writer controller.add_writer(new_writer) pattern_name = '_off.png' pattern_path = os.path.join(config['pattern_dir'], pattern_name) p = Bemis100Pattern(pattern_path, config['num_lights']) n = -1 controller.add_pattern(p, n, name=pattern_name) try: application.listen(5000) tornado.ioloop.IOLoop.instance().start() except KeyboardInterrupt: print 'Exiting...' # for c in controller.writers: # c.close_port() controller.quit()