本文整理汇总了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()
示例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))
示例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()
示例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)
示例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
示例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
示例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)
示例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)
示例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()
示例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()
示例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()
示例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)
示例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()
示例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()
示例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()