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


Python Server类代码示例

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


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

示例1: setup_server

	def setup_server(self, api):
		api.update( api_gen.get_decorated() )
		self.setup_websocket_callback_api(api)
		self.setup_blender_hack( bpy.context, use_gtk=False, headless=True )
		print('blender hack setup ok')
		Server.set_api( self )
		print('custom api set')
开发者ID:antwan2000arp,项目名称:pyppet,代码行数:7,代码来源:server_api.py

示例2: newApp

def newApp(args, options):
    from j25.Configuration import Configuration

    if len(args) < 2:
        print >> sys.stderr, "you must supply the name of the app"
        exit(1)
    _checkProject(AUTO_PROJECT_DIRS)
    appName = args[1]
    appDirectory = os.path.join('apps', appName)
    print Server.getBanner()
    print COLOR_SEQ % 33
    try:
        _createPythonPackage(HERE, appDirectory, True)
        f = open(os.path.join(appDirectory, 'config.py'), 'w')
        f.write(app_config_template)
        f.close()
        f = open(os.path.join(appDirectory, 'routing.py'), 'w')
        f.write(app_routing_template % appName)
        f.close()
        for directory, is_python_package in AUTO_APP_DIRS:
            _createPythonPackage(appDirectory, directory, is_python_package)
        #update configuration
        config = Configuration.load_file("server.ini", False)
        currentApps = eval(config.main.applications)
        assert isinstance(currentApps, list)
        currentApps.append('apps.%s' % appName)
        config.main.applications = str(list(set(currentApps)))
        Configuration.dump_file("server.ini", config)
        logger.info("Application %s has been created. Current project has been configured." % appName)
    finally:
        print RESET_SEQ
开发者ID:cloud9ers,项目名称:j25framework,代码行数:31,代码来源:run.py

示例3: __init__

    def __init__(self, *args):
        Privilege.init()
        PyExt.init()
        StdChal.init()
        IOLoop.configure(EvIOLoop)

        Server.init_socket_server()

        super().__init__(*args)
开发者ID:pzread,项目名称:judge,代码行数:9,代码来源:TestWebSock.py

示例4: newProject

def newProject(args, options):
    from j25.Configuration import Configuration

    if len(args) < 2:
        print >> sys.stderr, "Please supply a project name"
        exit(1)
    appName = options.withapp
    projectName = args[1]
    print Server.getBanner()
    print COLOR_SEQ % 33
    print "Creating project: %s" % projectName
    _createPythonPackage(HERE, projectName, False)
    #creating project structure
    for directory, is_python_package in AUTO_PROJECT_DIRS:
        _createPythonPackage(projectName, directory, is_python_package)
    #creating templates
    config = Configuration.create_empty_config()
    s1 = config.add_section('main')
    s1.add_option('project_name', projectName)
    s1.add_option('applications', [])
    s1.add_option('excluded_applications_from_worker', [])
    s1.add_option("mode", "DEV")
    s1.add_option("ip", "0.0.0.0")
    s1.add_option("port", "8800")
    s1.add_option("is_subdomain_aware", True) 
    
    s2 = config.add_section('session')
    s1.add_option('project_name', projectName)
    s2.add_option('secret', uuid4().hex + uuid4().hex)
    s2.add_option('url', ('%s/c9#session' % Constants.MONGODB_URL))
    s2.add_option('secure', 'False')
    s2.add_option('timeout', '600')
    s3 = config.add_section('store')
    s3.add_option("db_name", "c9_%s" % projectName)
    s3.add_option("ip", "127.0.0.1")
    s3.add_option("auto_create_collections", None)  
    Configuration.dump_file(os.path.join(projectName, 'server.ini'), config)
    f = open(os.path.join(projectName, 'routing.py'), 'w')
    f.write(project_routing_template)
    f.close()
    f = open(os.path.join(projectName, 'workerconfig.py'), 'w')
    f.write(app_workerconfig)
    f.close()
    if options.withapp:
        config = Configuration.load_file(os.path.join(projectName, 'server.ini'), False)
        builtin_Apps = eval(config.main.applications)
        assert isinstance(builtin_Apps, list)
        if not appName in builtin_Apps:
            builtin_Apps.append(appName)
            config.main.applications = str(builtin_Apps)
            Configuration.dump_file(os.path.join(projectName, 'server.ini'), config)
            logger.info("\033[1;33mProject %s Created with Application %s.\033[0m"% (projectName, appName))
        else:
            logger.info("\033[1;33mApplication %s already installed in the project by Default.\033[0m" % appName)
    print RESET_SEQ
