Re: [libvirt-test-API PATCH] domain:screenshot: Added cleanup function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2012年04月16日 17:32, Martin Kletzander wrote:
---
v2:
  - removed sharedmod for persistence of the filename

  repos/domain/screenshot.py |    8 +++++++-
  1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/repos/domain/screenshot.py b/repos/domain/screenshot.py
index 82425f3..2761dc5 100644
--- a/repos/domain/screenshot.py
+++ b/repos/domain/screenshot.py
@@ -10,6 +10,8 @@ import libvirt
  required_params = ('guestname', 'filename',)
  optional_params = ('screen',)

+last_filename = None
+
  def saver(stream, data, file_):
      return file_.write(data)

@@ -27,7 +29,7 @@ def screenshot(params):
      mime = dom.screenshot(st, int(screen), 0)

      ext = mimetypes.guess_extension(mime) or '.ppm'
-    filename = params['filename'] + ext
+    last_filename = params['filename'] + ext
      f = file(filename, 'w')

      logger.debug('Saving screenshot into %s' % filename)
@@ -37,3 +39,7 @@ def screenshot(params):
      ret = st.finish()

      return ret
+
+def cleanup(params):
+    if last_filename:
+        os.remove(sharedmod['last_filename'])

Shoud this be the following instead?

           os.remove(last_filename)

ACK with the nit fixed.

Regards,
Osier

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]