Re: [libvirt] [PATCH] domain:screenshot: Added cleanup function
On 04/16/2012 04:43 AM, Osier Yang wrote: On 2012年04月13日 23:44, Martin Kletzander wrote: Added cleanup function to the screeshot testcase. This makes use of the new sharedmod module. --- WARNING: don't push this before the patch with sharedmod is pushed in the repo, otherwise this will not work. Thanks. repos/domain/screenshot.py |6 ++ 1 files changed, 6 insertions(+), 0 deletions(-) diff --git a/repos/domain/screenshot.py b/repos/domain/screenshot.py index 3e727a7..5a12c4b 100644 --- a/repos/domain/screenshot.py +++ b/repos/domain/screenshot.py @@ -6,6 +6,7 @@ import os import mimetypes import libvirt +import sharedmod required_params = ('guestname', 'filename',) optional_params = ('screen',) @@ -36,6 +37,7 @@ def screenshot(params): logger.debug('Mimetype of the file is %s' % mime) ret = st.finish() +sharedmod.dict['screenshot_filename'] = filename Is it neccessary to set a shared variable in the same case? IIUC the purpose of sharemod.py, it's for variable sharing among different test cases. Though the case will work fine, but it's just redundant, and let's keep things simple. Osier -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list We can share just the extension if you want. I can also change it to share it in the module global variable. However, the parameter can be used by other tests this way, just in case. We talked about what came to this patch here a little bit: https://www.redhat.com/archives/libvir-list/2012-April/msg00172.html I'm willing to change it to whatever suits the others but I'd like to have it asap so I can finish part of documentation based on this test. Martin -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] domain:screenshot: Added cleanup function
On 2012年04月16日 14:52, Martin Kletzander wrote: On 04/16/2012 04:43 AM, Osier Yang wrote: On 2012年04月13日 23:44, Martin Kletzander wrote: Added cleanup function to the screeshot testcase. This makes use of the new sharedmod module. --- WARNING: don't push this before the patch with sharedmod is pushed in the repo, otherwise this will not work. Thanks. repos/domain/screenshot.py |6 ++ 1 files changed, 6 insertions(+), 0 deletions(-) diff --git a/repos/domain/screenshot.py b/repos/domain/screenshot.py index 3e727a7..5a12c4b 100644 --- a/repos/domain/screenshot.py +++ b/repos/domain/screenshot.py @@ -6,6 +6,7 @@ import os import mimetypes import libvirt +import sharedmod required_params = ('guestname', 'filename',) optional_params = ('screen',) @@ -36,6 +37,7 @@ def screenshot(params): logger.debug('Mimetype of the file is %s' % mime) ret = st.finish() +sharedmod.dict['screenshot_filename'] = filename Is it neccessary to set a shared variable in the same case? IIUC the purpose of sharemod.py, it's for variable sharing among different test cases. Though the case will work fine, but it's just redundant, and let's keep things simple. Osier -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list We can share just the extension if you want. I can also change it to share it in the module global variable. However, the parameter can be used by other tests this way, just in case. I don't see any other test case will need the screenshot_filename now, if we have some ones in future, change it to shared var at that time then. The principle is not to put the parameter in shared module if it's no need. Osier -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] domain:screenshot: Added cleanup function
On 04/16/2012 10:00 AM, Osier Yang wrote: On 2012年04月16日 14:52, Martin Kletzander wrote: On 04/16/2012 04:43 AM, Osier Yang wrote: On 2012年04月13日 23:44, Martin Kletzander wrote: Added cleanup function to the screeshot testcase. This makes use of the new sharedmod module. --- WARNING: don't push this before the patch with sharedmod is pushed in the repo, otherwise this will not work. Thanks. repos/domain/screenshot.py |6 ++ 1 files changed, 6 insertions(+), 0 deletions(-) diff --git a/repos/domain/screenshot.py b/repos/domain/screenshot.py index 3e727a7..5a12c4b 100644 --- a/repos/domain/screenshot.py +++ b/repos/domain/screenshot.py @@ -6,6 +6,7 @@ import os import mimetypes import libvirt +import sharedmod required_params = ('guestname', 'filename',) optional_params = ('screen',) @@ -36,6 +37,7 @@ def screenshot(params): logger.debug('Mimetype of the file is %s' % mime) ret = st.finish() +sharedmod.dict['screenshot_filename'] = filename Is it neccessary to set a shared variable in the same case? IIUC the purpose of sharemod.py, it's for variable sharing among different test cases. Though the case will work fine, but it's just redundant, and let's keep things simple. Osier -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list We can share just the extension if you want. I can also change it to share it in the module global variable. However, the parameter can be used by other tests this way, just in case. I don't see any other test case will need the screenshot_filename now, if we have some ones in future, change it to shared var at that time then. The principle is not to put the parameter in shared module if it's no need. Osier OK then, I'll save it in the test and send v2. Martin -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] domain:screenshot: Added cleanup function
On 2012年04月13日 23:44, Martin Kletzander wrote: Added cleanup function to the screeshot testcase. This makes use of the new sharedmod module. --- WARNING: don't push this before the patch with sharedmod is pushed in the repo, otherwise this will not work. Thanks. repos/domain/screenshot.py |6 ++ 1 files changed, 6 insertions(+), 0 deletions(-) diff --git a/repos/domain/screenshot.py b/repos/domain/screenshot.py index 3e727a7..5a12c4b 100644 --- a/repos/domain/screenshot.py +++ b/repos/domain/screenshot.py @@ -6,6 +6,7 @@ import os import mimetypes import libvirt +import sharedmod required_params = ('guestname', 'filename',) optional_params = ('screen',) @@ -36,6 +37,7 @@ def screenshot(params): logger.debug('Mimetype of the file is %s' % mime) ret = st.finish() +sharedmod.dict['screenshot_filename'] = filename Is it neccessary to set a shared variable in the same case? IIUC the purpose of sharemod.py, it's for variable sharing among different test cases. Though the case will work fine, but it's just redundant, and let's keep things simple. Osier -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] domain:screenshot: Added cleanup function
Added cleanup function to the screeshot testcase. This makes use of the new sharedmod module. --- WARNING: don't push this before the patch with sharedmod is pushed in the repo, otherwise this will not work. Thanks. repos/domain/screenshot.py |6 ++ 1 files changed, 6 insertions(+), 0 deletions(-) diff --git a/repos/domain/screenshot.py b/repos/domain/screenshot.py index 3e727a7..5a12c4b 100644 --- a/repos/domain/screenshot.py +++ b/repos/domain/screenshot.py @@ -6,6 +6,7 @@ import os import mimetypes import libvirt +import sharedmod required_params = ('guestname', 'filename',) optional_params = ('screen',) @@ -36,6 +37,7 @@ def screenshot(params): logger.debug('Mimetype of the file is %s' % mime) ret = st.finish() +sharedmod.dict['screenshot_filename'] = filename finally: # Some error occurred, cleanup @@ -43,3 +45,7 @@ def screenshot(params): conn.close() return ret + +def cleanup(params): +if sharedmod.has_key('screenshot_filename'): +os.remove(sharedmod['screenshot_filename']) -- 1.7.8.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list