Skip to content
Snippets Groups Projects
Commit d14ea43f authored by Philipp Schäfer's avatar Philipp Schäfer
Browse files

VA launcher script: now allows sending a rendering file during connection process

parent 3458b199
No related branches found
No related tags found
No related merge requests found
......@@ -32,9 +32,9 @@ class LauncherConfig:
sys.exit( ErrorCodes.ERROR_INCOMPLETE_CONFIG )
class VAComposedIniParser:
def __init__(self, lsReproductionModuleIDs, sRendererIniPath = None):
def __init__(self, lsReproductionModuleIDs):
self.lsReproductionModuleIDs = lsReproductionModuleIDs
self.sRendererIniPath = sRendererIniPath
self.sRendererIniPath = None
self.sConfFolder = "../conf/"
def _create_parser(self):
......@@ -163,6 +163,7 @@ class VirtualAcousticsLauncher:
self.oLauncherConnection = None
self.sVAServerDir = None
self.sVAServerID = None
self.vaIniParser.sRendererIniPath = None
def _close_va_and_reset_connection(self):
if self.oVAProcess:
......@@ -175,9 +176,6 @@ class VirtualAcousticsLauncher:
def main_loop(self):
try:
#TODO-PSC: Receive file and name from client
self.vaIniParser.sRendererIniPath = None
self.vaIniParser.prepare_inis()
while True:
if not self.oLauncherConnection:
self.wait_for_connection()
......@@ -217,15 +215,23 @@ class VirtualAcousticsLauncher:
self.oVAProcess.kill()
self.oVAProcess = None
self.receive_va_server_id()
self.receive_va_start_info()
self.vaIniParser.prepare_inis()
#Checks for a message containing the ID of the VAServer instance to be started and returns the respective VAServer directory
def receive_va_server_id(self):
def receive_va_start_info(self):
try:
self.sVAServerID = self.oLauncherConnection.recv( 512 )
if type( self.sVAServerID ) is bytes:
self.sVAServerID = self.sVAServerID.decode( 'utf-8' )
sMessage = self.oLauncherConnection.recv( 512 )
if type( sMessage ) is bytes:
sMessage = sMessage.decode( 'utf-8' )
if ":" not in sMessage: #VAServer ID, should be received last
self.sVAServerID = sMessage
else: #VARenderer.ini file, optional
self.vaIniParser.sRendererIniPath = self.receive_file(sMessage)
return self.receive_va_start_info()
print( "Received launch request for variant: " + self.sVAServerID )
except socket.error:
print( "Error while reading variant" )
......@@ -305,7 +311,7 @@ class VirtualAcousticsLauncher:
if sMessage.startswith("file"):
self.receive_file(sMessage)
else: #NOT sMessage.startswith("file")
print( "Received quit event: "+sMessage )
print( "Received quit event: " + sMessage )
self._close_va_and_reset_connection()
break
......@@ -319,6 +325,8 @@ class VirtualAcousticsLauncher:
raise #re-raise for higher instance to catch
# Receives a file from a client, copies it to a tmp folder and returns the respective fullpath
# Input is a string message starting with "file:"
def receive_file(self, sMessage):
aMessageParts = sMessage.split(":")
iBytesToReceive = int(aMessageParts[2])
......@@ -367,6 +375,8 @@ class VirtualAcousticsLauncher:
self.oLauncherConnection.send( b'fail' ) #send failure
print("File receive failed")
return Fullpath+Filename
#create an instance of the class
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment