Browse files

ENH: added _debug_info function.

* The _debug_info function can be used to check on dependencies, versions
  and if RSL is installed and linked to Py-ART.
  • Loading branch information...
1 parent 5585d6c commit 6db19273e46d6fc8bf9ec5f637a54394c7bd5e37 @jjhelmus jjhelmus committed Feb 12, 2014
View
5 doc/source/dev_reference/_debug_info.rst
@@ -0,0 +1,5 @@
+=================
+pyart._debug_info
+=================
+
+.. autofunction:: pyart._debug_info
View
3 doc/source/dev_reference/index.rst
@@ -16,10 +16,11 @@ Documentation is broken down by directory and module.
.. toctree::
:maxdepth: 2
-
+
io
config
correct
graph
map
testing
+ _debug_info
View
3 pyart/__init__.py
@@ -17,7 +17,8 @@
from . import config
# root level functions
-from config import load_config
+from .config import load_config
+from ._debug_info import _debug_info
# test function setup based on scikit-image test function
import imp as _imp
View
134 pyart/_debug_info.py
@@ -0,0 +1,134 @@
+"""
+Print out Py-ART version information.
+
+This file can also be run as a script to report on dependencies before a
+build: python pyart/_debug_info.py
+
+"""
+
+from __future__ import print_function
+import os
+import sys
+
+
+def _debug_info(stream=None):
+ """
+ Print out version and status information for debugging.
+
+ This file can be run as a script from the source directory to report on
+ dependecies before a build using: **python pyart/_debug_info.py**.
+
+ Parameters
+ ----------
+ stream : file-like object
+ Stream to print the information to, None prints to sys.stdout.
+
+ """
+ if stream is None:
+ stream = sys.stdout
+
+ # remove the current path from the import search path
+ # if this is not done ./io is found and not the std library io module.
+ current_dir = os.path.dirname(os.path.abspath(__file__))
+ if current_dir in sys.path:
+ sys.path.remove(current_dir)
+
+ try:
+ import pyart
+ pyart_version = pyart.__version__
+ except:
+ pyart_version = "MISSING"
+
+ try:
+ import platform
+ python_version = platform.python_version()
+ except:
+ python_version = "MISSING"
+
+ try:
+ import numpy
+ numpy_version = numpy.__version__
+ except:
+ numpy_version = "MISSING"
+
+ try:
+ import numpy
+ numpy_version = numpy.__version__
+ except:
+ numpy_version = "MISSING"
+
+ try:
+ import scipy
+ scipy_version = scipy.__version__
+ except:
+ scipy_version = "MISSING"
+
+ try:
+ import matplotlib
+ matplotlib_version = matplotlib.__version__
+ except:
+ matplotlib_version = "MISSING"
+
+ try:
+ import netCDF4
+ netCDF4_version = netCDF4.__version__
+ except:
+ netCDF4_version = "MISSING"
+
+ try:
+ rsl_version = pyart.io._rsl_interface._RSL_VERSION_STR
+ except:
+ rsl_version = "MISSING"
+
+ try:
+ import cylp
+ cylp_available = "Available"
+ except:
+ cylp_available = "MISSING"
+
+ try:
+ import glpk
+ glpk_version = "%i.%i" % (glpk.env.version)
+ except:
+ glpk_version = "MISSING"
+
+ try:
+ import cvxopt.info
+ cvxopt_version = cvxopt.info.version
+ except:
+ cvxopt_version = "MISSING"
+
+ try:
+ from mpl_toolkits import basemap
+ basemap_version = basemap.__version__
+ except:
+ basemap_version = "MISSING"
+
+ try:
+ import nose
+ nose_version = nose.__version__
+ except:
+ nose_version = "MISSING"
+
+ print("Py-ART version:", pyart_version, file=stream)
+ print("", file=stream)
+
+ print("---- Dependencies ----", file=stream)
+ print("Python version:", python_version, file=stream)
+ print("NumPy version:", numpy_version, file=stream)
+ print("SciPy version:", scipy_version, file=stream)
+ print("matplotlib version:", matplotlib_version, file=stream)
+ print("netCDF4 version:", netCDF4_version, file=stream)
+ print("", file=stream)
+
+ print("---- Optional dependencies ----", file=stream)
+ print("TRMM RSL version:", rsl_version, file=stream)
+ print("CyLP:", cylp_available, file=stream)
+ print("PyGLPK version:", glpk_version, file=stream)
+ print("CVXOPT version:", cvxopt_version, file=stream)
+ print("basemap version:", basemap_version, file=stream)
+ print("nose version:", nose_version, file=stream)
+
+if __name__ == "__main__":
+
+ _debug_info()
View
2 pyart/io/_rsl_h.pxd
@@ -2,6 +2,8 @@
cdef extern from "rsl.h":
+ cdef char[6] _RSL_VERSION_STR "RSL_VERSION_STR"
+
# data structures
ctypedef unsigned short Range
View
2,123 pyart/io/_rsl_interface.c
1,069 additions, 1,054 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
3 pyart/io/_rsl_interface.pyx
@@ -29,6 +29,9 @@ cimport numpy as np
from datetime import datetime
+_RSL_VERSION_STR = _rsl_h._RSL_VERSION_STR
+
+
cpdef copy_volume(_RslVolume volume):
"""
copy_volume(volume)
View
12 pyart/tests/test_debug_info.py
@@ -0,0 +1,12 @@
+""" Unit Tests for Py-ART's config.py module. """
+
+import pyart
+from StringIO import StringIO
+
+
+def test_debug_info():
+ # test to see that something is written when _debug_info is called
+ # we don't care what is written, just that something is.
+ buf = StringIO()
+ pyart._debug_info(buf)
+ assert buf.len > 0

0 comments on commit 6db1927

Please sign in to comment.