|
25 | 25 | # Initialize Qt resources from file resources_rc.py
|
26 | 26 | import resources_rc
|
27 | 27 |
|
28 |
| -# Import required modules and if missing show the right name of them |
| 28 | +# Import required modules and if missing show the right module's name |
29 | 29 | req_mods = { "osgeo": "osgeo [python-gdal]" }
|
30 |
| -for k, v in req_mods.iteritems(): |
31 |
| - try: |
32 |
| - exec( "import %s" % k ) |
33 |
| - except ImportError, e: |
34 |
| - errorStr = str(e) |
35 |
| - if len(v) > 0: |
36 |
| - errorStr = errorStr.replace( k, v ) |
37 |
| - raise ImportError( errorStr ) |
38 |
| - |
39 |
| -# Set up current path, so that we know where to look for modules |
40 |
| -import os.path, sys |
41 |
| -currentPath = os.path.dirname( __file__ ) |
42 |
| -sys.path.append( os.path.abspath(os.path.dirname( __file__ ) + '/tools' ) ) |
43 |
| -import doBuildVRT, doContour, doRasterize, doPolygonize, doMerge, doSieve, doProximity, doNearBlack, doWarp, doGrid, doTranslate, doClipper |
44 |
| -import doInfo, doProjection, doOverview, doRgbPct, doPctRgb, doSettings, doAbout |
45 |
| - |
46 |
| -import GdalTools_utils as Utils |
| 30 | + |
| 31 | +try: |
| 32 | + # Set up current path, so that we know where to look for modules |
| 33 | + import os.path, sys |
| 34 | + currentPath = os.path.dirname( __file__ ) |
| 35 | + modulesPath = os.path.abspath( currentPath + '/tools' ) |
| 36 | + sys.path.append( modulesPath ) |
| 37 | + |
| 38 | + import GdalTools_utils as Utils |
| 39 | + |
| 40 | + import doBuildVRT, doContour, doRasterize, doPolygonize, doMerge, doSieve, doProximity, doNearBlack |
| 41 | + import doWarp, doGrid, doTranslate, doClipper, doInfo, doProjection, doOverview, doRgbPct, doPctRgb |
| 42 | + import doSettings, doAbout |
| 43 | + |
| 44 | + sys.path.remove( modulesPath ) |
| 45 | + |
| 46 | +except ImportError, e: |
| 47 | + error_str = str(e) |
| 48 | + error_mod = error_str.replace( "No module named ", "" ) |
| 49 | + if req_mods.has_key( error_mod ): |
| 50 | + error_str = error_str.replace( error_mod, req_mods[error_mod] ) |
| 51 | + raise ImportError( error_str ) |
| 52 | + |
47 | 53 |
|
48 | 54 | class GdalTools:
|
49 | 55 |
|
|
0 commit comments