On 04/16/2012 12:14 PM, Osier Yang wrote:
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
Yes, of course, stupid error, sorry.
Fixed and pushed.
Thanks,
Martin