diff mbox

[KVM-AUTOTEST,2/2] Convert images to JPEG using PIL instead of an external program

Message ID 4A82C4C0.1040605@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Avi Kivity Aug. 12, 2009, 1:33 p.m. UTC
On 08/12/2009 04:26 PM, Lucas Meneghel Rodrigues wrote:
> But I prefer to follow the project policy when possible. The reason why
> I accepted the original code that Michael wrote to perform the
> conversion was graceful degradation of functionality (if you don't have
> ImageMagick installed, the test will not abort).
>    

Well, policy is policy.  See the attached (untested).

Comments

Lucas Meneghel Rodrigues Aug. 12, 2009, 3:01 p.m. UTC | #1
On Wed, 2009-08-12 at 16:33 +0300, Avi Kivity wrote:
> On 08/12/2009 04:26 PM, Lucas Meneghel Rodrigues wrote:
> > But I prefer to follow the project policy when possible. The reason why
> > I accepted the original code that Michael wrote to perform the
> > conversion was graceful degradation of functionality (if you don't have
> > ImageMagick installed, the test will not abort).
> >    
> 
> Well, policy is policy.  See the attached (untested).

Ok Avi, I've spotted other places where we are also making unneeded
calls to rm and mogrify, so I changed them, combined the patches,
changed the exception trap only to catch the exceptions we are waiting
for, and send the patch to the mailing list. Please let me know what you
think.

Lucas

--
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
Avi Kivity Aug. 12, 2009, 3:05 p.m. UTC | #2
On 08/12/2009 06:01 PM, Lucas Meneghel Rodrigues wrote:
> Ok Avi, I've spotted other places where we are also making unneeded
> calls to rm and mogrify, so I changed them, combined the patches,
> changed the exception trap only to catch the exceptions we are waiting
> for, and send the patch to the mailing list. Please let me know what you
> think.
>    

Your rework looks good, thanks.
diff mbox

Patch

From 16537ea5270d65837cbd04c13c7289b0714a6d64 Mon Sep 17 00:00:00 2001
From: Avi Kivity <avi@redhat.com>
Date: Wed, 12 Aug 2009 12:00:52 +0300
Subject: [KVM-AUTOTEST PATCH] Convert images to JPEG using PIL instead of an external program

This is faster since we don't need to fork/exec/wait for an external
program each time.

Signed-off-by: Avi Kivity <avi@redhat.com>
---
 client/tests/kvm/kvm_guest_wizard.py |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/client/tests/kvm/kvm_guest_wizard.py b/client/tests/kvm/kvm_guest_wizard.py
index 73b830e..f3cc482 100644
--- a/client/tests/kvm/kvm_guest_wizard.py
+++ b/client/tests/kvm/kvm_guest_wizard.py
@@ -110,9 +110,14 @@  def barrier_2(vm, words, params, debug_dir, data_scrdump_filename,
             history_scrdump_filename = os.path.join(history_dir,
                     "scrdump-step_%s-%s.jpg" % (current_step_num,
                                                 time.strftime("%Y%m%d-%H%M%S")))
-            kvm_subprocess.run_fg("convert -quality 30 %s %s" %
-                                  (scrdump_filename, history_scrdump_filename),
-                                  logging.debug, "(convert) ", timeout=30)
+            def convert_image(src, dest):
+                try:
+                    import PIL.Image
+                    image = PIL.Image.open(src)
+                    image.save(dest, format = 'JPEG', quality = 30)
+                except:
+                    pass
+            convert_image(scrdump_filename, history_scrdump_filename)
 
         # Compare md5sum of barrier region with the expected md5sum
         calced_md5sum = ppm_utils.get_region_md5sum(w, h, data, x1, y1, dx, dy,
-- 
1.6.3.3