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

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



---
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'])
--
1.7.8.5


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