开发者ID:cloud9ers,项目名称:j25framework,代码行数:55,代码来源:run.py

示例5: key_up_event

def key_up_event(event, response, chan):
	channel = synth.channels[int(chan)]
	elem = minidom.Document().createElement("note")

	elem.setAttribute("start", str(Server.getTime(channel.getEnvelope().startTime)))
	elem.setAttribute("end", str(Server.getTime(time.time())))
	elem.setAttribute("note", str(channel.getNote()))
	elem.setAttribute("vol", str(channel.getVelocity()))
	elem.setAttribute("chan", str(chan))
	appendLog(elem)
	channel.noteOff()
开发者ID:willemsiers,项目名称:RAW-synthesizer,代码行数:11,代码来源:SynthController.py

示例6: Init_Mode

def Init_Mode() :
    global Script_mode
    global Script_Path
    
    #return_code = subprocess.call(['ping','-c','5','157.182.184.52'])
    return_code = 0
    if return_code == 1 :
        Script_mode = True
        script.init_dir()
        script.read(Script_Path)
    else :
        Server.open(url)
开发者ID:dsmith17,项目名称:golfcart,代码行数:12,代码来源:controller.py

示例7: update

	def update(self):
		key = pygame.key.get_pressed()
		mouse = pygame.mouse.get_pressed()

		for event in pygame.event.get():
			if event.type == QUIT or (key[K_F4] and key[K_LALT]):
				return False, self

			elif event.type == MOUSEBUTTONDOWN:
				mse = pygame.mouse.get_pos()

				if self.buttons["server"].onButton(mse):
					self.buttonSound.play()
					server = Server('');
					server.connect()

					return True, MultiGameRabbitMenu.MultiGameRabbitMenu(server)

					# server.accept()
					# server.send(b"connexion avec client : OK")
					# server.recieve()

				elif self.buttons["client"].onButton(mse):
					self.buttonSound.play()

					return True, MultiGameRabbitMenu.MultiGameRabbitMenu()

					# client = Client('localhost')
					# client.connect()
					# client.recieve()
					# client.send(b"connexion avec serveur : OK")

				elif self.buttons["back"].onButton(mse):
					self.buttonSound.play()
					return True, PlayModeMenu.PlayModeMenu()

			elif event.type == MOUSEMOTION:
				mse = pygame.mouse.get_pos()

				pygame.mouse.set_cursor(*pygame.cursors.arrow)

				for button in self.buttons.values():
					if button.onButton(mse):
						pygame.mouse.set_cursor(*pygame.cursors.tri_left)

		self.screen.blit(self.background, self.background.get_rect(), self.background.get_rect())

		for button in self.buttons.values():
			button.update()

		pygame.display.update()

		return True, self
开发者ID:Barbatos,项目名称:BumpNJump,代码行数:53,代码来源:MultiMenu.py

示例8: serverTesting

def serverTesting(): # only for testing .

	#configuration
	ServerHandler = Server.qcServer(8080)
	serverThread = Server.openServerThread(ServerHandler)
	serverThread.start()
	try:
		while True:
			Hello = 1
	except Exception:
		ServerHandler.closeServer()
		return 0
开发者ID:bumatan,项目名称:QuadCopter,代码行数:12,代码来源:main.py

示例9: main

def main():
    print_lock = Lock()

    socket_lock = Lock()
    server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    Server.setupSocket(print_lock, server_addr, server_socket)

    rasp_serial = serial.Serial(
        port='/dev/ttyACM0', # Linux
        #port='COM8',           # Windows
        baudrate=9600,
    )

    settings.init()

    threads = []

    update_sensors_thread = Thread(
        target=Server.update_sensors,
        args=(print_lock, rasp_serial)
    )

    threads.append(update_sensors_thread)
    update_sensors_thread.start()

    update_cameras_thread = Thread(
        target=Server.update_camera
    )
    
    threads.append(update_cameras_thread)
    update_cameras_thread.start()

    should_continue = True

    while should_continue:
        with print_lock:
            print "Waiting for new client..."

        client, addr = server_socket.accept()

        thread = Thread(target=Server.run, args=(print_lock, client))
        threads.append(thread)
        thread.start()

    with print_lock:
        print "Joining threads."

    for thread in threads:
        thread.join()

    with print_lock:
        print "All threads closed."
开发者ID:LoganRickert,项目名称:NASA-Robot-Arduino-RPI,代码行数:52,代码来源:server_main.py

示例10: main

