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


Python server.Server类代码示例

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


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

示例1: test_parse_lines

 def test_parse_lines(self):
     sv = Server()
     sv.read_tag_file("./data") 
     sv.parse_lines()
     PARSED_LINE_SEQUENCE_LIST = [("a","B"),("b","B"),("c","I"),("d","B"), \
         ("e","I"),("f","I"),("",),("g","B"),("h","I"),("i","B")]
     self.assertEquals(PARSED_LINE_SEQUENCE_LIST, sv.parsed_line_sequence_list)
开发者ID:photonxp,项目名称:word_slicer_demo,代码行数:7,代码来源:tests.py

示例2: main

def main():
    main_server_instance = Server(HOST, user=USER, passwd=PASSWD, port=PORT, use_ssl=USE_SSL)
    manager = multiprocessing.Manager()
    lock = multiprocessing.Lock()

    for group in GROUPS:
        workers = []
        # get group info here.
        first, last, count = main_server_instance.set_group(group)

        start_index = multiprocessing.Value('i', last)
        results = manager.list()
        args = (HOST, USER, PASSWD, PORT, USE_SSL, group, start_index,
                CHUNK_SIZE, results, lock, first)

        for i in range(1, MAX_CONNECTIONS):
            p = multiprocessing.Process(target=article_worker, args=args)
            p.start()
            workers.append(p)

        try:
            for worker in workers:
                worker.join()
        except KeyboardInterrupt:
            for worker in workers:
                worker.terminate()
                worker.join()

        for worker in workers:
            worker.terminate()
            worker.join()

        print(first, start_index.value, last)
开发者ID:Islandhitman,项目名称:uidx,代码行数:33,代码来源:__init__.py

示例3: main

def main():
    #use argparse to get role, ip, port and user name
    parser = argparse.ArgumentParser(
        description="""PySyncIt""",
        formatter_class=argparse.RawDescriptionHelpFormatter)
    
    parser.add_argument(
        '-ip', help='Specify the ip address of this machine', required=True)

    parser.add_argument(
        '-port', help='Specify the port of this machine to run rpc server', required=True)

    parser.add_argument(
        '-uname', help='Specify the user name of this machine', required=True)
    
    parser.add_argument(
        '-role', help='Specify the role of this machine - client or server', required=True)
    
    args = parser.parse_args()

    #start logging
    setup_logging("syncit.log.%s-%s" % (args.ip, args.port));
    logger = logging.getLogger('syncIt')

    #Read config file
    config = ConfigParser.ConfigParser()
    logger.info("Using config file: syncit.cfg")
    config.read('syncit.cfg')

    if (args.role == 'server'):
        node = Server(args.role, args.ip, int(args.port), args.uname, get_watch_dirs(config, args.uname), get_clients(config))
    else:
        node = Client(args.role, args.ip, int(args.port), args.uname, get_watch_dirs(config, args.uname), get_server_tuple(config))

    node.activate()
开发者ID:LivLuvHub,项目名称:PySyncIt,代码行数:35,代码来源:monitor.py

示例4: _display_from_interpreter

 def _display_from_interpreter(self):
     server = Server(json=self.saved_json_file)
     print '''Your visualization is being rendered at
              http://localhost:%s/
              Visit the url in your webgl compatible browser
              to see the animation in full glory'''%(server.port)
     server.run()
开发者ID:pramttl,项目名称:pydy-viz,代码行数:7,代码来源:scene.py

示例5: main

def main():
	server = Server()

	title = "capton"
	mode = (600, 600, 0, 32)

	pygame.init()
	pygame.display.set_caption(title)
	screen = pygame.display.set_mode(mode[:2], mode[2], mode[3])

	client = Client()

