[Qgis-developer] Re: plug-in requirements

volkan kepoglu vkepoglu at gmail.com
Wed May 14 02:02:18 EDT 2008


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.

  # I have very weak info about mac os. I am assuming that in order to run
rpy in mac, pywin32 is also required, right?
  if os.name != "posix":
    try:
      import win32api
    except ImportError:
      return "Pywin32 2.1.0, python dependencies, is missing."

  #checking whether rpy is installed or not
  try:
    import rpy
  except ImportError:
    return "RPy 1.0.1, python dependencies, is missing."
  except:
    return "R 2.6.1 is missing."

On 5/14/08, Barry Rowlingson <b.rowlingson at lancaster.ac.uk> wrote:
>
> volkan kepoglu wrote:
>
> It would be nice to have a
> > standard method for
> >
> > > plugins to test and report requirements before they install themselves
> > >
> > properly. Checking for > things like rpy and specific R packages would
> > be
> > one of those things.
> >
>
> Here's some more thinking:
>
> plugins should define a "requirements" function in their __init__.py file
> which will look something like this:
>
> def requirements():
>  reqs = {
>    'qgis': ['>=0.9.0','<0.11.0'] ,
>    'qgis-plugins': [],
>    'python': '>=2.3.0',
>    'python-packages': ['rpy'],
>    'rpy-r': '>=2.4.0',
>    'r-packages': ['DCluster'],
>    'other': otherRequirements,
>    }
>  return reqs
>
>  - 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.
>
>  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.
>
>  For example, here's an otherRequirements function that tests if the
> os.name parameter is 'nt' or 'posix':
>
>  def otherRequirements(test=False):
>  status=(None,None)
>  if test:
>    import os
>    status=(False,'OS not valid')
>    if os.name=="nt" or os.name=="posix":
>      status=(True,'OS is valid')
>  return ('OS is nt or posix',status)
>
>  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).
>
>  Any other ideas?
>
> Barry
>



-- 
Regards,
Volkan Kepoglu
PhD Candidate
GGIT Department in METU,
Ankara, Turkey.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/qgis-developer/attachments/20080514/524330b1/attachment.html


More information about the Qgis-developer mailing list