- Timestamp:
- Jul 4, 2016 5:35:03 AM (9 years ago)
- Branches:
- ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc
- Children:
- e540cd2
- Parents:
- 481ff26 (diff), 80c5d46 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - Location:
- src/sas
- Files:
-
- 124 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sascalc/dataloader/readers/defaults.json
rb699768 r80c5d46 9 9 "-extension":".ses", 10 10 "-reader":"sesans_reader" 11 }, 12 { 13 "-extension":".h5", 14 "-reader":"cansas_reader_HDF5" 11 15 }, 12 16 { … … 37 41 "-extension":".nxs", 38 42 "-reader":"nexus_reader" 43 }, 44 { 45 "-extension":".pdh", 46 "-reader":"anton_paar_saxs_reader" 39 47 } 40 48 ] -
src/sas/sasgui/guiframe/data_panel.py
rd85c194 r1941e6a 13 13 import wx 14 14 from wx.build import build_options 15 15 16 # Check version 16 17 toks = str(wx.__version__).split('.') … … 291 292 Layout widgets related to buttons 292 293 """ 294 #Load Data Button 293 295 self.bt_add = wx.Button(self, wx.NewId(), "Load Data", 294 296 size=(BUTTON_WIDTH, -1)) 295 297 self.bt_add.SetToolTipString("Load data files") 296 298 wx.EVT_BUTTON(self, self.bt_add.GetId(), self._load_data) 299 300 #Delete Data Button 297 301 self.bt_remove = wx.Button(self, wx.NewId(), "Delete Data", 298 302 size=(BUTTON_WIDTH, -1)) 299 303 self.bt_remove.SetToolTipString("Delete data from the application") 300 304 wx.EVT_BUTTON(self, self.bt_remove.GetId(), self.on_remove) 305 306 #Send data to perspective button 301 307 self.bt_import = wx.Button(self, wx.NewId(), "Send To", 302 308 size=(BUTTON_WIDTH, -1)) 303 309 self.bt_import.SetToolTipString("Send Data set to active perspective") 304 310 wx.EVT_BUTTON(self, self.bt_import.GetId(), self.on_import) 311 312 #Choose perspective to be send data to combo box 305 313 self.perspective_cbox = wx.ComboBox(self, -1, 306 314 style=wx.CB_READONLY) … … 310 318 self._on_perspective_selection) 311 319 320 #Append data to current Graph Button 312 321 self.bt_append_plot = wx.Button(self, wx.NewId(), "Append Plot To", 313 322 size=(BUTTON_WIDTH, -1)) … … 316 325 wx.EVT_BUTTON(self, self.bt_append_plot.GetId(), self.on_append_plot) 317 326 327 #Create a new graph and send data to that new graph button 318 328 self.bt_plot = wx.Button(self, wx.NewId(), "New Plot", 319 329 size=(BUTTON_WIDTH, -1)) … … 321 331 wx.EVT_BUTTON(self, self.bt_plot.GetId(), self.on_plot) 322 332 333 #Freeze current theory button - becomes a data set and stays on graph 323 334 self.bt_freeze = wx.Button(self, wx.NewId(), "Freeze Theory", 324 335 size=(BUTTON_WIDTH, -1)) … … 329 340 wx.EVT_BUTTON(self, self.bt_freeze.GetId(), self.on_freeze) 330 341 342 #select plot to send to combo box (blank if no data) 331 343 if sys.platform == 'darwin': 332 344 self.cb_plotpanel = wx.ComboBox(self, -1, … … 337 349 wx.EVT_COMBOBOX(self.cb_plotpanel, -1, self._on_plot_selection) 338 350 self.cb_plotpanel.Disable() 351 352 #Help button 353 self.bt_help = wx.Button(self, wx.NewId(), "HELP", 354 size=(BUTTON_WIDTH, -1)) 355 self.bt_help.SetToolTipString("Help for the Data Explorer.") 356 wx.EVT_BUTTON(self,self.bt_help.GetId(), self.on_help) 339 357 340 358 self.sizer3.AddMany([(self.bt_add), … … 356 374 ((10, 10)), 357 375 (self.sizer4), 358 ((10, 40)),359 ( (10, 40))])376 ((10, 10)), 377 (self.bt_help, 0, wx.EXPAND|wx.RIGHT, 5)]) 360 378 361 379 self.sizer3.AddGrowableCol(1, 1) … … 1069 1087 return self.frame 1070 1088 1089 def on_help(self, event): 1090 """ 1091 Bring up the data manager Documentation whenever 1092 the HELP button is clicked. 1093 1094 Calls DocumentationWindow with the path of the location within the 1095 documentation tree (after /doc/ ....". Note that when using old 1096 versions of Wx (before 2.9) and thus not the release version of 1097 installers, the help comes up at the top level of the file as 1098 webbrowser does not pass anything past the # to the browser when it is 1099 running "file:///...." 1100 1101 :param evt: Triggers on clicking the help button 1102 """ 1103 1104 #import documentation window here to avoid circular imports 1105 #if put at top of file with rest of imports. 1106 from documentation_window import DocumentationWindow 1107 1108 _TreeLocation = "user/sasgui/guiframe/data_explorer_help.html" 1109 _doc_viewer = DocumentationWindow(self, -1, _TreeLocation, "", 1110 "Data Explorer Help") 1111 1071 1112 def on_close(self, event): 1072 1113 """ -
src/sas/sasgui/guiframe/report_dialog.py
rd85c194 r6dd6e32 15 15 FONT_VARIANT = 0 16 16 ISPDF = True 17 elif sys.platform == "darwin": 17 # For OSX and everything else 18 else: 18 19 _STATICBOX_WIDTH = 480 19 20 PANEL_WIDTH = 530 -
src/sas/sasgui/perspectives/calculator/model_editor.py
rbb841ef r9501661 578 578 else: 579 579 out_f.write(line + "\n") 580 elif line.count("P1 = make_class"):580 elif line.count("P1 = find_model"): 581 581 out_f.write(line % (name1) + "\n") 582 elif line.count("P2 = make_class"):582 elif line.count("P2 = find_model"): 583 583 out_f.write(line % (name2) + "\n") 584 584 … … 719 719 Do the layout for parameter related widgets 720 720 """ 721 param_txt = wx.StaticText(self, -1, 'Fit Parameters (if any): ') 722 723 param_tip = "#Set the parameters and initial values.\n" 721 param_txt = wx.StaticText(self, -1, 'Fit Parameters NOT requiring' + \ 722 ' polydispersity (if any): ') 723 724 param_tip = "#Set the parameters NOT requiring polydispersity " + \ 725 "and their initial values.\n" 724 726 param_tip += "#Example:\n" 725 727 param_tip += "A = 1\nB = 1" … … 736 738 737 739 # Parameters with polydispersity 738 pd_param_txt = wx.StaticText(self, -1, 'Fit Parameters requiring polydispersity (if any): ') 739 740 pd_param_tip = "#Set the parameters and initial values.\n" 740 pd_param_txt = wx.StaticText(self, -1, 'Fit Parameters requiring ' + \ 741 'polydispersity (if any): ') 742 743 pd_param_tip = "#Set the parameters requiring polydispersity and " + \ 744 "their initial values.\n" 741 745 pd_param_tip += "#Example:\n" 742 746 pd_param_tip += "C = 2\nD = 2" … … 803 807 self.bt_close.SetToolTipString("Close this panel.") 804 808 805 self.button_sizer.AddMany([(self.bt_apply, 0, 806 wx.LEFT, EDITOR_WIDTH * 0.8), 807 (self.bt_help, 0, 808 wx.LEFT,15), 809 (self.bt_close, 0, 810 wx.LEFT | wx.BOTTOM, 15)]) 809 self.button_sizer.AddMany([(self.bt_apply, 0,0), 810 (self.bt_help, 0, wx.LEFT | wx.BOTTOM,15), 811 (self.bt_close, 0, wx.LEFT | wx.RIGHT, 15)]) 811 812 812 813 def _do_layout(self): … … 835 836 wx.ALL | wx.EXPAND, 5), 836 837 (self.msg_sizer, 0, wx.EXPAND | wx.ALL, 5), 837 (self.button_sizer, 0, wx. EXPAND | wx.ALL, 5)])838 (self.button_sizer, 0, wx.ALIGN_RIGHT)]) 838 839 self.SetSizer(self.main_sizer) 839 840 self.SetAutoLayout(True) … … 1237 1238 ##import scipy? 1238 1239 #class Model(Model1DPlugin): 1239 # name = ""1240 # name = basename without extension of __file__ 1240 1241 # def __init__(self): 1241 1242 # Model1DPlugin.__init__(self, name=self.name) 1242 1243 # #set name same as file name 1243 # self.name = self.get_fname()1244 1244 # #self.params here 1245 1245 # self.description = "%s" … … 1303 1303 """ 1304 1304 TEST_TEMPLATE = """ 1305 def get_fname(self):1306 path = sys._getframe().f_code.co_filename1307 basename = os.path.basename(path)1308 name, _ = os.path.splitext(basename)1309 return name1310 1305 ###################################################################### 1311 1306 ## THIS IS FOR TEST. DO NOT MODIFY THE FOLLOWING LINES!!!!!!!!!!!!!!!! … … 1330 1325 import sys 1331 1326 import copy 1327 import collections 1332 1328 1333 1329 import numpy 1334 1330 1335 1331 from sas.sascalc.fit.pluginmodel import Model1DPlugin 1336 from sasmodels.sasview_model import make_class 1337 from sasmodels.core import load_model_info 1338 # User can change the name of the model (only with single functional model) 1339 #P1_model: 1340 #from %s import Model as P1 1341 1342 #P2_model: 1343 #from %s import Model as P2 1332 from sasmodels.sasview_model import find_model 1344 1333 1345 1334 class Model(Model1DPlugin): 1346 name = "" 1347 def __init__(self): 1335 name = os.path.splitext(os.path.basename(__file__))[0] 1336 is_multiplicity_model = False 1337 def __init__(self, multiplicity=1): 1348 1338 Model1DPlugin.__init__(self, name='') 1349 P1 = make_class('%s')1350 P2 = make_class('%s')1339 P1 = find_model('%s') 1340 P2 = find_model('%s') 1351 1341 p_model1 = P1() 1352 1342 p_model2 = P2() 1353 1343 ## Setting model name model description 1354 1344 self.description = '%s' 1355 self.name = self.get_fname()1356 1345 if self.name.rstrip().lstrip() == '': 1357 1346 self.name = self._get_name(p_model1.name, p_model2.name) … … 1362 1351 1363 1352 ## Define parameters 1364 self.params = {}1353 self.params = collections.OrderedDict() 1365 1354 1366 1355 ## Parameter details [units, min, max] … … 1391 1380 #list of parameter that can be fitted 1392 1381 self._set_fixed_params() 1382 1393 1383 ## parameters with orientation 1384 self.orientation_params = [] 1394 1385 for item in self.p_model1.orientation_params: 1395 1386 new_item = "p1_" + item … … 1402 1393 self.orientation_params.append(new_item) 1403 1394 ## magnetic params 1395 self.magnetic_params = [] 1404 1396 for item in self.p_model1.magnetic_params: 1405 1397 new_item = "p1_" + item … … 1459 1451 1460 1452 def _set_dispersion(self): 1453 self.dispersion = collections.OrderedDict() 1461 1454 ##set dispersion only from p_model 1462 1455 for name , value in self.p_model1.dispersion.iteritems(): … … 1574 1567 1575 1568 def _set_fixed_params(self): 1569 self.fixed = [] 1576 1570 for item in self.p_model1.fixed: 1577 1571 new_item = "p1" + item … … 1624 1618 self.description += description 1625 1619 1626 def get_fname(self):1627 path = sys._getframe().f_code.co_filename1628 basename = os.path.basename(path)1629 name, _ = os.path.splitext(basename)1630 return name1631 1632 1620 if __name__ == "__main__": 1633 1621 m1= Model() -
src/sas/sasgui/perspectives/calculator/pyconsole.py
r26d6e045 r7673ecd 27 27 """ 28 28 # try running the model 29 from sasmodels. core import load_model, call_kernel30 model = load_model(path)31 29 from sasmodels.sasview_model import load_custom_model 30 Model = load_custom_model(path) 31 model = Model() 32 32 q = np.array([0.01, 0.1]) 33 kernel = model.make_kernel([q]) 34 Iq = call_kernel(kernel, {}) 35 33 Iq = model.evalDistribution(q) 36 34 qx, qy = np.array([0.01, 0.01]), np.array([0.1, 0.1]) 37 kernel = model.make_kernel([qx, qy]) 38 Iqxy = call_kernel(kernel, {}) 35 Iqxy = model.evalDistribution([qx, qy]) 39 36 40 37 result = """ … … 56 53 except Exception: 57 54 import traceback 58 result, errmsg = None, traceback.format_exc( limit=2)55 result, errmsg = None, traceback.format_exc() 59 56 60 57 parts = ["Running model '%s'..." % os.path.basename(fname)] -
src/sas/sasgui/perspectives/fitting/basepage.py
rcb4ef58 r6ed67db 12 12 import json 13 13 import logging 14 import traceback 15 14 16 from collections import defaultdict 15 17 from wx.lib.scrolledpanel import ScrolledPanel 18 19 import sasmodels.sasview_model 16 20 from sas.sasgui.guiframe.panel_base import PanelBase 17 21 from sas.sasgui.guiframe.utils import format_number, check_float, IdList … … 198 202 self.state_change = False 199 203 ## save customized array 200 self.values = []201 self.weights = []204 self.values = {} # type: Dict[str, List[float, ...]] 205 self.weights = {} # type: Dict[str, List[float, ...]] 202 206 ## retrieve saved state 203 207 self.number_saved_state = 0 … … 852 856 angles.append(angle) 853 857 weights.append(weight) 854 except :858 except Exception: 855 859 # Skip non-data lines 856 logging.error( sys.exc_info()[1])860 logging.error(traceback.format_exc()) 857 861 return numpy.array(angles), numpy.array(weights) 858 862 except: … … 1393 1397 self.model._persistency_dict[key] = \ 1394 1398 [state.values, state.weights] 1395 except :1396 logging.error( sys.exc_info()[1])1399 except Exception: 1400 logging.error(traceback.format_exc()) 1397 1401 selection = self._find_polyfunc_selection(disp_model) 1398 1402 for list in self.fittable_param: … … 1410 1414 list[5].Disable() 1411 1415 list[6].Disable() 1412 except :1413 logging.error( sys.exc_info()[1])1416 except Exception: 1417 logging.error(traceback.format_exc()) 1414 1418 # For array, disable all fixed params 1415 1419 if selection == 1: … … 1419 1423 try: 1420 1424 item[2].Disable() 1421 except :1422 logging.error( sys.exc_info()[1])1425 except Exception: 1426 logging.error(traceback.format_exc()) 1423 1427 1424 1428 # Make sure the check box updated when all checked … … 1507 1511 is_modified = self._check_value_enter(self.parameters, 1508 1512 is_modified) 1509 except :1510 logging.error( sys.exc_info()[1])1513 except Exception: 1514 logging.error(traceback.format_exc()) 1511 1515 1512 1516 # Here we should check whether the boundaries have been modified. … … 1651 1655 try: 1652 1656 self.save_current_state() 1653 except :1654 logging.error( sys.exc_info()[1])1657 except Exception: 1658 logging.error(traceback.format_exc()) 1655 1659 1656 1660 return flag … … 1895 1899 if mod_cat == custom_model: 1896 1900 for model in self.model_list_box[mod_cat]: 1897 if 'sasmodels.sasview_model.' in str(model): 1898 str_m = model.id 1899 else: 1900 str_m = str(model).split(".")[0] 1901 #self.model_box.Append(str_m) 1901 str_m = model.id if hasattr(model, 'id') else model.name 1902 1902 m_list.append(self.model_dict[str_m]) 1903 1903 else: … … 1910 1910 # wx.PostEvent(self.parent.parent, 1911 1911 # StatusEvent(status=msg, info="error")) 1912 except :1913 msg = "%s\n" % (sys.exc_info()[1])1912 except Exception: 1913 msg = traceback.format_exc() 1914 1914 wx.PostEvent(self._manager.parent, 1915 1915 StatusEvent(status=msg, info="error")) … … 2474 2474 try: 2475 2475 self.model.set_dispersion(p, disp_model) 2476 except :2477 logging.error( sys.exc_info()[1])2476 except Exception: 2477 logging.error(traceback.format_exc()) 2478 2478 2479 2479 ## save state into … … 2588 2588 self._draw_model() 2589 2589 self.Refresh() 2590 except: 2590 except Exception: 2591 logging.error(traceback.format_exc()) 2591 2592 # Error msg 2592 2593 msg = "Error occurred:" … … 2680 2681 # Try to delete values and weight of the names array dic if exists 2681 2682 try: 2682 del self.values[name] 2683 del self.weights[name] 2684 # delete all other dic 2685 del self.state.values[name] 2686 del self.state.weights[name] 2687 del self.model._persistency_dict[name.split('.')[0]] 2688 del self.state.model._persistency_dict[name.split('.')[0]] 2689 except: 2690 logging.error(sys.exc_info()[1]) 2683 if name in self.values: 2684 del self.values[name] 2685 del self.weights[name] 2686 # delete all other dic 2687 del self.state.values[name] 2688 del self.state.weights[name] 2689 del self.model._persistency_dict[name.split('.')[0]] 2690 del self.state.model._persistency_dict[name.split('.')[0]] 2691 except Exception: 2692 logging.error(traceback.format_exc()) 2691 2693 2692 2694 def _lay_out(self): … … 2832 2834 graphs.append(item2.figure) 2833 2835 canvases.append(item2.canvas) 2834 except :2836 except Exception: 2835 2837 # Not for control panels 2836 logging.error( sys.exc_info()[1])2838 logging.error(traceback.format_exc()) 2837 2839 # Make sure the resduals plot goes to the last 2838 2840 if res_item != None: … … 3167 3169 if item[7].__class__.__name__ == 'ComboBox': 3168 3170 disfunc = str(item[7].GetValue()) 3169 except :3170 logging.error( sys.exc_info()[1])3171 except Exception: 3172 logging.error(traceback.format_exc()) 3171 3173 3172 3174 # 2D … … 3174 3176 try: 3175 3177 check = item[0].GetValue() 3176 except :3178 except Exception: 3177 3179 check = None 3178 3180 name = item[1] … … 3202 3204 for weight in self.weights[name]: 3203 3205 disfunc += ' ' + str(weight) 3204 except :3205 logging.error( sys.exc_info()[1])3206 except Exception: 3207 logging.error(traceback.format_exc()) 3206 3208 content += name + ',' + str(check) + ',' + value + disfunc + ':' 3207 3209 … … 3403 3405 weights=pd_weights) 3404 3406 is_array = True 3405 except :3406 logging.error( sys.exc_info()[1])3407 except Exception: 3408 logging.error(traceback.format_exc()) 3407 3409 if not is_array: 3408 3410 self._disp_obj_dict[name] = disp_model … … 3418 3420 self.state.weights] 3419 3421 3420 except :3421 logging.error( sys.exc_info()[1])3422 except Exception: 3423 logging.error(traceback.format_exc()) 3422 3424 print "Error in BasePage._paste_poly_help: %s" % \ 3423 3425 sys.exc_info()[1] -
src/sas/sasgui/perspectives/fitting/fitting.py
r934ce649 r7673ecd 273 273 wx.PostEvent(self.parent, evt) 274 274 break 275 except: 275 except Exception: 276 import traceback; traceback.print_exc() 276 277 msg = 'Delete Error: \nCould not delete the file; Check if in use.' 277 278 wx.MessageBox(msg, 'Error') … … 579 580 _, theory_state = item 580 581 self.fit_panel.set_model_state(theory_state) 581 except :582 except Exception: 582 583 msg = "Fitting: cannot deal with the theory received" 583 584 evt = StatusEvent(status=msg, info="error") -
src/sas/sasgui/perspectives/fitting/models.py
rcb4ef58 r7673ecd 2 2 Utilities to manage models 3 3 """ 4 import imp4 import traceback 5 5 import os 6 6 import sys … … 8 8 # Time is needed by the log method 9 9 import time 10 import datetime 10 11 import logging 11 12 import py_compile … … 20 21 21 22 PLUGIN_DIR = 'plugin_models' 23 PLUGIN_LOG = os.path.join(os.path.expanduser("~"), '.sasview', PLUGIN_DIR, 24 "plugins.log") 22 25 23 26 def get_model_python_path(): … … 28 31 29 32 30 def log(message):33 def plugin_log(message): 31 34 """ 32 35 Log a message in a file located in the user's home directory 33 36 """ 34 dir = os.path.join(os.path.expanduser("~"), '.sasview', PLUGIN_DIR) 35 out = open(os.path.join(dir, "plugins.log"), 'a') 36 out.write("%10g: %s\n" % (time.clock(), message)) 37 out = open(PLUGIN_LOG, 'a') 38 now = time.time() 39 stamp = datetime.datetime.fromtimestamp(now).strftime('%Y-%m-%d %H:%M:%S') 40 out.write("%s: %s\n" % (stamp, message)) 37 41 out.close() 38 42 … … 51 55 if not issubclass(model, Model1DPlugin): 52 56 msg = "Plugin %s must be of type Model1DPlugin \n" % str(name) 53 log(msg)57 plugin_log(msg) 54 58 return None 55 59 if model.__name__ != "Model": 56 60 msg = "Plugin %s class name must be Model \n" % str(name) 57 log(msg)61 plugin_log(msg) 58 62 return None 59 63 try: … … 63 67 str(sys.exc_type), 64 68 sys.exc_info()[1]) 65 log(msg)69 plugin_log(msg) 66 70 return None 67 71 … … 72 76 msg = "Plugin %s: error writing function \n\t :%s %s\n " % \ 73 77 (str(name), str(sys.exc_type), sys.exc_info()[1]) 74 log(msg)78 plugin_log(msg) 75 79 return None 76 80 else: 77 81 msg = "Plugin %s needs a method called function \n" % str(name) 78 log(msg)82 plugin_log(msg) 79 83 return None 80 84 return model … … 132 136 """ 133 137 def __nonzero__(self): 134 type, value, t raceback= sys.exc_info()138 type, value, tb = sys.exc_info() 135 139 if type is not None and issubclass(type, py_compile.PyCompileError): 136 140 print "Problem with", repr(value) 137 raise type, value, t raceback141 raise type, value, tb 138 142 return 1 139 143 … … 155 159 156 160 def _findModels(dir): 161 """ 162 Find custom models 163 """ 157 164 # List of plugin objects 158 plugins = {}159 165 dir = find_plugins_dir() 160 166 # Go through files in plug-in directory 161 #always recompile the folder plugin162 167 if not os.path.isdir(dir): 163 msg = "SasView couldn't locate Model plugin folder." 164 msg += """ "%s" does not exist""" % dir 168 msg = "SasView couldn't locate Model plugin folder %r." % dir 165 169 logging.warning(msg) 166 return plugins 167 else: 168 log("looking for models in: %s" % str(dir)) 169 compile_file(dir) 170 logging.info("plugin model dir: %s" % str(dir)) 171 try: 172 list = os.listdir(dir) 173 for item in list: 174 toks = os.path.splitext(os.path.basename(item)) 175 if toks[1] == '.py' and not toks[0] == '__init__': 176 name = toks[0] 177 path = [os.path.abspath(dir)] 178 file = None 179 try: 180 (file, path, info) = imp.find_module(name, path) 181 module = imp.load_module(name, file, item, info) 182 if hasattr(module, "Model"): 183 try: 184 if _check_plugin(module.Model, name) != None: 185 plugins[name] = module.Model 186 except: 187 msg = "Error accessing Model" 188 msg += "in %s\n %s %s\n" % (name, 189 str(sys.exc_type), 190 sys.exc_info()[1]) 191 log(msg) 192 else: 193 filename = os.path.join(dir, item) 194 plugins[name] = load_custom_model(filename) 195 196 except: 197 msg = "Error accessing Model" 198 msg += " in %s\n %s %s \n" % (name, 199 str(sys.exc_type), 200 sys.exc_info()[1]) 201 log(msg) 202 finally: 203 204 if not file == None: 205 file.close() 206 except: 207 # Don't deal with bad plug-in imports. Just skip. 208 msg = "Could not import model plugin: %s" % sys.exc_info()[1] 209 log(msg) 170 return {} 171 172 plugin_log("looking for models in: %s" % str(dir)) 173 #compile_file(dir) #always recompile the folder plugin 174 logging.info("plugin model dir: %s" % str(dir)) 175 176 plugins = {} 177 for filename in os.listdir(dir): 178 name, ext = os.path.splitext(filename) 179 if ext == '.py' and not name == '__init__': 180 path = os.path.abspath(os.path.join(dir, filename)) 181 try: 182 model = load_custom_model(path) 183 except Exception: 184 msg = traceback.format_exc() 185 msg += "\nwhile accessing model in %r" % path 186 plugin_log(msg) 187 logging.warning("Failed to load plugin %r. See %s for details" 188 % (path, PLUGIN_LOG)) 189 plugins[model.name] = model 210 190 211 191 return plugins -
src/sas/sasgui/perspectives/fitting/pagestate.py
rc10d9d6c r7673ecd 19 19 import logging 20 20 import numpy 21 import string21 import traceback 22 22 23 23 import xml.dom.minidom … … 473 473 try: 474 474 value = content[1] 475 except :476 logging.error( sys.exc_value)475 except Exception: 476 logging.error(traceback.format_exc()) 477 477 if name.count("State created"): 478 478 repo_time = "" + value … … 515 515 title = content[2] + " [" + repo_time + "]" 516 516 title_name = HEADER % title 517 except :518 logging.error( sys.exc_value)517 except Exception: 518 logging.error(traceback.format_exc()) 519 519 if name == "model name ": 520 520 try: … … 530 530 q_name = ("Q Range: " + q_range) 531 531 q_range = CENTRE % q_name 532 except :533 logging.error( sys.exc_value)532 except Exception: 533 logging.error(traceback.format_exc()) 534 534 paramval = "" 535 535 for lines in param_string.split(":"): … … 864 864 attribute = getattr(self, item[1]) 865 865 attribute[name] = com_name 866 except :867 logging.error( sys.exc_value)866 except Exception: 867 logging.error(traceback.format_exc()) 868 868 869 869 # get self.values and self.weights dic. if exists … … 880 880 val = float(line) 881 881 value_list.append(val) 882 except :882 except Exception: 883 883 # pass if line is empty (it happens) 884 logging.error( sys.exc_value)884 logging.error(traceback.format_exc()) 885 885 dic[name] = numpy.array(value_list) 886 886 setattr(self, item[1], dic) … … 1293 1293 if len(note_value) > 0: 1294 1294 data_info.notes.append(note_value) 1295 except :1295 except Exception: 1296 1296 err_mess = "cansas_reader.read: error processing entry notes\n %s" % sys.exc_value 1297 1297 self.errors.append(err_mess) … … 1315 1315 if len(detail_value) > 0: 1316 1316 data_info.sample.details.append(detail_value) 1317 except :1317 except Exception: 1318 1318 err_mess = "cansas_reader.read: error processing sample details\n %s" % sys.exc_value 1319 1319 self.errors.append(err_mess)
Note: See TracChangeset
for help on using the changeset viewer.