Author: bugman Date: Tue Oct 19 15:33:49 2010 New Revision: 11641 URL: http://svn.gna.org/viewcvs/relax?rev=11641&view=rev Log: Added checks and the RelaxNoModuleInstallError relax error to make sure that bmrblib is installed. Modified: branches/bmrb/generic_fns/bmrb.py branches/bmrb/relax_errors.py Modified: branches/bmrb/generic_fns/bmrb.py URL: http://svn.gna.org/viewcvs/relax/branches/bmrb/generic_fns/bmrb.py?rev=11641&r1=11640&r2=11641&view=diff ============================================================================== --- branches/bmrb/generic_fns/bmrb.py (original) +++ branches/bmrb/generic_fns/bmrb.py Tue Oct 19 15:33:49 2010 @@ -29,9 +29,10 @@ # relax module imports. from data import Relax_data_store; ds = Relax_data_store() from data.exp_info import ExpInfo +import dep_check from generic_fns import exp_info from info import Info_box -from relax_errors import RelaxError, RelaxFileError, RelaxFileOverwriteError, RelaxNoPipeError +from relax_errors import RelaxError, RelaxFileError, RelaxFileOverwriteError, RelaxNoModuleInstallError, RelaxNoPipeError from relax_io import get_file_path, mkdir_nofail from specific_fns.setup import get_specific_fn from version import version_full @@ -39,6 +40,10 @@ def display(version='3.1'): """Display the results in the BMRB NMR-STAR format.""" + + # Test if bmrblib is installed. + if not dep_check.bmrblib_module: + raise RelaxNoModuleInstallError('BMRB library', 'bmrblib') # Test if the current data pipe exists. if not ds.current_pipe: @@ -53,6 +58,10 @@ def read(file=None, directory=None, version='3.1'): """Read the contents of a BMRB NMR-STAR formatted file.""" + + # Test if bmrblib is installed. + if not dep_check.bmrblib_module: + raise RelaxNoModuleInstallError('BMRB library', 'bmrblib') # Test if the current data pipe exists. if not ds.current_pipe: @@ -78,6 +87,10 @@ def write(file=None, directory=None, version='3.1', force=False): """Create a BMRB NMR-STAR formatted file.""" + + # Test if bmrblib is installed. + if not dep_check.bmrblib_module: + raise RelaxNoModuleInstallError('BMRB library', 'bmrblib') # Test if the current data pipe exists. if not ds.current_pipe: Modified: branches/bmrb/relax_errors.py URL: http://svn.gna.org/viewcvs/relax/branches/bmrb/relax_errors.py?rev=11641&r1=11640&r2=11641&view=diff ============================================================================== --- branches/bmrb/relax_errors.py (original) +++ branches/bmrb/relax_errors.py Tue Oct 19 15:33:49 2010 @@ -162,6 +162,14 @@ self.text = text +# Module import errors. +####################### + +class RelaxNoModuleInstallError(BaseError): + def __init__(self, desc, name): + self.text = "The %s module '%s' cannot be found. Please check that it is installed." % (desc, name) + + # Fault. ########