#	ENTITY_COLOR = (255, 255, 255)
#	client.set_entity_color(ENTITY_COLOR)

	client.send_connect(server)

	I_COUNT = 30
	J_COUNT = 30
	FILL_PERCENT = 20
	client.send_create_random_world(I_COUNT, J_COUNT, FILL_PERCENT)

	BOT_COUNT = 20
	client.send_add_bot(BOT_COUNT)

	client.send_restart_game()

	while True:
		server.update()

		client.update()
		client.draw(screen)

		time.sleep(1.0 / 60)
开发者ID:Ring-r,项目名称:sandbox,代码行数:34,代码来源:capton.py

示例6: start

def start(args, kill = None):
    config_file = os.path.join(os.path.dirname(os.path.abspath(__file__)), "pywps.cfg")

    processes = [
        FeatureCount(),
        SayHello(),
        Centroids(),
        UltimateQuestion(),
        Sleep(),
        Buffer(),
        Area(),
        Box(),
        Warp()
    ]

    s = Server(processes=processes, config_file=config_file)

    # TODO: need to spawn a different process for different server
    if args.waitress:
        import waitress
        from pywps import configuration

        configuration.load_configuration(config_file)
        host = configuration.get_config_value('wps', 'serveraddress').split('://')[1]
        port = int(configuration.get_config_value('wps', 'serverport'))

        waitress.serve(s.app, host=host, port=port)
    else:
        s.run()
开发者ID:jachym,项目名称:pywps-4-demo,代码行数:29,代码来源:demo.py

示例7: test_assertPathOk

	def test_assertPathOk(self) :
		s = Server("badpath")
		try :
			s._assertPathOk()
			self.fail("Exception expected")
		except BadServerPath, e:
			self.assertEqual(e.message, "badpath")
开发者ID:clam-project,项目名称:testfarm-server2,代码行数:7,代码来源:server_test.py

示例8: run

    def run(self):
        """
        Start HTTP daemon
        """
        self.log("Starting new API instance on %d" % self.port)
        http_handler = Handler
        SocketServer.TCPServer.allow_reuse_address = True

        try:
            http_service = ApiServer((self.host, self.port), http_handler, manager=self.manager)
        except socket.error as e:
            self.log("Failed to bind to port. Got: %s" % str(e))
            return False

        if self.ssl:
            self.manager.get_key({'hostname': self.ssl, 'algo': 'RSA', 'bits': 2048})
            key_path = self.manager.get_key_path(self.ssl)

            while True:
                res = self.manager.cert({'hostname': self.ssl, 'ip': '127.0.0.1'})
                if res['status'] != 'available':
                    time.sleep(10)
                    continue

                self.log("Certificate successfully received for %s" % self.ssl)
                break

            cert_path = self.manager.get_fullchain_path(self.ssl)
            self.log("Key: %s, Cert: %s" % (key_path, cert_path))
            http_service.socket = ssl.wrap_socket(http_service.socket, keyfile=key_path, certfile=cert_path, server_side=True)

        self.log("HTTP API server started")
        while self.is_running():
            http_service.handle_request()
开发者ID:alxark,项目名称:scmt,代码行数:34,代码来源:service.py

示例9: DemoMicroBridge

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,代码行数:28,代码来源:demo.py

示例10: __init__

 def __init__(self, core="tarantool"):
     Server.__init__(self, core)
     self.default_bin_name = "tarantool_box"
     self.default_config_name = "tarantool.cfg"
     self.default_init_lua_name = "init.lua"
     # append additional cleanup patterns
     self.re_vardir_cleanup += ['*.snap',
                                '*.xlog',
                                '*.inprogress',
                                '*.cfg',
                                '*.sup',
                                '*.lua']
     self.process = None
     self.config = None
     self.vardir = None
     self.valgrind_log = "valgrind.log"
     self.valgrind_sup = os.path.join("share/", "%s.sup" % ('tarantool'))
     self.init_lua = None
     self.default_suppression_name = "valgrind.sup"
     self.pidfile = None
     self.port = None
     self.binary = None
     self.is_started = False
     self.mem = False
     self.start_and_exit = False
     self.gdb = False
     self.valgrind = False
