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


Python Server.startServer方法代码示例

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


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

示例1: Launcher

# 需要导入模块: from Server import Server [as 别名]
# 或者: from Server.Server import startServer [as 别名]
class Launcher(object):
    '''
    This class sets up and configures the Server and starts it.
    '''

    def __init__(self, configPath):
        serverConfig = ServerConfig(configPath)

        self.warehouse = Warehouse(serverConfig.getWarehousePath())

        logMngr = ServerLogger()
        logMngr.addFileHandler(serverConfig.getLogDirectory())

        self.server = Server(int(serverConfig.getPortNo()),
                             serverConfig.getURLHandlers())
        

        

    def startServer(self):
        self.server.startServer()

    def stopServer(self):
        self.server.stopServer()
开发者ID:XuryaX,项目名称:lookup,代码行数:26,代码来源:Launcher.py

示例2: Server

# 需要导入模块: from Server import Server [as 别名]
# 或者: from Server.Server import startServer [as 别名]
from Server import Server

if __name__ == "__main__":

    server = Server()
    server.startServer()
    server.start()

    strIn = raw_input("Press to Stop Server\n")

    server.closeServer()

开发者ID:mohiulalamprince,项目名称:github,代码行数:13,代码来源:TestServer.py

示例3: __init__

# 需要导入模块: from Server import Server [as 别名]
# 或者: from Server.Server import startServer [as 别名]
class SpinOS:

    logger = None
    def __init__(self):
        print("SpinOS 0.2")
        print("Group 5 IDP 2014 NHL")
        print("Default string encoding : " + str(sys.getdefaultencoding()).upper())
        SpinOS.logger = Logger(Logger.SENSOR_VALUES)
        print("Logger level : " + SpinOS.logger.get_loglevel_string())

        GPIO.setmode(GPIO.BOARD) ## Use board pin numbering
        GPIO.setup(11, GPIO.OUT)
        GPIO.setwarnings(False)

        SpinOS.play_sound(2)
        #logger aanmaken
        self.movementHandler = MovementHandler()

        #server maken op poort 15, omdat ie vrij is
        self.server = Server(15, SpinOS.logger)
        #server starten
        self.server.startServer()
        #server aan logger geven
        SpinOS.logger.set_server(self.server)

        #running op true zetten
        self.running = True
        #mode op manual zetten
        self.mode = "manual"
        #server aanmaken en starten

        self.current_mode = ManualMode(self.movementHandler, self.logger)

        #main loop opstarten
        self.main_thread = threading.Thread(target=self.run)
        self.main_thread.start()

        #Check of we op de raspberry pi zitten
        if platform.system() != "Windows":
            #import mpu
            from MPU6050 import MPU6050
            self.MPU = MPU6050(SpinOS.logger)
            #import os.path om te kijken of de arduino er is
            import os.path
            self.serial_device = None
            #loop door verschillende usb devices. De naam veranderd namelijk soms
            for i in xrange(0, 3):
                #de naam van de usb
                serial_device = "/dev/ttyUSB" + str(i)
                #kijk of de usb er is
                if os.path.exists(serial_device):
                    #als de arduino er is moeten we serial importen
                    from Serial import Serial
                    #maak een nieuwe serial
                    self.serial = Serial(SpinOS.logger, serial_device)
                    #sla de naam van de arduino op
                    self.serial_device = serial_device
                    break
            #start de sensor thread
            self.sensor_running = True
            self.sensor_thread = threading.Thread(target=self.runSensors())
            self.sensor_thread.start()

    @staticmethod
    def play_sound(time_to_sleep):
        GPIO.output(11,True)
        time.sleep(float(time_to_sleep))
        GPIO.output(11,False)

    #run methode, deze loopt in eigen thread en halen de commando's op
    def run(self):
        try:
            while self.running:
                time.sleep(0.2)
                message_list = self.server.get_messages()#berichten ophalen van serverclients
                for message in message_list:
                    client = message[0]#client is eerste in lijst
                    message.remove(client)#verwijderen uit lijst
                    if message[0] == COMMAND.IDENTIFY:#if en elsif om te achterhalen welk commando is gegeven
                        #kijken welk apparaat connect
                        if message[1] == "dashboard":
                            client.type = ServerClient.ANDROID_DASHBOARD
                            self.logger.logevent("SPINOS", "Connected - ANDROID_DASHBOARD", Logger.MESSAGE)
                        elif message[1] == "controller":
                            client.type = ServerClient.ANDROID_CONTROLLER
                            self.logger.logevent("SPINOS", "Connected - ANDROID_CONTROLLER", Logger.MESSAGE)
                        elif message[1] == "gamepad":
                            client.type = ServerClient.GAMEPAD_CONTROLLER
                            self.logger.logevent("SPINOS", "Connected - GAMEPAD_CONTROLLER", Logger.MESSAGE)
                        else:
                            client.type = ServerClient.UNKNOWN
                            self.logger.logevent("SPINOS", "Connected - UNKNOWN", Logger.WARNING)
                    elif message[0] == COMMAND.KILL:
                        #spider wordt uitegezet alle threads worden gestopt
                        self.logger.logevent("SPINOS", "KILLING SPIDER, OH NO!!!!!")
                        self.running = False
                        self.shutdown()
                    elif message[0] == COMMAND.TO_MANUAL:
                        #huidige mode alive false zodat threads stoppen
                        self.current_mode.set_alive(False)
#.........这里部分代码省略.........
开发者ID:hen31,项目名称:SpinDP,代码行数:103,代码来源:SpinOS.py


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