本文整理汇总了Python中server.Server方法的典型用法代码示例。如果您正苦于以下问题:Python server.Server方法的具体用法?Python server.Server怎么用?Python server.Server使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类server
的用法示例。
在下文中一共展示了server.Server方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: import server [as 别名]
# 或者: from server import Server [as 别名]
def main(args):
"""
程序主函数
"""
parsed_args = parse_args(args)
settings.update({
'cache': parsed_args.cache,
'log': parsed_args.log,
'database': parsed_args.database,
'port': parsed_args.port,
'debug': parsed_args.debug,
'quiet': parsed_args.quiet,
})
init_env()
init_logger()
db.init(parsed_args.database)
server = Server(parsed_args.port, DEFAULT_SERVICE_HOST, parsed_args.cache)
server.run()
示例2: __init__
# 需要导入模块: import server [as 别名]
# 或者: from server import Server [as 别名]
def __init__(self, url, port=None, ip=None, auto_shutdown=True, wait_time=20, timeout=5, is_playing_fnc=None):
self.port = port if port else random.randint(8000,8099)
self.ip = ip if ip else "127.0.0.1"
self.connected = False
self.start_time = None
self.last_connect = None
self.is_playing_fnc = is_playing_fnc
self.auto_shutdown = auto_shutdown
self.wait_time = wait_time
self.timeout = timeout
self.running = False
self.file = None
self.files = []
self._server = Server((self.ip, self.port), Handler, client=self)
self.add_url(url)
self.start()
示例3: main
# 需要导入模块: import server [as 别名]
# 或者: from server import Server [as 别名]
def main():
server.Server()
示例4: __init__
# 需要导入模块: import server [as 别名]
# 或者: from server import Server [as 别名]
def __init__(self, options):
state.EventDispatcher.__init__(self, [EVENT_NEW_BYTE])
self.options = options
self.local_time_now = None
self.element_manager = ElementManager()
self.element_state_manager = ElementStateManager(self.element_manager, self)
self.frame_tracker = state.FrameTracker(NUM_MINOR_FRAMES)
self.subcom_trackers = {}
self.trackers = {MINOR_FRAME_KEY: self.frame_tracker}
if options.input:
self.deframer = ByteDeframer(MINOR_FRAME_LEN)
self.net = input.FileInput()
elif options.network_address:
self.deframer = ByteDeframer(MINOR_FRAME_LEN)
self.net = net.TCPNetwork()
else:
self.deframer = SymbolDeframer(MINOR_FRAME_LEN)
self.net = net.UDPNetwork()
self.server = server.Server(self, self.element_manager, self.element_state_manager, global_log)
if options.headless:
self.ui = None
else:
self.ui = ui.UserInterface(self)
示例5: stop
# 需要导入模块: import server [as 别名]
# 或者: from server import Server [as 别名]
def stop(self):
if self.ui: self.ui.stop()
#print "UI shutdown"
if self.server.exception:
print "An exception occurred in the Server:", self.server.exception
self.server.stop()
if self.net.exception:
print "An exception occurred in the NetworkThread:", self.net.exception
self.net.stop()
#print "Net stop"
示例6: start
# 需要导入模块: import server [as 别名]
# 或者: from server import Server [as 别名]
def start(self):
self.start_time = time.time()
self.running = True
self._server.run()
t= Thread(target=self._auto_shutdown)
t.setDaemon(True)
t.start()
logger.info("MEGA Server Started")
示例7: stop
# 需要导入模块: import server [as 别名]
# 或者: from server import Server [as 别名]
def stop(self):
self.running = False
self._server.stop()
logger.info("MEGA Server Stopped")
示例8: __init__
# 需要导入模块: import server [as 别名]
# 或者: from server import Server [as 别名]
def __init__(self, name, save, port, settings):
self.game = True
self.error = None
self.serving = False
self.time = timings['tick']
self._name = name
self.current_players = {}
self._server = Server(name, save, port, settings, self)
self._server.local_interface_login()
示例9: setUp
# 需要导入模块: import server [as 别名]
# 或者: from server import Server [as 别名]
def setUp(self):
self.payload = [0x1, 0x2, 0x3]
self.inexisting_service_id = 0xFF
self.handle = multiprocessing.Queue()
self.server = server.Server(
self.handle,
self.project_root_directory,
self.target,
cxxd_mocks.ServicePluginMock(),
cxxd_mocks.ServicePluginMock(),
cxxd_mocks.ServicePluginMock(),
cxxd_mocks.ServicePluginMock()
)
示例10:
# 需要导入模块: import server [as 别名]
# 或者: from server import Server [as 别名]
def test_if_start_all_services_starts_service_listener_first_and_then_sends_startup_request_for_each_service(self):
manager = mock.MagicMock()
api.server_start_all_services(self.handle, self.payload)
with mock.patch('server.Server.ServiceHandler.start_listening') as mock_start_listening:
with mock.patch('server.Server.ServiceHandler.startup_request') as mock_startup_request:
manager.attach_mock(mock_start_listening, 'mock_start_listening')
manager.attach_mock(mock_startup_request, 'mock_startup_request')
self.server.process_request()
mock_start_listening.assert_called()
self.assertEqual(mock_start_listening.call_count, len(self.server.service))
mock_startup_request.assert_called_with([self.payload])
self.assertEqual(mock_startup_request.call_count, len(self.server.service))
manager.assert_has_calls(
[mock.call.mock_start_listening(), mock.call.mock_startup_request([self.payload])]
)
示例11: test_if_start_service_starts_service_listener_first_and_then_sends_startup_request
# 需要导入模块: import server [as 别名]
# 或者: from server import Server [as 别名]
def test_if_start_service_starts_service_listener_first_and_then_sends_startup_request(self):
manager = mock.MagicMock()
api._server_start_service(self.handle, server.ServiceId.SOURCE_CODE_MODEL, self.payload)
with mock.patch('server.Server.ServiceHandler.start_listening') as mock_start_listening:
with mock.patch('server.Server.ServiceHandler.startup_request') as mock_startup_request:
manager.attach_mock(mock_start_listening, 'mock_start_listening')
manager.attach_mock(mock_startup_request, 'mock_startup_request')
self.server.process_request()
mock_start_listening.assert_called_once()
mock_startup_request.assert_called_once_with([self.payload])
manager.assert_has_calls(
[mock.call.mock_start_listening(), mock.call.mock_startup_request([self.payload])]
)
示例12: test_if_start_service_does_not_start_service_listener_or_sends_startup_request_for_unknown_service_id
# 需要导入模块: import server [as 别名]
# 或者: from server import Server [as 别名]
def test_if_start_service_does_not_start_service_listener_or_sends_startup_request_for_unknown_service_id(self):
api._server_start_service(self.handle, self.inexisting_service_id, self.payload)
with mock.patch('server.Server.ServiceHandler.start_listening') as mock_start_listening:
with mock.patch('server.Server.ServiceHandler.startup_request') as mock_startup_request:
self.server.process_request()
mock_start_listening.assert_not_called()
mock_startup_request.assert_not_called()
示例13: test_if_shutdown_and_exit_shuts_down_all_services_and_shuts_server_down
# 需要导入模块: import server [as 别名]
# 或者: from server import Server [as 别名]
def test_if_shutdown_and_exit_shuts_down_all_services_and_shuts_server_down(self):
dummy_service_id = 0x0
api.server_stop(self.handle, self.payload)
with mock.patch('server.Server._Server__shutdown_all_services') as mock_shutdown_all_services:
self.assertEqual(self.server.process_request(), False)
mock_shutdown_all_services.assert_called_once_with(dummy_service_id, [self.payload])
示例14: test_if_send_service_request_sends_request
# 需要导入模块: import server [as 别名]
# 或者: from server import Server [as 别名]
def test_if_send_service_request_sends_request(self):
api._server_request_service(self.handle, server.ServiceId.SOURCE_CODE_MODEL, self.payload)
with mock.patch('server.Server.ServiceHandler.request') as mock_send_request:
self.assertEqual(self.server.process_request(), True)
mock_send_request.assert_called_once_with([self.payload])
示例15: test_if_unsupported_server_request_is_well_handled
# 需要导入模块: import server [as 别名]
# 或者: from server import Server [as 别名]
def test_if_unsupported_server_request_is_well_handled(self):
unsupported_server_request = 0xFAFAFA
dummy_service_id = 0x0
self.server.handle.put([unsupported_server_request, dummy_service_id, [self.payload]])
with mock.patch('server.Server._Server__unknown_action') as mock_unknown_action:
self.server.process_request()
mock_unknown_action.assert_called_once_with(dummy_service_id, [self.payload])