public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Lucas Meneghel Rodrigues <lmr@redhat.com>
To: Michael Goldish <mgoldish@redhat.com>
Cc: autotest@test.kernel.org, kvm@vger.kernel.org
Subject: Re: [KVM-AUTOTEST PATCH 1/2] KVM test: optionally convert PPM files to PNG format after test
Date: Thu, 18 Jun 2009 15:28:49 -0300	[thread overview]
Message-ID: <1245349729.3885.6.camel@freedom> (raw)
In-Reply-To: <694310651.199431245322780684.JavaMail.root@zmail05.collab.prod.int.phx2.redhat.com>

On Thu, 2009-06-18 at 06:59 -0400, Michael Goldish wrote:

> The call should never fail because we currently don't raise exceptions.
> It's actually easier to skip the check, because in case ImageMagick
> isn't installed, you'll just get a nice message like:
> 
> 'convert_ppm_files_to_png' specified; converting PPM files to PNG format...
> (mogrify) bash: mogrify: command not found
> (mogrify) (Process terminated with status 127)
> 
> Personally I am fond of these messages because they indicate to me that
> kvm_subprocess is functioning properly, and I also think they're quite
> readable because they contain "bash's own words", but since we might
> raise exceptions in run_bg()/run_fg() in the future, I see your point.

Yes, that was the point. I am not particularly against leaving it as it
is, since we still haven't decided about the behavior of these utility
functions.

> I suppose I should do something like:
> 
> logging.debug("converting ...")
> found = True
> try:
>   os_dep.command("mogrify")
>   found = True
> except:
>   logging.error("'mogrify' not found; ImageMagick is probably not installed")
>   found = False
> if found:
>   mogrify_cmd = ...
>   kvm_subprocess.run_fg(...)

Yes, something along these lines

> Do you see a shorter/more elegant syntax to do this?

Nope, since os_dep() already trhows exceptions by default

> (We can put the conversion code inside the 'try' clause to avoid using
> that 'found' variable, but it's generally recommended to make the code
> inside a 'try' clause as specific as possible.)

Yes, because if something else unexpected happens inside the try clause
we will capture the exception and tell the user generically that the
problem is ImageMagick not installed. So I am for keeping the conversion
out of the try clause.

> In any case, I don't want to fail the test just because mogrify is missing,
> so we do need to catch the exception raised by os_dep.command().

Yes, sounds good to me. I am leaning towards implementing this check
instead of leaving the patch on its original form, so let me know what
is your decision.

-- 
Lucas Meneghel Rodrigues
Software Engineer (QE)
Red Hat - Emerging Technologies


  reply	other threads:[~2009-06-18 18:28 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1773774356.199411245322746771.JavaMail.root@zmail05.collab.prod.int.phx2.redhat.com>
2009-06-18 10:59 ` [KVM-AUTOTEST PATCH 1/2] KVM test: optionally convert PPM files to PNG format after test Michael Goldish
2009-06-18 18:28   ` Lucas Meneghel Rodrigues [this message]
2009-06-16 11:00 Michael Goldish
2009-06-18  9:04 ` Lucas Meneghel Rodrigues
2009-06-18  9:08 ` Lucas Meneghel Rodrigues

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1245349729.3885.6.camel@freedom \
    --to=lmr@redhat.com \
    --cc=autotest@test.kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=mgoldish@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox