From 1600d70ca37a94ca3f316ca061f1096130748b59 Mon Sep 17 00:00:00 2001 From: Edison Su Date: Mon, 15 Aug 2011 13:56:36 -0700 Subject: [PATCH] fix code generator, some api response is empty --- tools/testClient/cloudstackTestClient.py | 12 ------------ tools/testClient/codegenerator.py | 19 +++++++++++-------- 2 files changed, 11 insertions(+), 20 deletions(-) diff --git a/tools/testClient/cloudstackTestClient.py b/tools/testClient/cloudstackTestClient.py index 2ac5a1bb89b..1c2aad5ee49 100644 --- a/tools/testClient/cloudstackTestClient.py +++ b/tools/testClient/cloudstackTestClient.py @@ -1,5 +1,4 @@ import cloudstackConnection -import remoteSSHClient import asyncJobMgr import dbConnection from cloudstackAPI import * @@ -20,17 +19,6 @@ class cloudstackTestClient(object): def getDbConnection(self): return self.dbConnection - - def remoteSSHConfigure(self, host, port, user, passwd): - self.ssh = remoteSSHClient.remoteSSHClient(host, port, user, passwd) - - def executeViaSSH(self, command): - if self.ssh is None: - return None - return self.ssh.execute(command) - - def getSSHClient(self): - return self.ssh def executeSql(self, sql=None): if sql is None or self.dbConnection is None: diff --git a/tools/testClient/codegenerator.py b/tools/testClient/codegenerator.py index 98e3eda123c..36310da9518 100644 --- a/tools/testClient/codegenerator.py +++ b/tools/testClient/codegenerator.py @@ -92,15 +92,18 @@ class codeGenerator: self.code += "\n" self.code += 'class %sResponse (baseResponse):\n'%self.cmd.name self.code += self.space + "def __init__(self):\n" - for res in self.cmd.response: - if res.desc is not None: - self.code += self.space + self.space + '"""%s"""\n'%res.desc + if len(self.cmd.response) == 0: + self.code += self.space + self.space + "pass" + else: + for res in self.cmd.response: + if res.desc is not None: + self.code += self.space + self.space + '"""%s"""\n'%res.desc - if len(res.subProperties) > 0: - self.code += self.space + self.space + 'self.%s = []\n'%res.name - self.generateSubClass(res.name, res.subProperties) - else: - self.code += self.space + self.space + 'self.%s = None\n'%res.name + if len(res.subProperties) > 0: + self.code += self.space + self.space + 'self.%s = []\n'%res.name + self.generateSubClass(res.name, res.subProperties) + else: + self.code += self.space + self.space + 'self.%s = None\n'%res.name self.code += '\n' for subclass in self.subclass: