Ignore:
Timestamp:
04/12/12 11:59:57 (2 years ago)
Author:
Ales Erjavec <ales.erjavec@…>
Branch:
default
rebase_source:
abedf66d9eacd8b2c399653b893008d26742ebfe
Message:

Test for c45 library file presence before loading it.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Orange/OrangeWidgets/Classify/OWC45Tree.py

    r10770 r10785  
    66<priority>35</priority> 
    77""" 
     8import os 
     9 
     10from distutils import sysconfig 
     11 
    812from OWWidget import * 
    913import OWGUI 
     
    1418import Orange 
    1519 
    16 # Test if the c45.(so|pyd) can be found by orange.C45Learner 
    17 import orange 
    18 try: 
    19     orange.C45Learner() 
    20 except orange.KernelException, ex: 
    21     # I guess not 
    22     raise ImportError(ex.message) 
     20_Orange_dir = os.path.dirname(Orange.__file__) 
     21_SO = "c45%s" % sysconfig.get_config_var("SO") 
     22 
     23if os.path.exists(os.path.join(_Orange_dir, _SO)):               
     24    # Test if the c45.(so|pyd) can be loaded by orange.C45Learner 
     25    import orange 
     26    try: 
     27        orange.C45Learner() 
     28    except orange.KernelException, ex: 
     29        # I guess not 
     30        raise ImportError(ex.message) 
     31else: 
     32    raise ImportError("c45 is not found") 
    2333  
    2434class OWC45Tree(OWWidget): 
Note: See TracChangeset for help on using the changeset viewer.