开发者ID:catcher22,项目名称:tarantool,代码行数:27,代码来源:tarantool_server.py

示例11: serve_forever

	def serve_forever(self, poll_interval=0.5):
		# make sure every process knows the https parent pid
		secure_pid = os.getpid()
		plain_pid = os.fork() if self.plain_mode else None
		# when using simultaneous plain http, fork and run that part on the child.
		# os.fork() warns about ssl and multiprocessing. I think we're okay tho,
		# since only the parent does any ssl and its right on the socket???

		# plain (child) part:
		if plain_pid == 0:
			# TODO: catch signals from / poll for pid of parent?
			try:
				self.plain_server.serve_forever(poll_interval)
			finally:
				# could probably investigate the nature of our pid more closely,
				# however pidfiles are too tryhard atm
				if secure_pid == os.getppid():
					os.kill(secure_pid, signal.SIGTERM)


		# secure (parent) part:
		else:
			# might get away w/ lazy style? if more sophisticated management is desired
			# can override SocketServer.py copypastastyle
			try:
				Server.serve_forever(self, poll_interval)
			finally:
				# again, might want to think at least two seconds about our cleanup...
				# None == no fork even happened.
				if plain_pid is not None:
					os.kill(plain_pid, signal.SIGTERM)
开发者ID:gbromios,项目名称:gb,代码行数:31,代码来源:ssl_server.py

示例12: setUp

    def setUp(self):
        temp = tempfile.NamedTemporaryFile()
        filename_temp = temp.name
        temp.close()

        Server.SOCKET_ATTR = (socket.AF_UNIX, socket.SOCK_STREAM)
        Server.SOCKET_HOST = filename_temp

        server = Server()
        worker = Worker(target=server.initSocket)
        worker.start()
        self.server = server
        self.worker = worker
        self.filename_temp = filename_temp

        # wait socket up
        while not hasattr(server, '_server_socket'):
            pass

        self.clients = []
        self._new_client()
        self._new_client()

        gid = server.create_game(self.clients[0].uid, 'JungleRumble')
        server.join_game(self.clients[1].uid, gid)

        result = self.clients[0].read() # new_opponent
开发者ID:LucasFaiska,项目名称:RumbleJungle,代码行数:27,代码来源:test_server.py

示例13: main

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,代码行数:27,代码来源:run_tests.py

示例14: test_slice_line

 def test_slice_line(self):
     print "::test_slice_line starts ..."
     sv = Server()
     sv.stored_previous_partial = "cuu"
     sv.prepared_line = "p   B"
     sv.slice_line()
     self.assertEquals("cuu", sv.sm.slice_result[0])
开发者ID:photonxp,项目名称:word_slicer_demo,代码行数:7,代码来源:tests.py

示例15: crawl_listing

def crawl_listing():
    from server import Server
    ss = Server()
#    pool = Pool(50)
    it = 0 
    num_cats = Category.objects().count()
    for c in Category.objects(is_leaf=True):
        it += 1
        print c.catname, it, 'of', num_cats
        if c.spout_time and  c.spout_time > datetime.utcnow()-timedelta(hours=8):
            print '...skipped'
            continue
        if c.num:
            num_page = (c.num - 1) // ITEM_PER_PAGE + 1
            for page in xrange(1, num_page+1):
                page_item_NO = (page-1)*ITEM_PER_PAGE
                url = c.url( page_item_NO )
                if page == num_page:
#                    pool.spawn(ss.crawl_listing, url, c.catstr, page, c.num % ITEM_PER_PAGE)
                    ss.crawl_listing( url, c.catstr(), page, c.num % ITEM_PER_PAGE)
                else:
#                    pool.spawn(ss.crawl_listing, url, c.catstr, page)
                    ss.crawl_listing( url, c.catstr(), page)
                progress(str(page)+' ')
            print
        c.spout_time = datetime.utcnow()
        c.save()
开发者ID:mobishift2011,项目名称:amzn,代码行数:27,代码来源:client.py


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