当前位置: 首页>>代码示例>>Python>>正文


Python Server.start方法代码示例

本文整理汇总了Python中server.Server.start方法的典型用法代码示例。如果您正苦于以下问题:Python Server.start方法的具体用法?Python Server.start怎么用?Python Server.start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在server.Server的用法示例。


在下文中一共展示了Server.start方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: from server import Server [as 别名]
# 或者: from server.Server import start [as 别名]
def main():
    check_os()    
    from server import Server
    print("XMPlay Remote Control Server")
    print("")
    ip = input("Write the listening address(0.0.0.0 by default): ")
    if (ip == ""):
        ip = "0.0.0.0"
        
    port = input("Write the listening port(9999 by default): ")
    if (port == ""):
        port = "9999"
        
    port = int(port)
    
    threadServer = Server(1,(ip,port))
    threadServer.daemon = True
    threadServer.start()
    print("Server Started!")
    while (input("Write exit to quit: ") != "exit"):
        os.system("cls")
        pass
    
    threadServer.stop_server()
    sys.exit()
开发者ID:lucasdaddiego,项目名称:pyremote-xmplay,代码行数:27,代码来源:run.py

示例2: DemoMicroBridge

# 需要导入模块: from server import Server [as 别名]
# 或者: from server.Server import start [as 别名]
class DemoMicroBridge(ServerListener):
    def __init__(self):
        self.droid = android.Android()
        self.droid.webViewShow('file:///sdcard/sl4a/scripts/microbridge/demo.html')

        # Start server
        self.server = Server()
        self.server.add_listener(self)
        self.server.start()

    def on_server_started(self, server):
        print "Server Started!"

    def on_client_connect(self, server, client):
        print "Client Connected!"

    def on_client_disconnect(self, server, client):
        print "Client Disconnected!"

    def on_receive(self, client, string):
        # print "Received " + string

        # Received data from ADC
        # Arduino uses little-endian format
        data = 0
        for d in string[::-1]:
            data = data << 8 | ord(d)
        self.droid.eventPost("ADC", str(data))
开发者ID:beckettman,项目名称:python-microbridge,代码行数:30,代码来源:demo.py

示例3: main

# 需要导入模块: from server import Server [as 别名]
# 或者: from server.Server import start [as 别名]
def main():
    # Build the library
    subprocess.call(['npm', 'run', 'build'])
    # Copy the library to the http server path
    subprocess.call([
        'cp',
        join(BASEDIR, '..', 'dist/ether.global.js'),
        join(BASEDIR, 'public')
    ])
    # Build the sample user app under test
    # Building the app only works if dir is set properly
    os.chdir(BASEDIR)
    subprocess.call(['node', join(BASEDIR, 'rollup.js')])

    # Start the http server
    httpd = Server()
    httpd.start()

    # Run CasperJS tests
    subprocess.call([
        join(BASEDIR, '..', 'node_modules/casperjs/bin/casperjs'),
        'test', '--log-level=debug', '--verbose',
        join(BASEDIR, 'test')
    ])

    # Stop the http server
    httpd.stop()
开发者ID:darvelo,项目名称:ether,代码行数:29,代码来源:run_tests.py

示例4: TestSendfile

# 需要导入模块: from server import Server [as 别名]
# 或者: from server.Server import start [as 别名]
class TestSendfile(unittest.TestCase):

    def setUp(self):
        # server
        self.server = Server(('127.0.0.1', int(GATEWAY_DAT_PORT)))
        self.server.start()
        # client
        self.client = socket.socket()
        self.client.connect((self.server.host, self.server.port))
        self.client.settimeout(10)

        #self.client.recv(1024)
        self.sockno = self.client.fileno()
        self.file = open('10MB', 'rb')
        self.fileno = self.file.fileno()

    def tearDown(self):
        #save_remove('10MB-1')
        self.file.close()
        self.client.close()
        if self.server.running:
            self.server.stop()
        self.server = None # garbage collection

    def test_send_file(self):
        total_sent = 0
        while True:
            sent = self.file.read(BUFFER_LEN)
            if not sent:
                break #EOF
            self.client.sendall(sent)
        self.client.close()
        self.server.wait()
        data = self.server.handler_instance.get_data()
        print 'Server received: %s' % len(data)
开发者ID:hkucs,项目名称:dtn-client,代码行数:37,代码来源:test_send.py

示例5: main

