<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>You can also add logic to the code as follows:</div><div>-------------------------</div><div>#!/usr/bin/env python</div><div>import sys</div><div>print 'Current version:', hex(sys.hexversion)</div>
<div>if sys.hexversion >= 0x2050000: # version 2.5 or greater.</div><div> import imp # Introduced in version 2.5</div><div> print 'Do the work for the version', hex(sys.hexversion), 'here.'</div><div>
else:</div><div> print "Can't use the module 'imp' because the version is < 2.5."</div><div>-------------------------</div><div><br></div><div><br></div><div>From what I can see of newer Pythons the interpreter will not even look at the else section of the above code.</div>
<div><br></div><div>So I if it is essential for the test to run on older versions of python then the 2.4 or 2.3 specific code could be in the else section. In my view, a segfault is not a good run test.</div><div><br></div>
<div>Alternatively, the CMakeLists.txt solution below is the best for code that will never run on older versions of Python.</div><div><br></div><div>Regards</div><div> Andrew</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
---------- Forwarded message ----------<br>From: David Gobbi <<a href="mailto:david.gobbi@gmail.com">david.gobbi@gmail.com</a>><br>To: Ben Boeckel <<a href="mailto:ben.boeckel@kitware.com">ben.boeckel@kitware.com</a>><br>
Cc: VTK Developers <<a href="mailto:vtk-developers@vtk.org">vtk-developers@vtk.org</a>><br>Date: Thu, 13 Feb 2014 11:42:22 -0700<br>Subject: Re: [vtk-developers] Minimum Python requirement<br>For me, the dashboard should only show green if the test ran _and_<br>
gave a valid result.<br>
<br>
I know that many of the current tests show green if the machine is<br>
incapable of producing a valid result (especially the ones that<br>
require specific GPU functionality), but that's because there isn't an<br>
easy way to check for the needed functionality until run time.<br>
<br>
On Thu, Feb 13, 2014 at 11:22 AM, Ben Boeckel <<a href="mailto:ben.boeckel@kitware.com">ben.boeckel@kitware.com</a>> wrote:<br>
> On Thu, Feb 13, 2014 at 10:55:10 -0700, David Gobbi wrote:<br>
>> Actually, the check should probably be done in the CMakeLists.txt:<br>
>><br>
>> if(${PYTHON_VERSION} VERSION_GREATER "2.6")<br>
>> vtk_add_test_python(TestImageJSONWriter.py NO_VALID)<br>
>> endif()<br>
><br>
> I don't see why. We can certainly *run* the test on older Python<br>
> versions, we just can't *validate* the test. In the absence of the<br>
> latter, I'd take segfault discovery of a simple run test :) .<br>
><br>
> --Ben<br>
> _______________________________________________<br>
> Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
><br>
> Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
><br>
> Follow this link to subscribe/unsubscribe:<br>
> <a href="http://www.vtk.org/mailman/listinfo/vtk-developers" target="_blank">http://www.vtk.org/mailman/listinfo/vtk-developers</a><br>
><br>
<br></blockquote></div>-- <br>___________________________________________<br>Andrew J. P. Maclean<br><br>___________________________________________
</div></div>