def doit(filename): class OSCRequestHandler(SimpleHTTPRequestHandler): """OSCRequestHandler Hardcode the information necessary for TouchOSC to download the supplied layout file. """ def send_head(self): """Hard coded single-file server. """ self.send_response(200) self.send_header("Content-type", 'application/touchosc') self.send_header("Date", self.date_time_string(time.time())) self.send_header("Content-Disposition", 'attachment; filename="%s"' % (filename, )) self.end_headers() full_filename = os.path.join(os.path.dirname(__file__), filename) z = zipfile.ZipFile(full_filename) return z.open('index.xml', 'r') service = None if platform.system() == 'Linux': from avahi_announce import ZeroconfService service = ZeroconfService(name="AMCP", port=PORT, stype="_touchosceditor._tcp") service.publish() server_address = ('', PORT) httpd = BaseHTTPServer.HTTPServer(server_address, OSCRequestHandler) try: httpd.serve_forever() finally: if service: service.unpublish()
def avahi_publisher(server): # Cribbed from https://github.com/ArdentHeavyIndustries/amcp-rpi/blob/master/server.py if platform.system() == "Darwin": service = None else: # Avahi announce so it's findable on the controller by name from avahi_announce import ZeroconfService service = ZeroconfService( name="BRLS TouchOSC Server", port=server.server_address[1], stype="_osc._udp") service.publish()
def doit(filename): class OSCRequestHandler(SimpleHTTPRequestHandler): """OSCRequestHandler Hardcode the information necessary for TouchOSC to download the supplied layout file. """ def send_head(self): """Hard coded single-file server. """ self.send_response(200) self.send_header("Content-type", 'application/touchosc') self.send_header("Date", self.date_time_string(time.time())) self.send_header("Content-Disposition", 'attachment; filename="%s"' % (filename, )) self.end_headers() full_filename = os.path.join(os.path.dirname(__file__), filename) z = zipfile.ZipFile(full_filename) return z.open('index.xml', 'r') service = None if platform.system() == 'Linux': from avahi_announce import ZeroconfService service = ZeroconfService( name="AMCP", port=PORT, stype="_touchosceditor._tcp") service.publish() server_address = ('', PORT) httpd = BaseHTTPServer.HTTPServer(server_address, OSCRequestHandler) try: httpd.serve_forever() finally: if service: service.unpublish()
if __name__ == "__main__": try: server = AMCPServer(port=8000, client_ip=BROADCAST_IP, client_port=9000) except liblo.ServerError, err: print str(err) sys.exit() if platform.system() == "Darwin": service = None else: # Avahi announce so it's findable on the controller by name from avahi_announce import ZeroconfService service = ZeroconfService( name="AMCP TouchOSC Server", port=8000, stype="_osc._udp") service.publish() # Main thread runs both our LED effects and our OSC server, # draining all queued OSC events between frames. Runs until killed. try: server.mainLoop() except KeyboardInterrupt: # Cleanup if service: service.unpublish() if OnPi(): import RPi.GPIO as GPIO GPIO.cleanup() finally:
server = AMCPServer(port=8000, client_ip=BROADCAST_IP, client_port=9000) except liblo.ServerError, err: print str(err) sys.exit() if platform.system() == "Darwin": service = None else: # Avahi announce so it's findable on the controller by name from avahi_announce import ZeroconfService service = ZeroconfService(name="AMCP TouchOSC Server", port=8000, stype="_osc._udp") service.publish() # Main thread runs both our LED effects and our OSC server, # draining all queued OSC events between frames. Runs until killed. try: server.mainLoop() except KeyboardInterrupt: # Cleanup if service: service.unpublish() if OnPi(): import RPi.GPIO as GPIO GPIO.cleanup() finally: