From 9f4d151db4f2fbba041d1469f916c412cda7f15f Mon Sep 17 00:00:00 2001 From: Vishal Gowda Date: Tue, 7 Mar 2017 19:29:20 +0530 Subject: [PATCH] Make multiple vnc sessions work --- droid_config.json | 10 +++++++++- hedroid/worker/helpers.py | 5 ++++- hedroid/worker/thrift_server.py | 8 ++++---- start_worker_thrift.py | 2 +- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/droid_config.json b/droid_config.json index fdcb046..e1564f7 100644 --- a/droid_config.json +++ b/droid_config.json @@ -4,7 +4,15 @@ "droids": [ { "port": "5554", - "avd": "nexus6-android7" + "avd": "nexus6-android7", + "display": "1", + "ws_port": "6080" + }, + { + "port": "5556", + "avd": "nexus6-android7-2", + "display": "2", + "ws_port": "6081" } ] } diff --git a/hedroid/worker/helpers.py b/hedroid/worker/helpers.py index 3d64121..fda5d23 100644 --- a/hedroid/worker/helpers.py +++ b/hedroid/worker/helpers.py @@ -35,6 +35,7 @@ def start(self): proc.stop() except: pass + raise def stop(self): logger.debug('Stopping droid') @@ -55,7 +56,7 @@ def __init__(self): self.dpi = 560 self.dim = '720x1280x24' self.clip = '530x965+15+30' - self.ws_port = 6080 + self.ws_port = '6080' def set_port(self, port): self.port = port @@ -138,6 +139,8 @@ def setup(self): self.start_droid(droid) except IndexError: break + except: + pass def count(self): return len(self.initialised) diff --git a/hedroid/worker/thrift_server.py b/hedroid/worker/thrift_server.py index dbb8208..17134d2 100644 --- a/hedroid/worker/thrift_server.py +++ b/hedroid/worker/thrift_server.py @@ -1,3 +1,4 @@ +import os import atexit import requests @@ -37,10 +38,9 @@ def setup(self): config = get_config() builder = DroidBuilder() for droid in config['droids']: - if droid['port']: - builder.set_port(droid['port']) - if droid['avd']: - builder.set_avd(droid['avd']) + for key, value in droid.iteritems(): + func = getattr(builder, "set_{}".format(key)) + func(value) self.coordinator.add_droid(builder.build()) # Start all endpoints now self.coordinator.setup() diff --git a/start_worker_thrift.py b/start_worker_thrift.py index e966fc9..bcd46db 100755 --- a/start_worker_thrift.py +++ b/start_worker_thrift.py @@ -1,5 +1,5 @@ #! /usr/bin/env python -from worker.thrift_server import start_server +from hedroid.worker.thrift_server import start_server if __name__ == '__main__':