# 需要导入模块: from server import Server [as 别名]
# 或者: from server.Server import start [as 别名]
def main():
    parser = argparse.ArgumentParser(
        description="This is the DMCR Frontend. For licensing see LICENSE.txt.", add_help=False
    )

    parser.add_argument("--file", "-f", default="../../scenes/scene.json")
    parser.add_argument("--width", "-w", default=800)
    parser.add_argument("--height", "-h", default=600)
    parser.add_argument("--iterations", "-i", default=5)
    parser.print_help()
    params = vars(parser.parse_args())

    print "Starting FE server with:\n{file}: {width}x{height}, {iterations} iterations".format(**params)

    server = Server()
    server.FileToTask(params["file"], int(params["width"]), int(params["height"]), int(params["iterations"]))

    try:
        server.start()
        while True:
            choice = raw_input("> ")
            if choice == "l":
                for task in server.taskmanager.ListTasks():
                    print str(task)
            elif choice == "s":
                task_id = raw_input("Task ID: ")
                server.taskmanager.StopTask(int(task_id))
            elif choice == "a":
                filename = raw_input("Filename: ")
                width = 800
                height = 600
                iterations = 5

                width_i = raw_input("Width (800): ")
                if width_i != "":
                    width = int(width_i)
                height_i = raw_input("Height (600): ")
                if height_i != "":
                    height = int(height_i)

                iterations_i = raw_input("Iterations (5): ")
                if iterations_i != "":
                    iterations = int(iterations_i)

                server.FileToTask(filename, width, height, iterations)

            elif choice == "q":
                break

            else:
                print "l: list tasks\na: add task\ns: stop task\nq: quit"
    except KeyboardInterrupt as e:
        print "DMCR.main(): Excepted, quitting", e
    finally:
        print "Stopping server"
        server.stop()
        server.taskmanager.stop()  # wait for tasks to finish
开发者ID:Jontte,项目名称:DMCR,代码行数:59,代码来源:dmcr.py

示例6: CreateServer

# 需要导入模块: from server import Server [as 别名]
# 或者: from server.Server import start [as 别名]
def CreateServer(ip="127.0.0.1", port=8400):
    srv= Server(StreamersHandler, ip, port)
    streamersHandler= srv.GetRequestHandler()
    streamersHandler.RegisterStreamer(h264Stream)
    streamersHandler.RegisterStreamer(webmStream)
    streamersHandler.RegisterStreamer(prosojniceStream)
    streamersHandler.RegisterStreamer(motionDetect)
    streamersHandler.RegisterStreamer(testStream)
    streamersHandler.RegisterStreamer(NotifyCopyProcess)
    srv.start()

    return srv
开发者ID:offlinehacker-playground,项目名称:rocketeer,代码行数:14,代码来源:stream.py

示例7: host_game

# 需要导入模块: from server import Server [as 别名]
# 或者: from server.Server import start [as 别名]
def host_game():
	global in_game
	in_game = True
	port = input("Please select a port to host on: ")
	# Start a server on that port and then connect

	# Because we're hosting, create a server instance
	server = Server(socket.gethostname(), port)
	server.start()
	time.sleep(.5)

	client = Client()
	client.connect(socket.gethostname(), port)
开发者ID:cmark89,项目名称:Gocore,代码行数:15,代码来源:gocore.py

示例8: Chat

# 需要导入模块: from server import Server [as 别名]
# 或者: from server.Server import start [as 别名]
class Chat():

	def __init__(self):
		self.sessions = {}
		return

	def init(self):
		print('Chat started')

		#Database connection
		self.database()

		#Setup
		self.protocols()
		self.email()
		self.controllers()

		#Server
		self.server()

	#Protocols
	def protocols(self):
		print('Loading Protocols')
		self.JsonProtocol = JsonProtocol()
		self.TextProtocol = TextProtocol()

	#Database connection
	def database(self):
		print('Loading Database')
		self.connection = Connection()
		self.connection.register([User])
		self.connection.register([Channel])
		self.connection.register([Post])
		self.connection.register([Email])

	def email(self):
		print('Loading Email')
		self.Emailer = Emailer(self.connection)

	def controllers(self):
		print('Loading Controllers')
		self.UsersController = UsersController(self)
		self.ChannelsController = ChannelsController(self)
		self.PostsController = PostsController(self)
		self.SystemsController = SystemsController(self)

	#Server connection
	def server(self):
		print('Loading Server')
		self.srv = Server()
		self.srv.start(self)
开发者ID:darrenmoore,项目名称:chat,代码行数:53,代码来源:chat.py

示例9: main_loop

# 需要导入模块: from server import Server [as 别名]
# 或者: from server.Server import start [as 别名]
def main_loop():
  socket_fd, num_features, learning_type, model = sys.argv[1:5]

  learner_klass = {'cluster': Clusterer, 'classify': Classifier}[learning_type]
  parser = getattr(getattr(models, inflection.underscore(model)), model)
  learner = learner_klass.empty(*map(int, num_features.split(',')))
  server = Server(int(socket_fd), learner, parser.parse_raw)
  backend = {'cluster': server.minibatch_kmeans_backend, 'classify': server.svc_backend}[learning_type]

  try:
    server.start(backend)
  except StopIteration:
    pass
  finally:
    server.close()
开发者ID:yasyf,项目名称:mitclasses,代码行数:17,代码来源:__main__.py

示例10: main

