class NodeGenerator(object): def __init__(self): print 'init....' self.adb = AndroidDebugBridge() print self.adb.attached_devices() def node_add(self, id_serial): cwd = os.getcwd() jar_file = '/usr/bin/java -jar {}/swarm-client-1.20-jar-with-dependencies.jar'.format(cwd) master_host = '{}://{}:{}'.format(proto, host, port) # Swarm slave from <host_ip> : DESCRIPTION description = 'DESCRIPTION' # swarm LABEL1 LABEL2 LABEL3 labels = 'LABEL1 LABEL2 LABEL3' node_name = 'DEV_{}'.format(id_serial) options = ' -master {} -username {} -password {} -description "{}" -labels "{}" -name {}'.format( master_host, username, password, description, labels, node_name ) cmd = '{} {}'.format(jar_file, options) print cmd proc = Popen(cmd, shell=True, stdout=PIPE, stdin=PIPE, stderr=STDOUT) for line in proc.stdout: print "test:", line.rstrip() def nodes_add(self): devs = self.adb.attached_devices() for dev in devs: self.node_add(dev)
def __init__(self): print 'init....' self.adb = AndroidDebugBridge() print self.adb.attached_devices()