[libvirt] [test-API][PATCH 1/2] Fix compatibility problem on python 2.4

* switch rpartition with rsplit * adjust the style --- generator.py | 15 +++++++++++---- 1 files changed, 11 insertions(+), 4 deletions(-) diff --git a/generator.py b/generator.py index 9a2ed06..6108963 100644 --- a/generator.py +++ b/generator.py @@ -124,10 +124,14 @@ class FuncGen(object): for i in range(loop_number): case_ref_name = self.cases_ref_names[i] - pkg_casename = case_ref_name.rpartition(":")[0] - funcname = case_ref_name.rpartition(":")[-1] + pkg_casename = case_ref_name.rsplit(":", 1)[0] + funcname = case_ref_name.rsplit(":", 1)[-1] + + if "_clean" not in funcname: + cleanoper = 0 + else: + cleanoper = 1 - cleanoper = 0 if "_clean" not in funcname else 1 if not cleanoper: self.fmt.print_start(pkg_casename, env_logger) @@ -182,7 +186,10 @@ class FuncGen(object): if not cleanoper: self.fmt.print_end(pkg_casename, ret, env_logger) else: - self.fmt.print_string(21*" " + "Done" if clean_ret < 1 else 21*" " + "Fail", env_logger) + if clean_ret < 1: + self.fmt.print_string(21*" " + "Done", env_logger) + else: + self.fmt.print_string(21*" " + "Fail", env_logger) end_time = time.strftime("%Y-%m-%d %H:%M:%S") -- 1.7.1

--- utils/Python/format.py | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/utils/Python/format.py b/utils/Python/format.py index 5de8eb0..9c119dd 100644 --- a/utils/Python/format.py +++ b/utils/Python/format.py @@ -33,7 +33,7 @@ class Format(object): def print_string(self, msg, env_logger): """Only print a simple string""" - env_logger(msg) + env_logger.info(msg) self.write_log('\n%s' %msg) def print_start(self, msg, env_logger): -- 1.7.1

ack Guannan Ren ----- Original Message ----- From: "Wayne Sun" <gsun@redhat.com> To: libvir-list@redhat.com Sent: Friday, January 20, 2012 1:34:14 PM Subject: [libvirt] [test-API][PATCH 2/2] Fix problem of a logger instance --- utils/Python/format.py | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/utils/Python/format.py b/utils/Python/format.py index 5de8eb0..9c119dd 100644 --- a/utils/Python/format.py +++ b/utils/Python/format.py @@ -33,7 +33,7 @@ class Format(object): def print_string(self, msg, env_logger): """Only print a simple string""" - env_logger(msg) + env_logger.info(msg) self.write_log('\n%s' %msg) def print_start(self, msg, env_logger): -- 1.7.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list

ack The rpartition string methods family is from Python 2.5. Guannan Ren ----- Original Message ----- From: "Wayne Sun" <gsun@redhat.com> To: libvir-list@redhat.com Sent: Friday, January 20, 2012 1:34:13 PM Subject: [libvirt] [test-API][PATCH 1/2] Fix compatibility problem on python 2.4 * switch rpartition with rsplit * adjust the style --- generator.py | 15 +++++++++++---- 1 files changed, 11 insertions(+), 4 deletions(-) diff --git a/generator.py b/generator.py index 9a2ed06..6108963 100644 --- a/generator.py +++ b/generator.py @@ -124,10 +124,14 @@ class FuncGen(object): for i in range(loop_number): case_ref_name = self.cases_ref_names[i] - pkg_casename = case_ref_name.rpartition(":")[0] - funcname = case_ref_name.rpartition(":")[-1] + pkg_casename = case_ref_name.rsplit(":", 1)[0] + funcname = case_ref_name.rsplit(":", 1)[-1] + + if "_clean" not in funcname: + cleanoper = 0 + else: + cleanoper = 1 - cleanoper = 0 if "_clean" not in funcname else 1 if not cleanoper: self.fmt.print_start(pkg_casename, env_logger) @@ -182,7 +186,10 @@ class FuncGen(object): if not cleanoper: self.fmt.print_end(pkg_casename, ret, env_logger) else: - self.fmt.print_string(21*" " + "Done" if clean_ret < 1 else 21*" " + "Fail", env_logger) + if clean_ret < 1: + self.fmt.print_string(21*" " + "Done", env_logger) + else: + self.fmt.print_string(21*" " + "Fail", env_logger) end_time = time.strftime("%Y-%m-%d %H:%M:%S") -- 1.7.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
participants (2)
-
Guan Nan Ren
-
Wayne Sun