File tree 1 file changed +12
-3
lines changed
1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change 1
1
import os
2
2
import sys
3
3
import glob
4
+ import traceback
4
5
5
- from qgis .core import QgsApplication
6
+ from PyQt4 .QtCore import QCoreApplication
7
+ from qgis .core import QgsApplication , QgsMessageLog
6
8
7
9
def load_user_expressions (path ):
8
10
"""
@@ -14,9 +16,16 @@ def load_user_expressions(path):
14
16
for name in names :
15
17
if name == "__init__" :
16
18
continue
17
- # As user expression functions should be registed with qgsfunction
19
+ # As user expression functions should be registered with qgsfunction
18
20
# just importing the file is enough to get it to load the functions into QGIS
19
- __import__ ("expressions.{0}" .format (name ), locals (), globals ())
21
+ try :
22
+ __import__ ("expressions.{0}" .format (name ), locals (), globals ())
23
+ except :
24
+ error = traceback .format_exc ()
25
+ msgtitle = QCoreApplication .translate ("UserExpressions" , "User expressions" )
26
+ msg = QCoreApplication .translate ("UserExpressions" ,
27
+ "The user expression {0} is not valid" .format (name ))
28
+ QgsMessageLog .logMessage (msg + "\n " + error , msgtitle , QgsMessageLog .WARNING )
20
29
21
30
22
31
userpythonhome = os .path .join (QgsApplication .qgisSettingsDirPath (), "python" )
You can’t perform that action at this time.
0 commit comments