def main():

  ADDR = getArg( "a", "127.0.0.1", "Address" )
  PORT = getArg( "p", 5005, "Port" )
  MAX_CLIENTS = getArg( "m", 50, "Max Clients" )

  # Create server
  SERVER = Server( ADDR, PORT, MAX_CLIENTS )

  # Server main loop
  SERVER.main()

  SERVER.close()
开发者ID:Alfwich,项目名称:school,代码行数:13,代码来源:ChatServer.py

示例11: handle_exception

    def handle_exception (self, exception, client = None):
        """
        Handles an unexpected exception that occurs during client processing.

        @param exception (Exception)     The exception raised.
        @param client    (FastcgiClient) The client instance that generated the exception.
        """

        Server.handle_exception(self, exception, client)

        if not client or not client.request_id:
            return

        client._write_record(_StreamRecord(FCGI_STDERR, "Could not process request: Internal error", client.request_id))
        client._write_record(_EndRequestRecord(1, FCGI_REQUEST_COMPLETE, client.request_id))
开发者ID:orther,项目名称:Elements,代码行数:15,代码来源:fastcgi.py

示例12: __init__

    def __init__(self, parent=None):
        QMainWindow.__init__(self, parent)

        self.setupUi(self)

        # self.clients = []
        if sys.platform == 'darwin':
           self.menubar.setNativeMenuBar(False)

        # self.pc_names = {}
        # self.pc_names['localhost'] = 'Randy'

        self.server = Server(self)
        self.server.message.connect(self.receiveMessage)
        self.server.start()
        
        self.createActions()
        self.createTrayIcon()

        self.sendButton.clicked.connect(self.send_message)
        self.lineEdit.returnPressed.connect(self.send_message)
        self.actionQuit.triggered.connect(qApp.quit)

        self.trayIcon.setIcon(QIcon(':images/trash.svg'))
        self.trayIcon.show()
开发者ID:xran-deex,项目名称:PyChat,代码行数:25,代码来源:PyChatClient.py

示例13: OnStart

    def OnStart(self, event=None):
        if not self.status:
            if not self.me or self.me == '*':
                common.showerror(self, tr("Username should not be empty or '*'"))
                self.txtName.SetFocus()
                return

            ip = self.txtIP.GetValue()
            if not ip:
                common.showerror(self, tr("Host address cannot be empty!"))
                self.txtIP.SetFocus()
                return
            port = int(self.txtPort.GetValue())
            self.pref.pairprog_host = ip
            self.pref.pairprog_port = port
            self.pref.pairprog_username = self.me
            self.pref.save()
            try:
                self.server = Server.start_server(ip, port, self.servercommands)
                if self.server:
                    self.AddUser(self.me, manager=True)
                    self.change_status('startserver')
                    self.callplugin('start', self, 'server')
            except:
                common.warn(tr("Start server error!"))
                error.traceback()
        else:
            self.server.shut_down()
            self.server = None
            self.change_status('stopserver')
            self.callplugin('stop', self, 'server')
开发者ID:LaoMa3953,项目名称:ulipad,代码行数:31,代码来源:Concurrent.py

示例14: World

class World(DirectObject):
    def __init__(self):
        # Start our server up
        self.server = Server(9099, compress=True)
        
        # Create a task to print and send data
        taskMgr.doMethodLater(2.0, self.printTask, "printData")
        
    def printTask(self, task):
        # Print out results
        print "Received: " + str(self.server.getData())
        print "Clients: " + str(self.server.getClients())
        
        # Broadcast data to all clients
        self.server.broadcastData("Server's Data")
        
        return Task.again
开发者ID:gelatindesign,项目名称:Colony,代码行数:17,代码来源:test_server.py

示例15: installApp

def installApp(args, options):
    from j25.Configuration import Configuration
    if len(args) < 2:
        print >> sys.stderr, "you must supply the name of the app"
        exit(1)
    _checkProject(AUTO_PROJECT_DIRS)
    appName = args[1]
    print Server.getBanner()
    print COLOR_SEQ % 33
    config = Configuration.load_file('server.ini', False)
    currentApps = eval(config.main.applications)
    assert isinstance(currentApps, list)
    if not appName in currentApps:
        currentApps.append(appName)
        config.main.applications = str(currentApps)
        Configuration.dump_file('server.ini', config)
        logger.info("\033[1;33mApplication %s added to project.\033[0m"% appName)
    else:
        logger.info("\033[1;33mApplication %s already installed in the project.\033[0m" % appName)
开发者ID:cloud9ers,项目名称:j25framework,代码行数:19,代码来源:run.py


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