def main(argv): try: if os.getuid() == 0: print >> sys.stderr, except AttributeError: print >> sys.stderr, if len(argv) > 1: try: port = int(argv[1]) except ValueError: print >> sys.stderr, "Failed to parse", argv[1], "as port number." return 1 else: port = _DEFAULT_SERVER_PORT try: server = BratServer((_DEFAULT_SERVER_ADDR, port)) print >> sys.stderr, "Serving brat at http://%s:%d" % server.server_address server.serve_forever() except KeyboardInterrupt: pass except socket.error, why: print >> sys.stderr, "Error binding to port", port, ":", why[1]
def startAPIServer(): try: server = HTTPServer(("", PORT_NUMBER), myHandler) print "Starting API server on port ", PORT_NUMBER server.serve_forever() except KeyboardInterrupt: print "Force shutting down API server" server.socket.close() except: print "Couldn't start API server"
def run(self): database.checkdb() server = SimpleXMLRPCServer(('0.0.0.0', self.port), logRequests=True) server.register_function(list_contents) server.register_function(initMachine) server.register_function(useMachine) server.register_function(showMachines) server.register_function(show) server.register_function(showWLS) server.register_function(showDomains) server.register_function(nmstart) server.register_function(startAdmin) server.register_function(startServer) server.register_function(stopServer) server.register_function(listprocess) server.register_function(kill) print "wlnm server daemon is running ." try: #print 'Use Control-C to exit' server.serve_forever() except KeyboardInterrupt: print 'Exiting'
def main(argv): # warn if root/admin try: if os.getuid() == 0: print >> sys.stderr, """ ! WARNING: running as root. The brat standalone server is experimental ! ! and may be a security risk. It is recommend to run the standalone ! ! server as a non-root user with write permissions to the brat work/ and ! ! data/ directories (e.g. apache if brat is set up using standard ! ! installation). ! """ except AttributeError: # not on UNIX print >> sys.stderr, """ Warning: could not determine user. Note that the brat standalone server is experimental and should not be run as administrator. """ if len(argv) > 1: try: port = int(argv[1]) except ValueError: print >> sys.stderr, "Failed to parse", argv[1], "as port number." return 1 else: port = _DEFAULT_SERVER_PORT try: server = BratServer((_DEFAULT_SERVER_ADDR, port)) print >> sys.stderr, "Serving brat at http://127.0.0.1:%d" % port server.serve_forever() except KeyboardInterrupt: # normal exit pass except socket.error, why: print >> sys.stderr, "Error binding to port", port, ":", why[1]
if self.hardware.get_state() == hi.MANUAL: if not started: print "Recording..." started = True self.vision.save_frame(2, self.path) frame_count += 1 else: if started: print "Stopped." print "{0} frames saved.".format(frame_count) started = False frame_count = 0 sleep(0.1) if __name__ == "__main__": path = raw_input("Please enter path: ") if len(path) == 0: path = "test" # make the main thread and start it main = Main(path) main.start() # make the frame streaming server. This gets main control flow. server.register_vision(main.vision) server = server.WebServer(('0.0.0.0', 5000), server.CamHandler) server.serve_forever()