本文整理汇总了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()
示例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()
示例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)
#.........这里部分代码省略.........