Message ID | 603d8e9011205d1586b36dffead3823a2a61a745.1249257056.git.mgoldish@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Sun, Aug 2, 2009 at 8:58 PM, Michael Goldish<mgoldish@redhat.com> wrote: > Instead of failing, just print a warning. Â Included files may not always be > crucial for tests to run (kvm_cdkeys.cfg for example). > > Signed-off-by: Michael Goldish <mgoldish@redhat.com> > --- > Â client/tests/kvm/kvm_config.py | Â 21 +++++++++++---------- > Â 1 files changed, 11 insertions(+), 10 deletions(-) > > diff --git a/client/tests/kvm/kvm_config.py b/client/tests/kvm/kvm_config.py > index e478a55..7ff7a07 100755 > --- a/client/tests/kvm/kvm_config.py > +++ b/client/tests/kvm/kvm_config.py > @@ -406,17 +406,18 @@ class config: > Â Â Â Â Â Â Â Â if self.filename: > Â Â Â Â Â Â Â Â Â Â filename = os.path.join(os.path.dirname(self.filename), > Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â words[1]) > - Â Â Â Â Â Â Â Â Â Â if not os.path.exists(filename): > - Â Â Â Â Â Â Â Â Â Â Â Â e_msg = "Cannot include %s -- file not found" % filename > - Â Â Â Â Â Â Â Â Â Â Â Â raise error.AutotestError(e_msg) > - Â Â Â Â Â Â Â Â Â Â new_file = open(filename, "r") > - Â Â Â Â Â Â Â Â Â Â list = self.parse(new_file, list, restricted) > - Â Â Â Â Â Â Â Â Â Â new_file.close() > - Â Â Â Â Â Â Â Â Â Â if self.debug and not restricted: > - Â Â Â Â Â Â Â Â Â Â Â Â self.__debug_print("", "Leaving file %s" % words[1]) > + Â Â Â Â Â Â Â Â Â Â if os.path.exists(filename): > + Â Â Â Â Â Â Â Â Â Â Â Â new_file = open(filename, "r") > + Â Â Â Â Â Â Â Â Â Â Â Â list = self.parse(new_file, list, restricted) > + Â Â Â Â Â Â Â Â Â Â Â Â new_file.close() > + Â Â Â Â Â Â Â Â Â Â Â Â if self.debug and not restricted: > + Â Â Â Â Â Â Â Â Â Â Â Â Â Â self.__debug_print("", "Leaving file %s" % words[1]) > + Â Â Â Â Â Â Â Â Â Â else: > + Â Â Â Â Â Â Â Â Â Â Â Â print ("WARNING: Cannot include %s -- " > + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â "file not found" % filename) I quite didn't like the above, because to issue messages like that we should be using the logging infrastructure to avoid to write WARNING, DEBUG and similar strings. Anyway, I understand why kvm_config.py is still using print's. I will apply this, but will send later a patch that makes kvm_config.py to use the logging infrastructure. -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
----- "Lucas Meneghel Rodrigues" <lmr@redhat.com> wrote: > On Sun, Aug 2, 2009 at 8:58 PM, Michael Goldish<mgoldish@redhat.com> > wrote: > > Instead of failing, just print a warning. Â Included files may not > always be > > crucial for tests to run (kvm_cdkeys.cfg for example). > > > > Signed-off-by: Michael Goldish <mgoldish@redhat.com> > > --- > > Â client/tests/kvm/kvm_config.py | Â 21 +++++++++++---------- > > Â 1 files changed, 11 insertions(+), 10 deletions(-) > > > > diff --git a/client/tests/kvm/kvm_config.py > b/client/tests/kvm/kvm_config.py > > index e478a55..7ff7a07 100755 > > --- a/client/tests/kvm/kvm_config.py > > +++ b/client/tests/kvm/kvm_config.py > > @@ -406,17 +406,18 @@ class config: > > Â Â Â Â Â Â Â Â if self.filename: > > Â Â Â Â Â Â Â Â Â Â filename = > os.path.join(os.path.dirname(self.filename), > > Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â words[1]) > > - Â Â Â Â Â Â Â Â Â Â if not os.path.exists(filename): > > - Â Â Â Â Â Â Â Â Â Â Â Â e_msg = "Cannot include %s -- file not > found" % filename > > - Â Â Â Â Â Â Â Â Â Â Â Â raise error.AutotestError(e_msg) > > - Â Â Â Â Â Â Â Â Â Â new_file = open(filename, "r") > > - Â Â Â Â Â Â Â Â Â Â list = self.parse(new_file, list, restricted) > > - Â Â Â Â Â Â Â Â Â Â new_file.close() > > - Â Â Â Â Â Â Â Â Â Â if self.debug and not restricted: > > - Â Â Â Â Â Â Â Â Â Â Â Â self.__debug_print("", "Leaving file %s" % > words[1]) > > + Â Â Â Â Â Â Â Â Â Â if os.path.exists(filename): > > + Â Â Â Â Â Â Â Â Â Â Â Â new_file = open(filename, "r") > > + Â Â Â Â Â Â Â Â Â Â Â Â list = self.parse(new_file, list, > restricted) > > + Â Â Â Â Â Â Â Â Â Â Â Â new_file.close() > > + Â Â Â Â Â Â Â Â Â Â Â Â if self.debug and not restricted: > > + Â Â Â Â Â Â Â Â Â Â Â Â Â Â self.__debug_print("", "Leaving file > %s" % words[1]) > > + Â Â Â Â Â Â Â Â Â Â else: > > + Â Â Â Â Â Â Â Â Â Â Â Â print ("WARNING: Cannot include %s -- " > > + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â "file not found" % filename) > > I quite didn't like the above, because to issue messages like that we > should be using the logging infrastructure to avoid to write WARNING, > DEBUG and similar strings. Anyway, I understand why kvm_config.py is > still using print's. I will apply this, but will send later a patch > that makes kvm_config.py to use the logging infrastructure. Can we use the logging infrastructure in stand-alone modules? -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Fri, Aug 7, 2009 at 7:24 PM, Michael Goldish<mgoldish@redhat.com> wrote: > > ----- "Lucas Meneghel Rodrigues" <lmr@redhat.com> wrote: >>> I quite didn't like the above, because to issue messages like that we >> should be using the logging infrastructure to avoid to write WARNING, >> DEBUG and similar strings. Anyway, I understand why kvm_config.py is >> still using print's. I will apply this, but will send later a patch >> that makes kvm_config.py to use the logging infrastructure. > > Can we use the logging infrastructure in stand-alone modules? Yes, we can, we have logging_manager and logging_config have what is needed. I am going to send a patch showing how to do it with kvm_config.py. -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/client/tests/kvm/kvm_config.py b/client/tests/kvm/kvm_config.py index e478a55..7ff7a07 100755 --- a/client/tests/kvm/kvm_config.py +++ b/client/tests/kvm/kvm_config.py @@ -406,17 +406,18 @@ class config: if self.filename: filename = os.path.join(os.path.dirname(self.filename), words[1]) - if not os.path.exists(filename): - e_msg = "Cannot include %s -- file not found" % filename - raise error.AutotestError(e_msg) - new_file = open(filename, "r") - list = self.parse(new_file, list, restricted) - new_file.close() - if self.debug and not restricted: - self.__debug_print("", "Leaving file %s" % words[1]) + if os.path.exists(filename): + new_file = open(filename, "r") + list = self.parse(new_file, list, restricted) + new_file.close() + if self.debug and not restricted: + self.__debug_print("", "Leaving file %s" % words[1]) + else: + print ("WARNING: Cannot include %s -- " + "file not found" % filename) else: - e_msg = "Cannot include anything because no file is open" - raise error.AutotestError(e_msg) + print ("WARNING: Cannot include %s because no file is " + "currently open" % words[1]) # Parse multi-line exceptions # (the block is parsed for each dict separately)
Instead of failing, just print a warning. Included files may not always be crucial for tests to run (kvm_cdkeys.cfg for example). Signed-off-by: Michael Goldish <mgoldish@redhat.com> --- client/tests/kvm/kvm_config.py | 21 +++++++++++---------- 1 files changed, 11 insertions(+), 10 deletions(-)