- Timestamp:
- Apr 6, 2017 4:36:51 AM (8 years ago)
- Branches:
- master, 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, costrafo411, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- d01b55c
- Parents:
- d3bce8c (diff), 5e2f36c (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:
-
- 53 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sascalc/calculator/resolution_calculator.py
r9a5097c r9c0f3c17 15 15 import sys 16 16 import logging 17 18 logger = logging.getLogger(__name__) 17 19 18 20 #Plank's constant in cgs unit … … 1006 1008 detector_offset = self.sample2detector_distance[1] 1007 1009 except: 1008 logg ing.error(sys.exc_value)1010 logger.error(sys.exc_value) 1009 1011 1010 1012 # detector size in [no of pix_x,no of pix_y] … … 1093 1095 output.qy_data = qy_value 1094 1096 except: 1095 logg ing.error(sys.exc_value)1097 logger.error(sys.exc_value) 1096 1098 1097 1099 return output -
src/sas/sascalc/calculator/sas_gen.py
r9a5097c r9c0f3c17 12 12 import sys 13 13 import logging 14 15 logger = logging.getLogger(__name__) 14 16 15 17 MFACTOR_AM = 2.853E-12 … … 285 287 mask = (x_dir2 + y_dir2 + z_dir2) <= 1.0 286 288 except: 287 logg ing.error(sys.exc_value)289 logger.error(sys.exc_value) 288 290 self.output = MagSLD(self.pos_x[mask], self.pos_y[mask], 289 291 self.pos_z[mask], self.sld_n[mask], … … 394 396 except: 395 397 # Skip non-data lines 396 logg ing.error(sys.exc_value)398 logger.error(sys.exc_value) 397 399 #Reading Header; Segment count ignored 398 400 s_line = line.split(":", 1) … … 589 591 z_lines.append(z_line) 590 592 except: 591 logg ing.error(sys.exc_value)593 logger.error(sys.exc_value) 592 594 593 595 output = MagSLD(pos_x, pos_y, pos_z, sld_n, sld_mx, sld_my, sld_mz) … … 683 685 except: 684 686 # Skip non-data lines 685 logg ing.error(sys.exc_value)687 logger.error(sys.exc_value) 686 688 output = MagSLD(pos_x, pos_y, pos_z, sld_n, 687 689 sld_mx, sld_my, sld_mz) -
src/sas/sascalc/data_util/calcthread.py
r934ce649 r64ca561 8 8 import traceback 9 9 import sys 10 import logging 10 11 11 12 if sys.platform.count("darwin") > 0: … … 21 22 from time import clock 22 23 from time import sleep 24 25 logger = logging.getLogger(__name__) 23 26 24 27 … … 243 246 except Exception: 244 247 pass 245 import logging 246 logging.error(traceback.format_exc()) 248 logger.error(traceback.format_exc()) 247 249 #print 'CalcThread exception', 248 250 -
src/sas/sascalc/dataloader/loader.py
rb699768 r463e7ffc 32 32 from readers import cansas_reader 33 33 34 logger = logging.getLogger(__name__) 35 34 36 class Registry(ExtensionRegistry): 35 37 """ … … 99 101 msg = "DataLoader couldn't locate DataLoader plugin folder." 100 102 msg += """ "%s" does not exist""" % dir 101 logg ing.warning(msg)103 logger.warning(msg) 102 104 return readers_found 103 105 … … 117 119 msg = "Loader: Error importing " 118 120 msg += "%s\n %s" % (item, sys.exc_value) 119 logg ing.error(msg)121 logger.error(msg) 120 122 121 123 # Process zip files … … 139 141 msg = "Loader: Error importing" 140 142 msg += " %s\n %s" % (mfile, sys.exc_value) 141 logg ing.error(msg)143 logger.error(msg) 142 144 143 145 except: 144 146 msg = "Loader: Error importing " 145 147 msg += " %s\n %s" % (item, sys.exc_value) 146 logg ing.error(msg)148 logger.error(msg) 147 149 148 150 return readers_found … … 190 192 msg = "Loader: Error accessing" 191 193 msg += " Reader in %s\n %s" % (module.__name__, sys.exc_value) 192 logg ing.error(msg)194 logger.error(msg) 193 195 return reader_found 194 196 … … 223 225 msg = "Loader: Error accessing Reader " 224 226 msg += "in %s\n %s" % (loader.__name__, sys.exc_value) 225 logg ing.error(msg)227 logger.error(msg) 226 228 return reader_found 227 229 … … 268 270 msg = "Loader: Error accessing Reader" 269 271 msg += " in %s\n %s" % (module.__name__, sys.exc_value) 270 logg ing.error(msg)272 logger.error(msg) 271 273 return reader_found 272 274 -
src/sas/sascalc/dataloader/readers/associations.py
re5c09cf r463e7ffc 18 18 import logging 19 19 import json 20 21 logger = logging.getLogger(__name__) 20 22 21 23 FILE_NAME = 'defaults.json' … … 67 69 msg = "read_associations: skipping association" 68 70 msg += " for %s\n %s" % (ext.lower(), sys.exc_value) 69 logg ing.error(msg)71 logger.error(msg) 70 72 else: 71 73 print "Could not find reader association settings\n %s [%s]" % (__file__, os.getcwd()) … … 81 83 :param registry_function: function to be called to register each reader 82 84 """ 83 logg ing.info("register_readers is now obsolete: use read_associations()")85 logger.info("register_readers is now obsolete: use read_associations()") 84 86 import abs_reader 85 87 import ascii_reader -
src/sas/sascalc/dataloader/readers/cansas_reader.py
r747334d r3c903ea 33 33 import xml.dom.minidom 34 34 from xml.dom.minidom import parseString 35 36 logger = logging.getLogger(__name__) 35 37 36 38 PREPROCESS = "xmlpreprocess" … … 1475 1477 self.errors.add(err_mess) 1476 1478 if optional: 1477 logg ing.info(err_mess)1479 logger.info(err_mess) 1478 1480 else: 1479 1481 raise ValueError, err_mess … … 1484 1486 self.errors.add(err_mess) 1485 1487 if optional: 1486 logg ing.info(err_mess)1488 logger.info(err_mess) 1487 1489 else: 1488 1490 raise ValueError, err_mess -
src/sas/sascalc/dataloader/readers/danse_reader.py
r9a5097c r9c0f3c17 19 19 from sas.sascalc.dataloader.data_info import Data2D, Detector 20 20 from sas.sascalc.dataloader.manipulations import reader2D_converter 21 22 logger = logging.getLogger(__name__) 21 23 22 24 # Look for unit converter … … 142 144 error.append(err) 143 145 except: 144 logg ing.info("Skipping line:%s,%s" %(data_str,146 logger.info("Skipping line:%s,%s" %(data_str, 145 147 sys.exc_value)) 146 148 … … 196 198 msg = "Skipping entry (v1.0):%s,%s" % (str(data[i_pt]), 197 199 sys.exc_value) 198 logg ing.info(msg)200 logger.info(msg) 199 201 200 202 # Get bin number … … 271 273 raise ValueError, msg 272 274 else: 273 logg ing.info("Danse_reader Reading %s \n" % filename)275 logger.info("Danse_reader Reading %s \n" % filename) 274 276 275 277 # Store loading process information -
src/sas/sascalc/dataloader/readers/tiff_reader.py
r9a5097c r9c0f3c17 16 16 from sas.sascalc.dataloader.data_info import Data2D 17 17 from sas.sascalc.dataloader.manipulations import reader2D_converter 18 18 19 logger = logging.getLogger(__name__) 20 19 21 class Reader: 20 22 """ … … 76 78 value = float(val) 77 79 except: 78 logg ing.error("tiff_reader: had to skip a non-float point")80 logger.error("tiff_reader: had to skip a non-float point") 79 81 continue 80 82 -
src/sas/sascalc/dataloader/readers/xml_reader.py
ra235f715 r463e7ffc 18 18 from lxml import etree 19 19 from lxml.builder import E 20 21 logger = logging.getLogger(__name__) 20 22 21 23 PARSER = etree.ETCompatXMLParser(remove_comments=True, remove_pis=False) … … 71 73 self.xmlroot = self.xmldoc.getroot() 72 74 except etree.XMLSyntaxError as xml_error: 73 logg ing.info(xml_error)75 logger.info(xml_error) 74 76 except Exception: 75 77 self.xml = None … … 88 90 self.xmlroot = etree.fromstring(tag_soup) 89 91 except etree.XMLSyntaxError as xml_error: 90 logg ing.info(xml_error)92 logger.info(xml_error) 91 93 except Exception: 92 94 self.xml = None … … 102 104 self.schemadoc = etree.parse(self.schema, parser=PARSER) 103 105 except etree.XMLSyntaxError as xml_error: 104 logg ing.info(xml_error)106 logger.info(xml_error) 105 107 except Exception: 106 108 self.schema = None -
src/sas/sascalc/pr/invertor.py
r9a5097c r9c0f3c17 18 18 from scipy import optimize 19 19 from sas.sascalc.pr.core.pr_inversion import Cinvertor 20 21 logger = logging.getLogger(__name__) 20 22 21 23 def help(): … … 495 497 # We were not able to estimate the errors 496 498 # Return an empty error matrix 497 logg ing.error(sys.exc_value)499 logger.error(sys.exc_value) 498 500 499 501 # Keep a copy of the last output … … 541 543 # number of terms 542 544 best_alpha, _, _ = self.estimate_alpha(self.nfunc) 543 logg ing.warning("Invertor.estimate_numterms: %s" % sys.exc_value)545 logger.warning("Invertor.estimate_numterms: %s" % sys.exc_value) 544 546 return self.nfunc, best_alpha, "Could not estimate number of terms" 545 547 -
src/sas/sascalc/pr/num_term.py
r9a5097c r9c0f3c17 5 5 import logging 6 6 from sas.sascalc.pr.invertor import Invertor 7 8 logger = logging.getLogger(__name__) 7 9 8 10 class NTermEstimator(object): … … 180 182 data_err = np.append(data_err, err) 181 183 except: 182 logg ing.error(sys.exc_value)184 logger.error(sys.exc_value) 183 185 184 186 return data_x, data_y, data_err -
src/sas/sasgui/guiframe/CategoryInstaller.py
rddbac66 r463e7ffc 16 16 17 17 USER_FILE = 'categories.json' 18 19 logger = logging.getLogger(__name__) 18 20 19 21 class CategoryInstaller: … … 114 116 @staticmethod 115 117 def get_default_file(): 116 logg ing.warning("CategoryInstaller.get_default_file is deprecated.")118 logger.warning("CategoryInstaller.get_default_file is deprecated.") 117 119 118 120 @staticmethod … … 153 155 model_enabled_dict.pop(model_name) 154 156 except: 155 logg ing.error("CategoryInstaller: %s", sys.exc_value)157 logger.error("CategoryInstaller: %s", sys.exc_value) 156 158 else: 157 159 add_list.remove(model_name) -
src/sas/sasgui/guiframe/CategoryManager.py
r212bfc2 r463e7ffc 20 20 from sas.sasgui.guiframe.CategoryInstaller import CategoryInstaller 21 21 IS_MAC = (sys.platform == 'darwin') 22 23 logger = logging.getLogger(__name__) 22 24 23 25 """ Notes … … 373 375 self.master_category_dict = json.load(f) 374 376 except IOError: 375 logg ing.error('Problem reading in category file.')377 logger.error('Problem reading in category file.') 376 378 377 379 self._regenerate_model_dict() -
src/sas/sasgui/guiframe/config.py
r1779e72 r64ca561 7 7 import sas.sasview 8 8 import logging 9 10 11 logger = logging.getLogger(__name__) 9 12 10 13 # Version of the application … … 57 60 58 61 icon_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "images")) 59 logg ing.info("icon path: %s" % icon_path)62 logger.info("icon path: %s" % icon_path) 60 63 media_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "media")) 61 64 test_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "test")) -
src/sas/sasgui/guiframe/data_manager.py
r2ffe241 r463e7ffc 25 25 from sas.sasgui.guiframe.dataFitting import Data2D 26 26 import time 27 28 logger = logging.getLogger(__name__) 27 29 28 30 class DataManager(object): … … 136 138 msg = "Data manager already stores %s" % str(data.name) 137 139 msg += "" 138 logg ing.info(msg)140 logger.info(msg) 139 141 data_state = self.stored_data[id] 140 142 data_state.data = data -
src/sas/sasgui/guiframe/documentation_window.py
rd85c194 r463e7ffc 20 20 import urllib 21 21 import sys 22 23 logger = logging.getLogger(__name__) 22 24 23 25 SPHINX_DOC_ENV = "SASVIEW_DOC_PATH" … … 71 73 72 74 if not os.path.exists(file_path): 73 logg ing.error("Could not find Sphinx documentation at %s \75 logger.error("Could not find Sphinx documentation at %s \ 74 76 -- has it been built?", file_path) 75 77 elif WX_SUPPORTS_HTML2: … … 79 81 self.Show() 80 82 else: 81 logg ing.error("No html2 support, popping up a web browser")83 logger.error("No html2 support, popping up a web browser") 82 84 #For cases that do not build against current version dependency 83 85 # Wx 3.0 we provide a webbrowser call - this is particularly for -
src/sas/sasgui/guiframe/gui_manager.py
r73cbeec r64ca561 48 48 from matplotlib import _pylab_helpers 49 49 50 logger = logging.getLogger(__name__) 51 50 52 warnings.simplefilter("ignore") 51 52 53 53 54 def get_app_dir(): … … 64 65 if os.path.isfile(os.path.join(app_path, "custom_config.py")): 65 66 app_path = os.path.abspath(app_path) 66 logg ing.info("Using application path: %s", app_path)67 logger.info("Using application path: %s", app_path) 67 68 return app_path 68 69 69 70 # Next, try the current working directory 70 71 if os.path.isfile(os.path.join(os.getcwd(), "custom_config.py")): 71 logg ing.info("Using application path: %s", os.getcwd())72 logger.info("Using application path: %s", os.getcwd()) 72 73 return os.path.abspath(os.getcwd()) 73 74 … … 76 77 # clean all these module variables and put them into a config class 77 78 # that can be passed by sasview.py. 78 logg ing.info(sys.executable)79 logg ing.info(str(sys.argv))79 logger.info(sys.executable) 80 logger.info(str(sys.argv)) 80 81 from sas import sasview as sasview 81 82 app_path = os.path.dirname(sasview.__file__) 82 logg ing.info("Using application path: %s", app_path)83 logger.info("Using application path: %s", app_path) 83 84 return app_path 84 85 … … 104 105 config_module = imp.load_module(file, fObj, path_config, descr) 105 106 except: 106 logg ing.error("Error loading %s/%s: %s" % (path, file, sys.exc_value))107 logger.error("Error loading %s/%s: %s" % (path, file, sys.exc_value)) 107 108 finally: 108 109 if fObj is not None: 109 110 fObj.close() 110 logg ing.info("GuiManager loaded %s/%s" % (path, file))111 logger.info("GuiManager loaded %s/%s" % (path, file)) 111 112 return config_module 112 113 … … 125 126 # Didn't find local config, load the default 126 127 import sas.sasgui.guiframe.config as config 127 logg ing.info("using default local_config")128 logger.info("using default local_config") 128 129 else: 129 logg ing.info("found local_config in %s" % os.getcwd())130 logger.info("found local_config in %s" % os.getcwd()) 130 131 else: 131 logg ing.info("found local_config in %s" % PATH_APP)132 logger.info("found local_config in %s" % PATH_APP) 132 133 133 134 from sas.sasgui.guiframe.customdir import SetupCustom … … 138 139 if custom_config is None: 139 140 msgConfig = "Custom_config file was not imported" 140 logg ing.info(msgConfig)141 logger.info(msgConfig) 141 142 else: 142 logg ing.info("using custom_config in %s" % os.getcwd())143 logger.info("using custom_config in %s" % os.getcwd()) 143 144 else: 144 logg ing.info("using custom_config from %s" % c_conf_dir)145 logger.info("using custom_config from %s" % c_conf_dir) 145 146 146 147 # read some constants from config … … 374 375 frame.SetIcon(icon) 375 376 except: 376 logg ing.error("ViewerFrame.put_icon: could not set icon")377 logger.error("ViewerFrame.put_icon: could not set icon") 377 378 378 379 def get_client_size(self): … … 803 804 str(self._input_file)) 804 805 msg += str(sys.exc_value) + '\n' 805 logg ing.error(msg)806 logger.error(msg) 806 807 if self._data_panel is not None and len(self.plugins) > 0: 807 808 self._data_panel.fill_cbox_analysis(self.plugins) … … 869 870 if plugin.__class__ == item.__class__: 870 871 msg = "Plugin %s already loaded" % plugin.sub_menu 871 logg ing.info(msg)872 logger.info(msg) 872 873 is_loaded = True 873 874 if not is_loaded: 874 875 self.plugins.append(plugin) 875 876 msg = "Plugin %s appended" % plugin.sub_menu 876 logg ing.info(msg)877 logger.info(msg) 877 878 878 879 def _get_local_plugins(self): … … 894 895 msg = "ViewerFrame._get_local_plugins:" 895 896 msg += "cannot import dataloader plugin.\n %s" % sys.exc_value 896 logg ing.error(msg)897 logger.error(msg) 897 898 if style2 == GUIFRAME.PLOTTING_ON: 898 899 try: … … 904 905 msg = "ViewerFrame._get_local_plugins:" 905 906 msg += "cannot import plotting plugin.\n %s" % sys.exc_value 906 logg ing.error(msg)907 logger.error(msg) 907 908 908 909 return plugins … … 949 950 plugins.append(module.Plugin()) 950 951 msg = "Found plug-in: %s" % module.PLUGIN_ID 951 logg ing.info(msg)952 logger.info(msg) 952 953 except: 953 954 msg = "Error accessing PluginPanel" … … 956 957 except: 957 958 msg = "ViewerFrame._find_plugins: %s" % sys.exc_value 958 logg ing.error(msg)959 logger.error(msg) 959 960 finally: 960 961 if file is not None: … … 963 964 # Should raise and catch at a higher level and 964 965 # display error on status bar 965 logg ing.error(sys.exc_value)966 logger.error(sys.exc_value) 966 967 967 968 return plugins … … 1385 1386 1386 1387 if config._do_aboutbox: 1387 logg ing.info("Doing help menu")1388 logger.info("Doing help menu") 1388 1389 wx_id = wx.NewId() 1389 1390 self._help_menu.Append(wx_id, '&About', 'Software information') … … 1746 1747 del self.panels[ID] 1747 1748 else: 1748 logg ing.error("delete_panel: No such plot id as %s" % ID)1749 logger.error("delete_panel: No such plot id as %s" % ID) 1749 1750 1750 1751 def create_gui_data(self, data, path=None): … … 1763 1764 log_msg += "load: %s\n" % str(basename) 1764 1765 log_msg += "Try Data opening...." 1765 logg ing.error(log_msg)1766 logger.error(log_msg) 1766 1767 return 1767 1768 … … 1843 1844 log_msg += "load: %s\n" % str(path) 1844 1845 log_msg += "Try File opening ...." 1845 logg ing.error(log_msg)1846 logger.error(log_msg) 1846 1847 return 1847 1848 log_msg = '' … … 1849 1850 error_message = "" 1850 1851 try: 1851 logg ing.info("Loading Data...:\n" + str(path) + "\n")1852 logger.info("Loading Data...:\n" + str(path) + "\n") 1852 1853 temp = self.loader.load(path) 1853 1854 if temp.__class__.__name__ == "list": … … 1864 1865 error_message += " Data from cmd:\n %s\n" % str(path) 1865 1866 error_message += str(sys.exc_value) + "\n" 1866 logg ing.error(error_message)1867 logger.error(error_message) 1867 1868 1868 1869 def load_folder(self, path): … … 1885 1886 error_message += " Data folder from cmd:\n %s\n" % str(path) 1886 1887 error_message += str(sys.exc_value) + "\n" 1887 logg ing.error(error_message)1888 logger.error(error_message) 1888 1889 1889 1890 def _on_open_state_application(self, event): … … 2044 2045 msg += "and model selected. " 2045 2046 msg += "No project was saved to %s" % (str(path)) 2046 logg ing.warning(msg)2047 logger.warning(msg) 2047 2048 wx.PostEvent(self, StatusEvent(status=msg, info="error")) 2048 2049 except Exception: … … 2111 2112 #IF SAS_OPENCL is set, settings are stored in the custom config file 2112 2113 self._write_opencl_config_file() 2113 logg ing.info(" --- SasView session was closed --- \n")2114 logger.info(" --- SasView session was closed --- \n") 2114 2115 wx.Exit() 2115 2116 sys.exit() … … 2140 2141 new_config_file.close() 2141 2142 else: 2142 logg ing.info("Failed to save OPENCL settings in custom config file")2143 logger.info("Failed to save OPENCL settings in custom config file") 2143 2144 2144 2145 … … 2157 2158 # 2158 2159 content = response.read().strip() 2159 logg ing.info("Connected to www.sasview.org. Latest version: %s"2160 logger.info("Connected to www.sasview.org. Latest version: %s" 2160 2161 % (content)) 2161 2162 version_info = json.loads(content) 2162 2163 except: 2163 logg ing.info("Failed to connect to www.sasview.org")2164 logger.info("Failed to connect to www.sasview.org") 2164 2165 self._process_version(version_info, standalone=event is None) 2165 2166 … … 2201 2202 msg = "guiframe: could not get latest application" 2202 2203 msg += " version number\n %s" % sys.exc_value 2203 logg ing.error(msg)2204 logger.error(msg) 2204 2205 if not standalone: 2205 2206 msg = "Could not connect to the application server." … … 2248 2249 dialog.Show(True) 2249 2250 except: 2250 logg ing.error("Error in _onTutorial: %s" % sys.exc_value)2251 logger.error("Error in _onTutorial: %s" % sys.exc_value) 2251 2252 try: 2252 2253 # Try an alternate method 2253 logg ing.error(2254 logger.error( 2254 2255 "Could not open the tutorial pdf, trying xhtml2pdf") 2255 2256 from xhtml2pdf import pisa 2256 2257 pisa.startViewer(path) 2257 2258 except: 2258 logg ing.error(2259 logger.error( 2259 2260 "Could not open the tutorial pdf with xhtml2pdf") 2260 2261 msg = "This feature requires 'PDF Viewer'\n" … … 2267 2268 try: 2268 2269 # Try an alternate method 2269 logg ing.error(2270 logger.error( 2270 2271 "Could not open the tutorial pdf, trying xhtml2pdf") 2271 2272 from xhtml2pdf import pisa 2272 2273 pisa.startViewer(path) 2273 2274 except: 2274 logg ing.error(2275 logger.error( 2275 2276 "Could not open the tutorial pdf with xhtml2pdf") 2276 2277 msg = "This feature requires the Preview application\n" … … 2411 2412 else: 2412 2413 msg = "Guiframe does not have a current perspective" 2413 logg ing.info(msg)2414 logger.info(msg) 2414 2415 2415 2416 def set_theory(self, state_id, theory_id=None): … … 2422 2423 except: 2423 2424 msg = "Guiframe set_theory: \n" + str(sys.exc_value) 2424 logg ing.info(msg)2425 logger.info(msg) 2425 2426 wx.PostEvent(self, StatusEvent(status=msg, info="error")) 2426 2427 else: 2427 2428 msg = "Guiframe does not have a current perspective" 2428 logg ing.info(msg)2429 logger.info(msg) 2429 2430 2430 2431 def plot_data(self, state_id, data_id=None, … … 2508 2509 action='remove')) 2509 2510 except: 2510 logg ing.error(sys.exc_value)2511 logger.error(sys.exc_value) 2511 2512 2512 2513 def save_data1d(self, data, fname): … … 3306 3307 msg = "%s Could not load " % str(APPLICATION_NAME) 3307 3308 msg += "input file from command line.\n" 3308 logg ing.error(msg)3309 logger.error(msg) 3309 3310 # Display a splash screen on top of the frame. 3310 3311 try: … … 3320 3321 msg = "Cannot display splash screen\n" 3321 3322 msg += str(sys.exc_value) 3322 logg ing.error(msg)3323 logger.error(msg) 3323 3324 self.frame.Show() 3324 3325 … … 3375 3376 os.remove(file_path) 3376 3377 except: 3377 logg ing.error("gui_manager.clean_plugin_models:\n %s"3378 logger.error("gui_manager.clean_plugin_models:\n %s" 3378 3379 % sys.exc_value) 3379 3380 -
src/sas/sasgui/guiframe/gui_statusbar.py
r3a22ce7 r463e7ffc 12 12 from sas.sasgui.guiframe.gui_style import GUIFRAME_ICON 13 13 14 logger = logging.getLogger(__name__) 15 14 16 # Number of fields on the status bar 15 17 NB_FIELDS = 4 … … 71 73 icon_type = event.info.lower() 72 74 if icon_type == "warning": 73 logg ing.warning(status)75 logger.warning(status) 74 76 color = (0, 0, 255) # blue 75 77 icon_bmp = wx.ArtProvider.GetBitmap(wx.ART_WARNING, 76 78 wx.ART_TOOLBAR) 77 79 if icon_type == "error": 78 logg ing.error(status)80 logger.error(status) 79 81 color = (255, 0, 0) # red 80 82 icon_bmp = wx.ArtProvider.GetBitmap(wx.ART_ERROR, -
src/sas/sasgui/guiframe/local_perspectives/data_loader/data_loader.py
ra674d0b r463e7ffc 7 7 import wx 8 8 import logging 9 10 logger = logging.getLogger(__name__) 9 11 10 12 from sas.sascalc.dataloader.loader import Loader … … 160 162 message += "\tError: {0}\n".format(error_data) 161 163 else: 162 logg ing.error("Loader returned an invalid object:\n %s" % str(item))164 logger.error("Loader returned an invalid object:\n %s" % str(item)) 163 165 data_error = True 164 166 … … 182 184 log_msg += "Please try to open that file from \"open project\"" 183 185 log_msg += "or \"open analysis\" menu." 184 logg ing.info(log_msg)186 logger.info(log_msg) 185 187 file_errors[basename] = [log_msg] 186 188 continue … … 212 214 213 215 except: 214 logg ing.error(sys.exc_value)216 logger.error(sys.exc_value) 215 217 216 218 error_message = "The Data file you selected could not be loaded.\n" -
src/sas/sasgui/guiframe/local_perspectives/plotting/Plotter1D.py
r9a5097c r9c0f3c17 24 24 from appearanceDialog import appearanceDialog 25 25 from graphAppearance import graphAppearance 26 27 logger = logging.getLogger(__name__) 26 28 27 29 DEFAULT_QMAX = 0.05 … … 242 244 wx.PostEvent(self.parent, StatusEvent(status=position)) 243 245 except: 244 logg ing.error(sys.exc_value)246 logger.error(sys.exc_value) 245 247 if not event.leftdown: 246 248 # text event … … 255 257 self.canvas.draw() 256 258 except: 257 logg ing.error(sys.exc_value)259 logger.error(sys.exc_value) 258 260 event.Skip() 259 261 return … … 409 411 self.q_ctrl[vl_ind].SetValue(str(pos_x)) 410 412 except: 411 logg ing.error(sys.exc_value)413 logger.error(sys.exc_value) 412 414 413 415 def set_resizing(self, resizing=False): -
src/sas/sasgui/guiframe/local_perspectives/plotting/Plotter2D.py
r9a5097c r9c0f3c17 30 30 from graphAppearance import graphAppearance 31 31 (InternalEvent, EVT_INTERNAL) = wx.lib.newevent.NewEvent() 32 33 logger = logging.getLogger(__name__) 32 34 33 35 DEFAULT_QMAX = 0.05 … … 432 434 except: 433 435 msg = "Add Text: Error. Check your property values..." 434 logg ing.error(msg)436 logger.error(msg) 435 437 if self.parent != None: 436 438 wx.PostEvent(self.parent, StatusEvent(status=msg)) -
src/sas/sasgui/guiframe/local_perspectives/plotting/binder.py
rd85c194 r463e7ffc 4 4 import logging 5 5 import sys 6 7 logger = logging.getLogger(__name__) 6 8 7 9 class Selection(object): … … 70 72 canvas.mpl_disconnect(canvas.scroll_pick_id) 71 73 except: 72 logg ing.error(sys.exc_value)74 logger.error(sys.exc_value) 73 75 self.canvas = canvas 74 76 self.figure = figure -
src/sas/sasgui/guiframe/proxy.py
rd85c194 r463e7ffc 6 6 import logging 7 7 import re 8 9 10 logger = logging.getLogger(__name__) 8 11 9 12 ''' … … 71 74 proxy_url_list = [] 72 75 for this_pac_url in pac_urls_list: 73 logg ing.debug('Trying pac file (%s)...' % this_pac_url)76 logger.debug('Trying pac file (%s)...' % this_pac_url) 74 77 try: 75 78 response = urllib2.urlopen( 76 79 this_pac_url, timeout=self.timeout) 77 logg ing.debug('Succeeded (%s)...' % this_pac_url)80 logger.debug('Succeeded (%s)...' % this_pac_url) 78 81 except Exception: 79 logg ing.debug('Failled (%s)...' % this_pac_url)82 logger.debug('Failled (%s)...' % this_pac_url) 80 83 continue 81 84 pacStr = response.read() … … 120 123 response = None 121 124 try: 122 logg ing.debug("Trying Direct connection to %s..."%self.url)125 logger.debug("Trying Direct connection to %s..."%self.url) 123 126 response = urllib2.urlopen(req, timeout=self.timeout) 124 127 except Exception, e: 125 logg ing.debug("Failed!")126 logg ing.debug(e)128 logger.debug("Failed!") 129 logger.debug(e) 127 130 try: 128 logg ing.debug("Trying to use system proxy if it exists...")131 logger.debug("Trying to use system proxy if it exists...") 129 132 self._set_proxy() 130 133 response = urllib2.urlopen(req, timeout=self.timeout) 131 134 except Exception, e: 132 logg ing.debug("Failed!")133 logg ing.debug(e)135 logger.debug("Failed!") 136 logger.debug(e) 134 137 pac_urls = self._get_addresses_of_proxy_pac() 135 138 proxy_urls = self._parse_proxy_pac(pac_urls) 136 139 for proxy in proxy_urls: 137 140 try: 138 logg ing.debug("Trying to use the proxy %s found in proxy.pac configuration"%proxy)141 logger.debug("Trying to use the proxy %s found in proxy.pac configuration"%proxy) 139 142 self._set_proxy(proxy) 140 143 response = urllib2.urlopen(req, timeout=self.timeout) 141 144 except Exception, e: 142 logg ing.debug("Failed!")143 logg ing.debug(e)145 logger.debug("Failed!") 146 logger.debug(e) 144 147 if response is not None: 145 logg ing.debug("The connection to %s was successful."%self.url)148 logger.debug("The connection to %s was successful."%self.url) 146 149 else: 147 logg ing.warning("Connection to %s failed..."%self.url)150 logger.warning("Connection to %s failed..."%self.url) 148 151 return response 149 152 -
src/sas/sasgui/guiframe/report_dialog.py
r6dd6e32 r463e7ffc 7 7 import sys 8 8 import wx.html as html 9 10 logger = logging.getLogger(__name__) 9 11 10 12 ISPDF = False … … 135 137 return pisaStatus.err 136 138 except: 137 logg ing.error("Error creating pdf: %s" % sys.exc_value)139 logger.error("Error creating pdf: %s" % sys.exc_value) 138 140 return False 139 141 -
src/sas/sasgui/perspectives/calculator/calculator.py
ra0c1e1d r463e7ffc 28 28 import logging 29 29 30 logger = logging.getLogger(__name__) 31 30 32 class Plugin(PluginBase): 31 33 """ … … 36 38 PluginBase.__init__(self, name="Calculator") 37 39 # Log startup 38 logg ing.info("Calculator plug-in started")40 logger.info("Calculator plug-in started") 39 41 self.sub_menu = "Tool" 40 42 self.data_edit_frame = None -
src/sas/sasgui/perspectives/calculator/gen_scatter_panel.py
r9a5097c r9c0f3c17 38 38 from sas.sasgui.guiframe.events import NewPlotEvent 39 39 from sas.sasgui.guiframe.documentation_window import DocumentationWindow 40 41 logger = logging.getLogger(__name__) 40 42 41 43 _BOX_WIDTH = 76 … … 699 701 ax = Axes3D(panel.figure) 700 702 except: 701 logg ing.error("PlotPanel could not import Axes3D")703 logger.error("PlotPanel could not import Axes3D") 702 704 raise 703 705 panel.dimension = 3 … … 1344 1346 msg = "OMF Panel: %s" % sys.exc_value 1345 1347 infor = 'Error' 1346 #logg ing.error(msg)1348 #logger.error(msg) 1347 1349 if self.parent.parent != None: 1348 1350 # inform msg to wx … … 1696 1698 msg = "%s cannot write %s\n" % ('Generic Scattering', str(path)) 1697 1699 infor = 'Error' 1698 #logg ing.error(msg)1700 #logger.error(msg) 1699 1701 if self.parent.parent != None: 1700 1702 # inform msg to wx -
src/sas/sasgui/perspectives/calculator/model_editor.py
rddbac66 r463e7ffc 32 32 from sas.sasgui.guiframe.documentation_window import DocumentationWindow 33 33 from .pyconsole import show_model_output, check_model 34 35 logger = logging.getLogger(__name__) 34 36 35 37 … … 985 987 exec "from %s import Model" % name 986 988 except: 987 logg ing.error(sys.exc_value)989 logger.error(sys.exc_value) 988 990 989 991 # Prepare the messagebox -
src/sas/sasgui/perspectives/calculator/resolution_calculator_panel.py
ra0c1e1d r463e7ffc 34 34 from sas.sasgui.perspectives.calculator import calculator_widgets as widget 35 35 from sas.sasgui.guiframe.documentation_window import DocumentationWindow 36 37 logger = logging.getLogger(__name__) 36 38 37 39 _BOX_WIDTH = 100 … … 1098 1100 new_string.append(value) 1099 1101 except: 1100 logg ing.error(sys.exc_value)1102 logger.error(sys.exc_value) 1101 1103 1102 1104 return new_string … … 1140 1142 return out 1141 1143 except: 1142 logg ing.error(sys.exc_value)1144 logger.error(sys.exc_value) 1143 1145 1144 1146 def _on_xy_coordinate(self, event=None): … … 1318 1320 except: 1319 1321 # Skip non-data lines 1320 logg ing.error(sys.exc_value)1322 logger.error(sys.exc_value) 1321 1323 1322 1324 return [wavelength, intensity] -
src/sas/sasgui/perspectives/corfunc/corfunc.py
r1dc8ec9 r463e7ffc 20 20 from plot_labels import * 21 21 22 logger = logging.getLogger(__name__) 22 23 23 24 class Plugin(PluginBase): … … 29 30 def __init__(self): 30 31 PluginBase.__init__(self, name="Correlation Function") 31 logg ing.info("Correlation function plug-in started")32 logger.info("Correlation function plug-in started") 32 33 self._always_active = True 33 34 self.state_reader = Reader(self.set_state) -
src/sas/sasgui/perspectives/corfunc/corfunc_state.py
rae9b8bf r463e7ffc 13 13 from sas.sascalc.dataloader.loader import Loader 14 14 15 logger = logging.getLogger(__name__) 16 15 17 CORNODE_NAME = 'corfunc' 16 18 CANSAS_NS = 'cansas1d/1.0' … … 216 218 msg = ("CorfuncState.fromXML: Could not read timestamp", 217 219 "\n{}").format(sys.exc_value) 218 logg ing.error(msg)220 logger.error(msg) 219 221 220 222 # Parse current state … … 360 362 msg = "XML document does not contain CorfuncState information\n{}" 361 363 msg.format(sys.exc_value) 362 logg ing.info(msg)364 logger.info(msg) 363 365 return state -
src/sas/sasgui/perspectives/file_converter/file_converter.py
rba65aff r463e7ffc 6 6 from sas.sasgui.guiframe.plugin_base import PluginBase 7 7 from sas.sasgui.perspectives.file_converter.converter_panel import ConverterWindow 8 9 logger = logging.getLogger(__name__) 8 10 9 11 class Plugin(PluginBase): … … 15 17 def __init__(self): 16 18 PluginBase.__init__(self, name="File Converter") 17 logg ing.info("File Converter plug-in started")19 logger.info("File Converter plug-in started") 18 20 self._sub_menu = "Tool" 19 21 self.converter_frame = None -
src/sas/sasgui/perspectives/fitting/basepage.py
red2276f r9c0f3c17 34 34 from sas.sasgui.guiframe.documentation_window import DocumentationWindow 35 35 36 logger = logging.getLogger(__name__) 36 37 37 38 (PageInfoEvent, EVT_PAGE_INFO) = wx.lib.newevent.NewEvent() … … 782 783 except Exception: 783 784 # Skip non-data lines 784 logg ing.error(traceback.format_exc())785 logger.error(traceback.format_exc()) 785 786 return np.array(angles), np.array(weights) 786 787 except: … … 1304 1305 [state.values, state.weights] 1305 1306 except Exception: 1306 logg ing.error(traceback.format_exc())1307 logger.error(traceback.format_exc()) 1307 1308 selection = self._find_polyfunc_selection(disp_model) 1308 1309 for list in self.fittable_param: … … 1321 1322 list[6].Disable() 1322 1323 except Exception: 1323 logg ing.error(traceback.format_exc())1324 logger.error(traceback.format_exc()) 1324 1325 # For array, disable all fixed params 1325 1326 if selection == 1: … … 1330 1331 item[2].Disable() 1331 1332 except Exception: 1332 logg ing.error(traceback.format_exc())1333 logger.error(traceback.format_exc()) 1333 1334 1334 1335 def _selectDlg(self): … … 1451 1452 self.Refresh() 1452 1453 1453 # logg ing.info("is_modified flag set to %g",is_modified)1454 # logger.info("is_modified flag set to %g",is_modified) 1454 1455 return is_modified 1455 1456 … … 1556 1557 self.save_current_state() 1557 1558 except Exception: 1558 logg ing.error(traceback.format_exc())1559 logger.error(traceback.format_exc()) 1559 1560 1560 1561 return flag, is_modified … … 2371 2372 self.model.set_dispersion(p, disp_model) 2372 2373 except Exception: 2373 logg ing.error(traceback.format_exc())2374 logger.error(traceback.format_exc()) 2374 2375 2375 2376 # save state into … … 2486 2487 self.Refresh() 2487 2488 except Exception: 2488 logg ing.error(traceback.format_exc())2489 logger.error(traceback.format_exc()) 2489 2490 # Error msg 2490 2491 msg = "Error occurred:" … … 2587 2588 del self.state.model._persistency_dict[name.split('.')[0]] 2588 2589 except Exception: 2589 logg ing.error(traceback.format_exc())2590 logger.error(traceback.format_exc()) 2590 2591 2591 2592 def _lay_out(self): … … 2719 2720 except Exception: 2720 2721 # Not for control panels 2721 logg ing.error(traceback.format_exc())2722 logger.error(traceback.format_exc()) 2722 2723 # Make sure the resduals plot goes to the last 2723 2724 if res_item is not None: … … 3052 3053 disfunc = str(item[7].GetValue()) 3053 3054 except Exception: 3054 logg ing.error(traceback.format_exc())3055 logger.error(traceback.format_exc()) 3055 3056 3056 3057 # 2D … … 3095 3096 disfunc += ' ' + str(weight) 3096 3097 except Exception: 3097 logg ing.error(traceback.format_exc())3098 logger.error(traceback.format_exc()) 3098 3099 content += name + ',' + str(check) + ',' + value + disfunc + ',' + \ 3099 3100 bound_lo + ',' + bound_hi + ':' … … 3366 3367 3367 3368 except Exception: 3368 logg ing.error(traceback.format_exc())3369 logger.error(traceback.format_exc()) 3369 3370 print "Error in BasePage._paste_poly_help: %s" % \ 3370 3371 sys.exc_info()[1] -
src/sas/sasgui/perspectives/fitting/fitting.py
red2276f r9c0f3c17 48 48 49 49 from . import models 50 51 logger = logging.getLogger(__name__) 50 52 51 53 MAX_NBR_DATA = 4 … … 119 121 self.page_finder = {} 120 122 # Log startup 121 logg ing.info("Fitting plug-in started")123 logger.info("Fitting plug-in started") 122 124 self.batch_capable = self.get_batch_capable() 123 125 … … 346 348 page.formfactorbox.SetLabel(current_val) 347 349 except: 348 logg ing.error("update_custom_combo: %s", sys.exc_value)350 logger.error("update_custom_combo: %s", sys.exc_value) 349 351 350 352 def set_edit_menu(self, owner): … … 586 588 msg = "Fitting: cannot deal with the theory received" 587 589 evt = StatusEvent(status=msg, info="error") 588 logg ing.error("set_theory " + msg + "\n" + str(sys.exc_value))590 logger.error("set_theory " + msg + "\n" + str(sys.exc_value)) 589 591 wx.PostEvent(self.parent, evt) 590 592 … … 1796 1798 Handle exception from calculator by posting it as an error. 1797 1799 """ 1798 logg ing.error("".join(traceback.format_exception(etype, value, tb)))1800 logger.error("".join(traceback.format_exception(etype, value, tb))) 1799 1801 msg = traceback.format_exception(etype, value, tb, limit=1) 1800 1802 evt = StatusEvent(status="".join(msg), type="stop", info="error") -
src/sas/sasgui/perspectives/fitting/models.py
r11b094f r463e7ffc 18 18 from sas.sasgui.guiframe.CategoryInstaller import CategoryInstaller 19 19 from sasmodels.sasview_model import load_custom_model, load_standard_models 20 21 logger = logging.getLogger(__name__) 20 22 21 23 … … 168 170 if not os.path.isdir(dir): 169 171 msg = "SasView couldn't locate Model plugin folder %r." % dir 170 logg ing.warning(msg)172 logger.warning(msg) 171 173 return {} 172 174 173 175 plugin_log("looking for models in: %s" % str(dir)) 174 176 #compile_file(dir) #always recompile the folder plugin 175 logg ing.info("plugin model dir: %s" % str(dir))177 logger.info("plugin model dir: %s" % str(dir)) 176 178 177 179 plugins = {} … … 188 190 msg += "\nwhile accessing model in %r" % path 189 191 plugin_log(msg) 190 logg ing.warning("Failed to load plugin %r. See %s for details"192 logger.warning("Failed to load plugin %r. See %s for details" 191 193 % (path, PLUGIN_LOG)) 192 194 … … 261 263 if self.is_changed(): 262 264 return _findModels(dir) 263 logg ing.info("plugin model : %s" % str(temp))265 logger.info("plugin model : %s" % str(temp)) 264 266 return temp 265 267 -
src/sas/sasgui/perspectives/fitting/pagestate.py
red2276f r9c0f3c17 33 33 from sas.sascalc.dataloader.data_info import Data2D, Collimation, Detector 34 34 from sas.sascalc.dataloader.data_info import Process, Aperture 35 36 logger = logging.getLogger(__name__) 35 37 36 38 # Information to read/write state as xml … … 395 397 msg = "Save state does not have enough information to load" 396 398 msg += " the all of the data." 397 logg ing.warning(msg=msg)399 logger.warning(msg=msg) 398 400 else: 399 401 self.formfactorcombobox = FIRST_FORM[self.categorycombobox] … … 620 622 except Exception: 621 623 msg = "Report string expected 'name: value' but got %r" % line 622 logg ing.error(msg)624 logger.error(msg) 623 625 if name.count("State created"): 624 626 repo_time = "" + value … … 662 664 except Exception: 663 665 msg = "While parsing 'data: ...'\n" 664 logg ing.error(msg + traceback.format_exc())666 logger.error(msg + traceback.format_exc()) 665 667 if name == "model name ": 666 668 try: … … 678 680 except Exception: 679 681 msg = "While parsing 'Plotting Range: ...'\n" 680 logg ing.error(msg + traceback.format_exc())682 logger.error(msg + traceback.format_exc()) 681 683 paramval = "" 682 684 for lines in param_string.split(":"): … … 1037 1039 msg = "PageState.fromXML: Could not" 1038 1040 msg += " read timestamp\n %s" % sys.exc_value 1039 logg ing.error(msg)1041 logger.error(msg) 1040 1042 1041 1043 if entry is not None: … … 1077 1079 except Exception: 1078 1080 base = "unable to load distribution %r for %s" 1079 logg ing.error(base % (value, parameter))1081 logger.error(base % (value, parameter)) 1080 1082 continue 1081 1083 _disp_obj_dict = getattr(self, varname) … … 1099 1101 msg = ("Error reading %r from %s %s\n" 1100 1102 % (line, tagname, name)) 1101 logg ing.error(msg + traceback.format_exc())1103 logger.error(msg + traceback.format_exc()) 1102 1104 dic[name] = np.array(value_list) 1103 1105 setattr(self, varname, dic) … … 1207 1209 1208 1210 except: 1209 logg ing.info("XML document does not contain fitting information.\n"1211 logger.info("XML document does not contain fitting information.\n" 1210 1212 + traceback.format_exc()) 1211 1213 -
src/sas/sasgui/perspectives/invariant/invariant.py
rc10d9d6c r463e7ffc 27 27 from sas.sasgui.guiframe.plugin_base import PluginBase 28 28 29 logger = logging.getLogger(__name__) 30 29 31 class Plugin(PluginBase): 30 32 """ … … 46 48 47 49 # Log startup 48 logg ing.info("Invariant plug-in started")50 logger.info("Invariant plug-in started") 49 51 50 52 def get_data(self): … … 280 282 281 283 except: 282 logg ing.error("invariant.set_state: %s" % sys.exc_value)284 logger.error("invariant.set_state: %s" % sys.exc_value) 283 285 284 286 def on_set_state_helper(self, event=None): -
src/sas/sasgui/perspectives/invariant/invariant_panel.py
r18b7ecb9 r463e7ffc 24 24 from sas.sasgui.guiframe.panel_base import PanelBase 25 25 from sas.sasgui.guiframe.documentation_window import DocumentationWindow 26 27 logger = logging.getLogger(__name__) 26 28 27 29 # The minimum q-value to be used when extrapolating … … 460 462 self._manager.plot_theory(name="Low-Q extrapolation") 461 463 except: 462 logg ing.error(sys.exc_value)464 logger.error(sys.exc_value) 463 465 464 466 def get_high_qstar(self, inv, high_q=False): … … 494 496 self._manager.plot_theory(name="High-Q extrapolation") 495 497 except: 496 logg ing.error(sys.exc_value)498 logger.error(sys.exc_value) 497 499 498 500 def get_qstar(self, inv): … … 845 847 attr.SetValue(value) 846 848 except: 847 logg ing.error("Invariant state: %s", sys.exc_value)849 logger.error("Invariant state: %s", sys.exc_value) 848 850 849 851 def get_bookmark_by_num(self, num=None): … … 862 864 _, _, current_state, comp_state = self.state.bookmark_list[int(num)] 863 865 except: 864 logg ing.error(sys.exc_value)866 logger.error(sys.exc_value) 865 867 raise ValueError, "No such bookmark exists" 866 868 … … 957 959 self.state.clone_state() 958 960 except: 959 logg ing.error(sys.exc_value)961 logger.error(sys.exc_value) 960 962 961 963 self._set_undo_flag(True) … … 1001 1003 del self.state.state_list[str(i)] 1002 1004 except: 1003 logg ing.error(sys.exc_value)1005 logger.error(sys.exc_value) 1004 1006 # Enable the undo button if it was not 1005 1007 self._set_undo_flag(True) … … 1066 1068 del self.state.state_list[str(i)] 1067 1069 except: 1068 logg ing.error(sys.exc_value)1070 logger.error(sys.exc_value) 1069 1071 1070 1072 # try to add new state of the text changes in the state_list … … 1081 1083 self.state.state_list[str(self.state.state_num)] = self.state.clone_state() 1082 1084 except: 1083 logg ing.error(sys.exc_value)1085 logger.error(sys.exc_value) 1084 1086 1085 1087 self._set_undo_flag(True) … … 1103 1105 self.state.state_list[str(self.state.state_num)] = self.state.clone_state() 1104 1106 except: 1105 logg ing.error(sys.exc_value)1107 logger.error(sys.exc_value) 1106 1108 1107 1109 def _get_input_list(self): -
src/sas/sasgui/perspectives/invariant/invariant_state.py
rdb5294e r463e7ffc 16 16 from sas.sasgui.guiframe.gui_style import GUIFRAME_ID 17 17 from sas.sasgui.guiframe.dataFitting import Data1D 18 19 logger = logging.getLogger(__name__) 18 20 19 21 INVNODE_NAME = 'invariant' … … 381 383 msg = "InvariantSate.fromXML: Could not read" 382 384 msg += " timestamp\n %s" % sys.exc_value 383 logg ing.error(msg)385 logger.error(msg) 384 386 385 387 # Parse bookmarks … … 694 696 msg = "XML document does not contain invariant" 695 697 msg += " information.\n %s" % sys.exc_value 696 logg ing.info(msg)698 logger.info(msg) 697 699 return state 698 700 -
src/sas/sasgui/perspectives/invariant/report_dialog.py
rd85c194 r463e7ffc 20 20 21 21 from sas.sasgui.guiframe.report_dialog import BaseReportDialog 22 23 logger = logging.getLogger(__name__) 22 24 23 25 class ReportDialog(BaseReportDialog): … … 92 94 except: 93 95 # DO not open 94 logg ing.error("Could not open file: %s" % sys.exc_value)96 logger.error("Could not open file: %s" % sys.exc_value) 95 97 # delete image file 96 98 os.remove(pic_fname) -
src/sas/sasgui/perspectives/pr/explore_dialog.py
r9a5097c r9c0f3c17 22 22 import logging 23 23 import sys 24 25 logger = logging.getLogger(__name__) 24 26 25 27 # Avoid Matplotlib complaining about the lack of legend on the plot … … 284 286 msg += "a change in the " % str(output_type) 285 287 msg += "ExploreDialog code." 286 logg ing.error(msg)288 logger.error(msg) 287 289 288 290 def __do_layout(self): … … 418 420 msg = "ExploreDialog: inversion failed " 419 421 msg += "for D_max=%s\n%s" % (str(d), sys.exc_value) 420 logg ing.error(msg)422 logger.error(msg) 421 423 422 424 self.results = results -
src/sas/sasgui/perspectives/pr/inversion_panel.py
r18b7ecb9 r463e7ffc 17 17 from pr_widgets import OutputTextCtrl 18 18 from sas.sasgui.guiframe.documentation_window import DocumentationWindow 19 20 logger = logging.getLogger(__name__) 19 21 20 22 if sys.platform.count("win32") > 0: … … 710 712 self.alpha_ctl.SetValue(alpha) 711 713 except ValueError: 712 logg ing.error("InversionControl._on_accept_alpha got a value that was not a number: %s" % alpha )714 logger.error("InversionControl._on_accept_alpha got a value that was not a number: %s" % alpha ) 713 715 except: 714 716 # No estimate or bad estimate, either do nothing 715 logg ing.error("InversionControl._on_accept_alpha: %s" % sys.exc_value)717 logger.error("InversionControl._on_accept_alpha: %s" % sys.exc_value) 716 718 717 719 def _on_accept_nterms(self, evt): … … 726 728 self.nfunc_ctl.SetValue(nterms) 727 729 except ValueError: 728 logg ing.error("InversionControl._on_accept_nterms got a value that was not a number: %s" % nterms )730 logger.error("InversionControl._on_accept_nterms got a value that was not a number: %s" % nterms ) 729 731 except: 730 732 # No estimate or bad estimate, either do nothing 731 logg ing.error("InversionControl._on_accept_nterms: %s" % sys.exc_value)733 logger.error("InversionControl._on_accept_nterms: %s" % sys.exc_value) 732 734 733 735 def clear_panel(self): … … 947 949 except: 948 950 msg = "InversionControl._change_file: %s" % sys.exc_value 949 logg ing.error(msg)951 logger.error(msg) 950 952 951 953 def on_help(self, event): -
src/sas/sasgui/perspectives/pr/inversion_state.py
rd85c194 r463e7ffc 22 22 from sas.sascalc.dataloader.readers.cansas_reader import get_content 23 23 24 logger = logging.getLogger(__name__) 25 24 26 PRNODE_NAME = 'pr_inversion' 25 27 CANSAS_NS = "cansas1d/1.0" … … 250 252 msg = "InversionState.fromXML: Could not read " 251 253 msg += "timestamp\n %s" % sys.exc_value 252 logg ing.error(msg)254 logger.error(msg) 253 255 254 256 # Parse inversion inputs … … 306 308 err_msg += "%d %d" % (len(self.coefficients), 307 309 self.nfunc) 308 logg ing.error(err_msg)310 logger.error(err_msg) 309 311 self.coefficients = None 310 312 … … 343 345 err_msg += " covariance matrix: " 344 346 err_msg += "%d %d" % (len(self.covariance), self.nfunc) 345 logg ing.error(err_msg)347 logger.error(err_msg) 346 348 self.covariance = None 347 349 … … 430 432 msg = "XML document does not contain P(r) " 431 433 msg += "information.\n %s" % sys.exc_value 432 logg ing.info(msg)434 logger.info(msg) 433 435 434 436 return state -
src/sas/sasgui/perspectives/pr/pr.py
r9a5097c r9c0f3c17 34 34 from pr_widgets import load_error 35 35 from sas.sasgui.guiframe.plugin_base import PluginBase 36 37 logger = logging.getLogger(__name__) 36 38 37 39 … … 113 115 114 116 # Log startup 115 logg ing.info("Pr(r) plug-in started")117 logger.info("Pr(r) plug-in started") 116 118 117 119 def delete_data(self, data_id): … … 181 183 self.control_panel.set_state(state) 182 184 except: 183 logg ing.error("prview.set_state: %s" % sys.exc_value)185 logger.error("prview.set_state: %s" % sys.exc_value) 184 186 185 187 … … 508 510 data_err = np.append(data_err, err) 509 511 except: 510 logg ing.error(sys.exc_value)512 logger.error(sys.exc_value) 511 513 512 514 if not scale == None: … … 559 561 data_err = np.append(data_err, err) 560 562 except: 561 logg ing.error(sys.exc_value)563 logger.error(sys.exc_value) 562 564 elif line.find("The 6 columns") >= 0: 563 565 data_started = True … … 1201 1203 dataset = panel.plots[panel.graph.selected_plottable].name 1202 1204 else: 1203 logg ing.info("Prview Error: No data is available")1205 logger.info("Prview Error: No data is available") 1204 1206 return 1205 1207 … … 1211 1213 except: 1212 1214 self.control_panel.alpha = self.alpha 1213 logg ing.info("Prview :Alpha Not estimate yet")1215 logger.info("Prview :Alpha Not estimate yet") 1214 1216 try: 1215 1217 estimate = int(self.control_panel.nterms_estimate) … … 1217 1219 except: 1218 1220 self.control_panel.nfunc = self.nfunc 1219 logg ing.info("Prview : ntemrs Not estimate yet")1221 logger.info("Prview : ntemrs Not estimate yet") 1220 1222 1221 1223 self.current_plottable = panel.plots[panel.graph.selected_plottable] -
src/sas/sasgui/perspectives/simulation/simulation.py
r9a5097c r9c0f3c17 24 24 from sas.sascalc.data_util.calcthread import CalcThread 25 25 from sas.guicomm.events import NewPlotEvent, StatusEvent 26 27 logger = logging.getLogger(__name__) 26 28 27 29 class Calc1D(CalcThread): … … 93 95 self._default_save_location = os.getcwd() 94 96 # Log startup 95 logg ing.info("Simulation plug-in started")97 logger.info("Simulation plug-in started") 96 98 97 99 def get_panels(self, parent): -
src/sas/sasgui/plottools/PlotPanel.py
r9a5097c r9c0f3c17 33 33 from sas.sasgui.guiframe.events import StatusEvent 34 34 from .toolbar import NavigationToolBar, PlotPrintout, bind 35 36 logger = logging.getLogger(__name__) 35 37 36 38 def show_tree(obj, d=0): … … 1506 1508 from mpl_toolkits.mplot3d import Axes3D 1507 1509 except: 1508 logg ing.error("PlotPanel could not import Axes3D")1510 logger.error("PlotPanel could not import Axes3D") 1509 1511 self.subplot.figure.clear() 1510 1512 ax = Axes3D(self.subplot.figure) -
src/sas/sasgui/plottools/binder.py
rd7bb526 r463e7ffc 4 4 import sys 5 5 import logging 6 7 logger = logging.getLogger(__name__) 6 8 7 9 class Selection(object): … … 121 123 for cid in self._connections: self.canvas.mpl_disconnect(cid) 122 124 except: 123 logg ing.error("Error disconnection canvas: %s" % sys.exc_value)125 logger.error("Error disconnection canvas: %s" % sys.exc_value) 124 126 self._connections = [] 125 127 -
src/sas/sasgui/plottools/canvas.py
rd7bb526 r463e7ffc 11 11 from matplotlib.backends.backend_wx import RendererWx 12 12 13 logger = logging.getLogger(__name__) 14 13 15 14 16 def draw_image(self, x, y, im, bbox, clippath=None, clippath_trans=None): … … 96 98 dc.DrawBitmap(self.canvas.bitmap, (0, 0)) 97 99 except: 98 logg ing.error(sys.exc_value)100 logger.error(sys.exc_value) 99 101 100 102 # restore original figure resolution … … 207 209 fig.draw(self) 208 210 except ValueError: 209 logg ing.error(sys.exc_value)211 logger.error(sys.exc_value) 210 212 else: 211 213 self._isRendered = False -
src/sas/sasgui/plottools/plottables.py
r9a5097c r9c0f3c17 46 46 import sys 47 47 import logging 48 49 logger = logging.getLogger(__name__) 48 50 49 51 if 'any' not in dir(__builtins__): … … 808 810 tempdy.append(self.dy[i]) 809 811 except: 810 logg ing.error("check_data_logX: skipping point x %g", self.x[i])811 logg ing.error(sys.exc_value)812 logger.error("check_data_logX: skipping point x %g", self.x[i]) 813 logger.error(sys.exc_value) 812 814 self.x = tempx 813 815 self.y = tempy … … 838 840 tempdy.append(self.dy[i]) 839 841 except: 840 logg ing.error("check_data_logY: skipping point %g", self.y[i])841 logg ing.error(sys.exc_value)842 logger.error("check_data_logY: skipping point %g", self.y[i]) 843 logger.error(sys.exc_value) 842 844 843 845 self.x = tempx -
src/sas/sasgui/plottools/toolbar.py
rd7bb526 r463e7ffc 6 6 from matplotlib.backends.backend_wx import _load_bitmap 7 7 import logging 8 9 logger = logging.getLogger(__name__) 8 10 9 11 # Event binding code changed after version 2.5 … … 94 96 self._parent.onToolContextMenu(event=event) 95 97 except: 96 logg ing.error("Plot toolbar could not show menu")98 logger.error("Plot toolbar could not show menu") 97 99 98 100 def context_menu(self, event): … … 122 124 except: 123 125 import traceback 124 logg ing.error(traceback.format_exc())126 logger.error(traceback.format_exc()) 125 127 126 128 def copy_figure(self, event): -
src/sas/sascalc/data_util/qsmearing.py
r9a5097c r0ac6e11 67 67 if _found_sesans == True: 68 68 #Pre-compute the Hankel matrix (H) 69 qmax, qunits = data.sample.zacceptance70 69 SElength = Converter(data._xunit)(data.x, "A") 71 zaccept = Converter(qunits)(qmax, "1/A"), 70 71 theta_max = Converter("radians")(data.sample.zacceptance)[0] 72 q_max = 2 * np.pi / np.max(data.source.wavelength) * np.sin(theta_max) 73 zaccept = Converter("1/A")(q_max, "1/" + data.source.wavelength_unit), 74 72 75 Rmax = 10000000 73 76 hankel = SesansTransform(data.x, SElength, zaccept, Rmax) -
src/sas/sascalc/dataloader/data_info.py
r9a5097c r747334d 354 354 ## SESANS zacceptance 355 355 zacceptance = None 356 yacceptance = None 356 357 357 358 def __init__(self): -
src/sas/sascalc/dataloader/readers/cansas_constants.py
rad4632c r747334d 135 135 "Sesans": {"storeas": "content"}, 136 136 "zacceptance": {"storeas": "float"}, 137 "yacceptance": {"storeas": "float"}, 137 138 "<any>" : ANY 138 139 } -
src/sas/sascalc/dataloader/readers/sesans_reader.py
r9a5097c r0ac6e11 1 1 """ 2 2 SESANS reader (based on ASCII reader) 3 3 4 4 Reader for .ses or .sesans file format 5 6 Jurrian Bakker 5 6 Jurrian Bakker 7 7 """ 8 import logging 8 9 import numpy as np 9 10 import os … … 18 19 _ZERO = 1e-16 19 20 21 20 22 class Reader: 21 23 """ 22 24 Class to load sesans files (6 columns). 23 25 """ 24 # #File type26 # File type 25 27 type_name = "SESANS" 26 27 # #Wildcards28 29 # Wildcards 28 30 type = ["SESANS files (*.ses)|*.ses", 29 31 "SESANS files (*..sesans)|*.sesans"] 30 # #List of allowed extensions32 # List of allowed extensions 31 33 ext = ['.ses', '.SES', '.sesans', '.SESANS'] 32 33 # #Flag to bypass extension check34 35 # Flag to bypass extension check 34 36 allow_all = True 35 37 36 38 def read(self, path): 37 38 # print "reader triggered"39 40 39 """ 41 40 Load data file 42 41 43 42 :param path: file path 44 43 45 44 :return: SESANSData1D object, or None 46 45 47 46 :raise RuntimeError: when the file can't be opened 48 47 :raise ValueError: when the length of the data vectors are inconsistent … … 51 50 basename = os.path.basename(path) 52 51 _, extension = os.path.splitext(basename) 53 if self.allow_all or extension.lower() in self.ext: 54 try: 55 # Read in binary mode since GRASP frequently has no-ascii 56 # characters that brakes the open operation 57 input_f = open(path,'rb') 58 except: 59 raise RuntimeError, "sesans_reader: cannot open %s" % path 60 buff = input_f.read() 61 lines = buff.splitlines() 62 x = np.zeros(0) 63 y = np.zeros(0) 64 dy = np.zeros(0) 65 lam = np.zeros(0) 66 dlam = np.zeros(0) 67 dx = np.zeros(0) 68 69 #temp. space to sort data 70 tx = np.zeros(0) 71 ty = np.zeros(0) 72 tdy = np.zeros(0) 73 tlam = np.zeros(0) 74 tdlam = np.zeros(0) 75 tdx = np.zeros(0) 76 output = Data1D(x=x, y=y, lam=lam, dy=dy, dx=dx, dlam=dlam, isSesans=True) 77 self.filename = output.filename = basename 52 if not (self.allow_all or extension.lower() in self.ext): 53 raise RuntimeError("{} has an unrecognized file extension".format(path)) 54 else: 55 raise RunetimeError("{} is not a file".format(path)) 56 with open(path, 'r') as input_f: 57 # Read in binary mode since GRASP frequently has no-ascii 58 # characters that brakes the open operation 59 line = input_f.readline() 60 params = {} 61 while not line.startswith("BEGIN_DATA"): 62 terms = line.split() 63 if len(terms) >= 2: 64 params[terms[0]] = " ".join(terms[1:]) 65 line = input_f.readline() 66 self.params = params 67 headers = input_f.readline().split() 78 68 79 paramnames=[] 80 paramvals=[] 81 zvals=[] 82 dzvals=[] 83 lamvals=[] 84 dlamvals=[] 85 Pvals=[] 86 dPvals=[] 69 data = np.loadtxt(input_f) 70 if data.size < 1: 71 raise RuntimeError("{} is empty".format(path)) 72 x = data[:, headers.index("SpinEchoLength")] 73 dx = data[:, headers.index("SpinEchoLength_error")] 74 lam = data[:, headers.index("Wavelength")] 75 dlam = data[:, headers.index("Wavelength_error")] 76 y = data[:, headers.index("Depolarisation")] 77 dy = data[:, headers.index("Depolarisation_error")] 87 78 88 for line in lines: 89 # Initial try for CSV (split on ,) 90 line=line.strip() 91 toks = line.split('\t') 92 if len(toks)==2: 93 paramnames.append(toks[0]) 94 paramvals.append(toks[1]) 95 if len(toks)>5: 96 zvals.append(toks[0]) 97 dzvals.append(toks[3]) 98 lamvals.append(toks[4]) 99 dlamvals.append(toks[5]) 100 Pvals.append(toks[1]) 101 dPvals.append(toks[2]) 102 else: 103 continue 79 lam_unit = self._unit_fetch("Wavelength") 80 x, x_unit = self._unit_conversion(x, "A", self._unit_fetch("SpinEchoLength")) 81 dx, dx_unit = self._unit_conversion( 82 dx, lam_unit, 83 self._unit_fetch("SpinEchoLength")) 84 dlam, dlam_unit = self._unit_conversion( 85 dlam, lam_unit, 86 self._unit_fetch("Wavelength")) 87 y_unit = self._unit_fetch("Depolarisation") 104 88 105 x=[] 106 y=[] 107 lam=[] 108 dx=[] 109 dy=[] 110 dlam=[] 111 lam_header = lamvals[0].split() 112 data_conv_z = None 113 default_z_unit = "A" 114 data_conv_P = None 115 default_p_unit = " " # Adjust unit for axis (L^-3) 116 lam_unit = lam_header[1].replace("[","").replace("]","") 117 if lam_unit == 'AA': 118 lam_unit = 'A' 119 varheader=[zvals[0],dzvals[0],lamvals[0],dlamvals[0],Pvals[0],dPvals[0]] 120 valrange=range(1, len(zvals)) 121 for i in valrange: 122 x.append(float(zvals[i])) 123 y.append(float(Pvals[i])) 124 lam.append(float(lamvals[i])) 125 dy.append(float(dPvals[i])) 126 dx.append(float(dzvals[i])) 127 dlam.append(float(dlamvals[i])) 89 output = Data1D(x=x, y=y, lam=lam, dy=dy, dx=dx, dlam=dlam, 90 isSesans=True) 128 91 129 x,y,lam,dy,dx,dlam = [ 130 np.asarray(v, 'double') 131 for v in (x,y,lam,dy,dx,dlam) 132 ] 92 output.y_unit = y_unit 93 output.x_unit = x_unit 94 output.source.wavelength_unit = lam_unit 95 output.source.wavelength = lam 96 self.filename = output.filename = basename 97 output.xaxis(r"\rm{z}", x_unit) 98 # Adjust label to ln P/(lam^2 t), remove lam column refs 99 output.yaxis(r"\rm{ln(P)/(t \lambda^2)}", y_unit) 100 # Store loading process information 101 output.meta_data['loader'] = self.type_name 102 output.sample.name = params["Sample"] 103 output.sample.ID = params["DataFileTitle"] 104 output.sample.thickness = float( 105 self._unit_conversion( 106 params["Thickness"], "cm", self._unit_fetch("Thickness"))[0]) 133 107 134 input_f.close() 108 output.sample.zacceptance = ( 109 float(params["Theta_zmax"]), 110 self._unit_fetch("Theta_zmax")) 135 111 136 output.x, output.x_unit = self._unit_conversion(x, lam_unit, default_z_unit) 137 output.y = y 138 output.y_unit = r'\AA^{-2} cm^{-1}' # output y_unit added 139 output.dx, output.dx_unit = self._unit_conversion(dx, lam_unit, default_z_unit) 140 output.dy = dy 141 output.lam, output.lam_unit = self._unit_conversion(lam, lam_unit, default_z_unit) 142 output.dlam, output.dlam_unit = self._unit_conversion(dlam, lam_unit, default_z_unit) 143 144 output.xaxis(r"\rm{z}", output.x_unit) 145 output.yaxis(r"\rm{ln(P)/(t \lambda^2)}", output.y_unit) # Adjust label to ln P/(lam^2 t), remove lam column refs 112 output.sample.yacceptance = ( 113 float(params["Theta_ymax"]), 114 self._unit_fetch("Theta_ymax")) 115 return output 146 116 147 # Store loading process information 148 output.meta_data['loader'] = self.type_name 149 #output.sample.thickness = float(paramvals[6]) 150 output.sample.name = paramvals[1] 151 output.sample.ID = paramvals[0] 152 zaccept_unit_split = paramnames[7].split("[") 153 zaccept_unit = zaccept_unit_split[1].replace("]","") 154 if zaccept_unit.strip() == r'\AA^-1' or zaccept_unit.strip() == r'\A^-1': 155 zaccept_unit = "1/A" 156 output.sample.zacceptance=(float(paramvals[7]),zaccept_unit) 157 output.vars = varheader 117 @staticmethod 118 def _unit_conversion(value, value_unit, default_unit): 119 """ 120 Performs unit conversion on a measurement. 158 121 159 if len(output.x) < 1: 160 raise RuntimeError, "%s is empty" % path 161 return output 162 163 else: 164 raise RuntimeError, "%s is not a file" % path 165 return None 166 167 def _unit_conversion(self, value, value_unit, default_unit): 168 if has_converter == True and value_unit != default_unit: 122 :param value: The magnitude of the measurement 123 :param value_unit: a string containing the final desired unit 124 :param default_unit: a string containing the units of the original measurement 125 :return: The magnitude of the measurement in the new units 126 """ 127 # (float, string, string) -> float 128 if has_converter and value_unit != default_unit: 169 129 data_conv_q = Converter(value_unit) 170 130 value = data_conv_q(value, units=default_unit) … … 173 133 new_unit = value_unit 174 134 return value, new_unit 135 136 def _unit_fetch(self, unit): 137 return self.params[unit+"_unit"]
Note: See TracChangeset
for help on using the changeset viewer.