<div>Whether rpy is installed or not, can simple be checked with try and except commands. There maybe better way, but it is working in posix and nt. In nt, pywin32 also requires in order to run rpy. </div>
<div> </div>
<div> # I have very weak info about mac os. I am assuming that in order to run rpy in mac, pywin32 is also required, right?<br> if <a href="http://os.name">os.name</a> != "posix": </div>
<div> try:<br> import win32api<br> except ImportError:<br> return "Pywin32 2.1.0, python dependencies, is missing."<br> </div>
<div> #checking whether rpy is installed or not<br> try:<br> import rpy<br> except ImportError:<br> return "RPy 1.0.1, python dependencies, is missing."<br> except:<br> return "R 2.6.1 is missing."<br>
</div>
<div><span class="gmail_quote">On 5/14/08, <b class="gmail_sendername">Barry Rowlingson</b> <<a href="mailto:b.rowlingson@lancaster.ac.uk">b.rowlingson@lancaster.ac.uk</a>> wrote:</span>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid"><span class="q">volkan kepoglu wrote:<br><br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px; BORDER-LEFT: #ccc 1px solid">It would be nice to have a<br>standard method for<br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px; BORDER-LEFT: #ccc 1px solid">plugins to test and report requirements before they install themselves<br></blockquote>properly. Checking for > things like rpy and specific R packages would be<br>
one of those things.<br></blockquote><br></span>Here's some more thinking:<br><br>plugins should define a "requirements" function in their __init__.py file which will look something like this:<br><br>def requirements():<br>
reqs = {<br> 'qgis': ['>=0.9.0','<0.11.0'] ,<br> 'qgis-plugins': [],<br> 'python': '>=2.3.0',<br> 'python-packages': ['rpy'],<br> 'rpy-r': '>=2.4.0',<br>
'r-packages': ['DCluster'],<br> 'other': otherRequirements,<br> }<br> return reqs<br><br> - so basically it returns a dict of name:value pairs which the requirements testing system can get. Note that the system can display the requirements as text, and also test the requirements. Obviously the system needs a way of testing each dependency type.<br>
<br> The 'other' type is special, and its value is a function in the plugin that is called with one argument, 'test' and returns a list of two items. The first item is the test description, and the second item is the test status. Test status is a list of two items, the first is True or False for the test and the second is a note string. If the function is called with 'test=False', the status should be (None,None) and the test isn't performed.<br>
<br> For example, here's an otherRequirements function that tests if the <a onclick="return top.js.OpenExtLink(window,event,this)" href="http://os.name/" target="_blank">os.name</a> parameter is 'nt' or 'posix':<br>
<br> def otherRequirements(test=False):<br> status=(None,None)<br> if test:<br> import os<br> status=(False,'OS not valid')<br> if os.name=="nt" or os.name=="posix":<br> status=(True,'OS is valid')<br>
return ('OS is nt or posix',status)<br><br> I'm not sure that returning a dict() from requirements is correct, since it might be neessary to impose an ordering on the testing (no point testing for R packages if rpy isn't installed, for example).<br>
<br> Any other ideas?<br><span class="sg"><br>Barry<br></span></blockquote></div><br><br clear="all"><br>-- <br>Regards,<br>Volkan Kepoglu<br>PhD Candidate<br>GGIT Department in METU,<br>Ankara, Turkey.