Changeset 10224:c7b1721e5a2e in orange


Ignore:
Timestamp:
02/15/12 10:53:50 (2 years ago)
Author:
Janez Demšar <janez.demsar@…>
Branch:
default
Message:

Nicer warning messages in Orange.init

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Orange/__init__.py

    r10218 r10224  
    1010import warnings 
    1111 
     12alreadyWarned = False 
     13disabledMsg = "Some features will be disabled due to failing modules\n" 
    1214def _import(name): 
     15    global alreadyWarned 
    1316    try: 
    1417        __import__(name, globals(), locals(), [], -1) 
    15     except Exception: 
    16         warnings.warn("Some features are disabled, because Orange could not import: " + name, UserWarning, 2) 
     18    except Exception as err: 
     19        warnings.warn("%sImporting '%s' failed: %s" %  
     20            (disabledMsg if not alreadyWarned else "", name, err), 
     21            UserWarning, 2) 
     22        alreadyWarned = True 
    1723 
    1824_import("misc") 
Note: See TracChangeset for help on using the changeset viewer.