Esempio n. 1
0
	def start_server(self):
		self.stop_server = False
		LOG.info("Starting SCNLP as a subprocess")
		os.chdir( self.jars_folder )
		LOG.info("Starting with command:\n%s" % self.cmd)
		self.proc = tprocess(self.cmd)
		#self.proc.logfile = sys.stdout
		self.proc.expect('NLP>', timeout=None)
		LOG.info(self.proc.before)
		LOG.info("Testing communication with SCNLP process")
		output = self.process_text("This is the test sentence on the server. This is the second test sentence from the server.")
		output_lines = output.split('\n')
		self.server_thread = None
		test_passed = False
		if len(output_lines) > 1:
			test_passed = True
		if not test_passed:
			assert False, "Could not communicate with SCNLP subprocess, shutting down..."

		LOG.info("SCNLP process started successfully!")

		try:
			self.server_socket = self.get_server_socket()
			self.server_socket.listen(1)
			LOG.info("SCNLP Server now listening on port %d" % self.server_port)
			self.server_thread = Thread(target = self.accept_clientes)
			self.server_thread.daemon = True
			self.server_thread.start()
		except Exception as ex:
			assert False, "Could not start the server\n%s" % ex
		print("Returning from the start_server method")
		return 1
	def start_server(self):
		LOG.info("Starting SSPL as a subprocess")
		os.chdir( self.jars_folder )
		self.proc = tprocess(self.cmd)
		self.proc.logfile = sys.stdout
		self.proc.expect('Processing will end when EOF is reached.', timeout=None)
		LOG.info(self.proc.before)
		LOG.info("Testing communication with SSPL process")
		output = self.process_text("This is the test sentence on the server. This is the second test sentence from the server.")
		# output = self.proc.before
		#LOG.info(output)
		#LOG.info(type(output))
		output_lines = output.split('\n')
		test_passed = False
		if len(output_lines) > 1:
			test_passed = True
		if not test_passed:
			assert False, "Could not communicate with SSPL subprocess, shutting down..."

		LOG.info("SSPL process started successfully!")

		try:
			self.server_socket = self.get_server_socket()
			self.server_socket.listen(1)
			LOG.info("SSPL Server now listening on port %d" % self.server_port)
			self.server_thread = Thread(target = self.accept_clientes)
			self.server_thread.daemon = True
			self.server_thread.start()
		except Exception as ex:
			assert False, "Could not start the server\n%s" % ex