# 需要导入模块: from server import Server [as 别名]
# 或者: from server.Server import start [as 别名]
def main():
    """Start a server"""
    file = '../data/game.dbr'
    store = Store()
    game = tables_init(store)
    scan_file(file, game)
    game.output('../data/game.new')
    if os.system('/usr/bin/cmp -s ../data/game.dbr ../data/game.new'):
        subprocess.Popen([
            '/usr/bin/meld', '../data/game.dbr', '../data/game.new'])
    else:
        os.unlink('../data/game.new')
        html_path = "../html"
        serv = Server(game, html_path, file)
        serv.start()
开发者ID:jjstwerff,项目名称:alien_engine,代码行数:17,代码来源:read.py

示例11: main

# 需要导入模块: from server import Server [as 别名]
# 或者: from server.Server import start [as 别名]
def main():
	try:
		#Read config file
		settings=Settings()
	
		#Set up logger
		logger=Logger(settings)

		#Create scanner
		server=Server(settings,logger)

		#Begin scanning
		server.start()
		
	except KeyboardInterrupt:
		server.stop()
开发者ID:SteveAbb,项目名称:Vestigo,代码行数:18,代码来源:vestigo_base.py

示例12: __init__

# 需要导入模块: from server import Server [as 别名]
# 或者: from server.Server import start [as 别名]
class Runner:
    def __init__(self):
        self.server = None
        self.init_logging()
        signal.signal(signal.SIGINT, self.stop)
        signal.signal(signal.SIGTERM, self.stop)

    def init_logging(self):
        if not hasattr(settings, 'Logging'):
            logging.basicConfig(format='[%(threadName)s @ %(asctime)s] %(levelname)s: %(message)s', level='DEBUG')
            return

        logger = logging.getLogger()
        logger.setLevel(settings.Logging.level)
        formatter = logging.Formatter(settings.Logging.format)

        if settings.Logging.output_file:
            fileHandler = logging.FileHandler(settings.Logging.output_file)
            fileHandler.setFormatter(formatter)
            logger.addHandler(fileHandler)

        if settings.Logging.console_output:
            consoleHandler = logging.StreamHandler()
            consoleHandler.setFormatter(formatter)
            logger.addHandler(consoleHandler)

    def start(self):
        handler = Handler()
        self.server = Server(settings.ServerSettings, handler)
        try:
            self.server.start()
        except Exception as e:
            logging.error('Caught error: {}'.format(str(e)))
            if self.server:
                self.server.stop()
            sys.exit(1)

    def stop(self, signal, frame):
        if self.server:
            self.server.stop()
            sys.exit(0)
        else:
            logging.warning('Cannot stop server because it isn\'t running.')
            sys.exit(9)
开发者ID:evanisnor,项目名称:dynamic-api-python,代码行数:46,代码来源:run.py

示例13: main

# 需要导入模块: from server import Server [as 别名]
# 或者: from server.Server import start [as 别名]
def main():
    server = Server()

    while True:
        # create server
        sys.stdout.write("WYBO server> ")
        cmd = sys.stdin.readline()

        if cmd == "start\n":
            server.start(9003)
        elif cmd == "stop\n":
            server.stop()
        elif cmd == "restart\n" or cmd == "reboot\n":
            server.reboot()
        elif cmd == "adduser\n":
            server.add_user()
        elif cmd == "exit\n":
            server.stop()
            exit()
开发者ID:lbsb,项目名称:wybo-working-hours-tracker,代码行数:21,代码来源:main.py

示例14: run_monitor

# 需要导入模块: from server import Server [as 别名]
# 或者: from server.Server import start [as 别名]
def run_monitor():
	local_address = (sys.argv[1], int(sys.argv[2]))
	servers = [(addr, port) for addr, port in settings.SERVER_LIST if addr != local_address[0] or port != local_address[1]]

	stats = Stats(local_address)
	stats.start()

	server = Server(local_address)
	server.start()

	client_pool = ClientPool(servers, stats)
	client_pool.start()

	try:
		while True:
			time.sleep(1)
	except KeyboardInterrupt:
		server.stop()
		client_pool.stop()
		stats.stop()
开发者ID:hamaxx,项目名称:tcphealthcheck,代码行数:22,代码来源:monitor.py

示例15: main

# 需要导入模块: from server import Server [as 别名]
# 或者: from server.Server import start [as 别名]
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('-p', '--port', type=int, required=True)

    args = parser.parse_args()
    address = ('127.0.0.1', args.port)

    import config  # import config.py explicitly

    if address not in config.servers:
        print address
        print config
        print "*** specified port not one of the ones in the config file"
        return
    server = Server(address, config.servers, config.delays)
    server.start()

    print "Running on port {}".format(args.port)

    Cmd(server).cmdloop()
开发者ID:alecbenzer,项目名称:cs425-mp3,代码行数:22,代码来源:mp3.py


注:本文中的server.Server.start方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。