Changeset 82d88d5 in sasview for src/sas/sasgui/guiframe


Ignore:
Timestamp:
Mar 6, 2019 4:18:09 PM (5 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1249
Children:
f923967
Parents:
cb64d86 (diff), f205d3a (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.
Message:

Merge branch 'master' into py37-sasgui

Location:
src/sas/sasgui/guiframe
Files:
35 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sasgui/guiframe/gui_manager.py

    r5251ec6 r82d88d5  
    4848from sas.sasgui.guiframe.CategoryManager import CategoryManager 
    4949from sas.sascalc.dataloader.loader import Loader 
     50from sas.sascalc.file_converter.nxcansas_writer import NXcanSASWriter 
    5051from sas.sasgui.guiframe.proxy import Connection 
    5152 
     
    6465SPLASH_SCREEN_HEIGHT = config.SPLASH_SCREEN_HEIGHT 
    6566SS_MAX_DISPLAY_TIME = config.SS_MAX_DISPLAY_TIME 
    66 if not WELCOME_PANEL_ON: 
    67     WELCOME_PANEL_SHOW = False 
     67 
     68def custom_value(name, default=None): 
     69    """ 
     70    Fetch a config value from custom_config.  Fallback to config, and then 
     71    to default if it doesn't exist in config. 
     72    """ 
     73    default = getattr(config, name, default) 
     74    return getattr(custom_config, name, default) 
     75 
     76# Custom config values in the order they appear. 
     77DATAPANEL_WIDTH = custom_value('DATAPANEL_WIDTH', -1) 
     78CLEANUP_PLOT = custom_value('CLEANUP_PLOT', False) 
     79FIXED_PANEL = custom_value('FIXED_PANEL', True) 
     80PLOPANEL_WIDTH = custom_value('PLOPANEL_WIDTH', -1) 
     81DATALOADER_SHOW = custom_value('DATALOADER_SHOW', True) 
     82GUIFRAME_HEIGHT = custom_value('GUIFRAME_HEIGHT', -1) 
     83GUIFRAME_WIDTH = custom_value('GUIFRAME_WIDTH', -1) 
     84CONTROL_WIDTH = custom_value('CONTROL_WIDTH', -1) 
     85CONTROL_HEIGHT = custom_value('CONTROL_HEIGHT', -1) 
     86open_folder = custom_value('DEFAULT_OPEN_FOLDER', None) 
     87if open_folder is not None and os.path.isdir(open_folder): 
     88    DEFAULT_OPEN_FOLDER = os.path.abspath(open_folder) 
    6889else: 
    69     WELCOME_PANEL_SHOW = True 
    70 try: 
    71     DATALOADER_SHOW = custom_config.DATALOADER_SHOW 
    72     TOOLBAR_SHOW = custom_config.TOOLBAR_SHOW 
    73     FIXED_PANEL = custom_config.FIXED_PANEL 
    74     if WELCOME_PANEL_ON: 
    75         WELCOME_PANEL_SHOW = custom_config.WELCOME_PANEL_SHOW 
    76     PLOPANEL_WIDTH = custom_config.PLOPANEL_WIDTH 
    77     DATAPANEL_WIDTH = custom_config.DATAPANEL_WIDTH 
    78     GUIFRAME_WIDTH = custom_config.GUIFRAME_WIDTH 
    79     GUIFRAME_HEIGHT = custom_config.GUIFRAME_HEIGHT 
    80     CONTROL_WIDTH = custom_config.CONTROL_WIDTH 
    81     CONTROL_HEIGHT = custom_config.CONTROL_HEIGHT 
    82     DEFAULT_PERSPECTIVE = custom_config.DEFAULT_PERSPECTIVE 
    83     CLEANUP_PLOT = custom_config.CLEANUP_PLOT 
    84     # custom open_path 
    85     open_folder = custom_config.DEFAULT_OPEN_FOLDER 
    86     if open_folder is not None and os.path.isdir(open_folder): 
    87         DEFAULT_OPEN_FOLDER = os.path.abspath(open_folder) 
    88     else: 
    89         DEFAULT_OPEN_FOLDER = get_app_dir() 
    90     SAS_OPENCL = custom_config.SAS_OPENCL 
    91 except: 
    92     DATALOADER_SHOW = True 
    93     TOOLBAR_SHOW = True 
    94     FIXED_PANEL = True 
    95     WELCOME_PANEL_SHOW = False 
    96     PLOPANEL_WIDTH = config.PLOPANEL_WIDTH 
    97     DATAPANEL_WIDTH = config.DATAPANEL_WIDTH 
    98     GUIFRAME_WIDTH = config.GUIFRAME_WIDTH 
    99     GUIFRAME_HEIGHT = config.GUIFRAME_HEIGHT 
    100     CONTROL_WIDTH = -1 
    101     CONTROL_HEIGHT = -1 
    102     DEFAULT_PERSPECTIVE = None 
    103     CLEANUP_PLOT = False 
    10490    DEFAULT_OPEN_FOLDER = get_app_dir() 
    105     DEFAULT_OPEN_FOLDER = PATH_APP 
    106     SAS_OPENCL = None 
     91WELCOME_PANEL_SHOW = (custom_value('WELCOME_PANEL_SHOW', False) 
     92                      if WELCOME_PANEL_ON else False) 
     93TOOLBAR_SHOW = custom_value('TOOLBAR_SHOW', True) 
     94DEFAULT_PERSPECTIVE = custom_value('DEFAULT_PERSPECTIVE', 'Fitting') 
     95SAS_OPENCL = custom_value('SAS_OPENCL', 'None') 
     96 
    10797DEFAULT_STYLE = config.DEFAULT_STYLE 
    108  
    10998PLUGIN_STATE_EXTENSIONS = config.PLUGIN_STATE_EXTENSIONS 
    11099OPEN_SAVE_MENU = config.OPEN_SAVE_PROJECT_MENU 
     
    24202409        default_name = fname 
    24212410        wildcard = "Text files (*.txt)|*.txt|"\ 
    2422                     "CanSAS 1D files(*.xml)|*.xml" 
    2423         path = None 
     2411                    "CanSAS 1D files (*.xml)|*.xml|"\ 
     2412                     "NXcanSAS files (*.h5)|*.h5|" 
     2413        options = [".txt", ".xml",".h5"] 
    24242414        dlg = wx.FileDialog(self, "Choose a file", 
    24252415                            self._default_save_location, 
     
    24312421            # This is MAC Fix 
    24322422            ext_num = dlg.GetFilterIndex() 
    2433             if ext_num == 0: 
    2434                 ext_format = '.txt' 
    2435             else: 
    2436                 ext_format = '.xml' 
     2423 
     2424            ext_format = options[ext_num] 
    24372425            path = os.path.splitext(path)[0] + ext_format 
    24382426            mypath = os.path.basename(path) 
    2439  
    2440             # Instantiate a loader 
    2441             loader = Loader() 
    2442             ext_format = ".txt" 
    2443             if os.path.splitext(mypath)[1].lower() == ext_format: 
     2427            fName = os.path.splitext(path)[0] + ext_format 
     2428 
     2429            if os.path.splitext(mypath)[1].lower() == options[0]: 
    24442430                # Make sure the ext included in the file name 
    24452431                # especially on MAC 
    2446                 fName = os.path.splitext(path)[0] + ext_format 
    24472432                self._onsaveTXT(data, fName) 
    2448             ext_format = ".xml" 
    2449             if os.path.splitext(mypath)[1].lower() == ext_format: 
     2433            elif os.path.splitext(mypath)[1].lower() == options[1]: 
    24502434                # Make sure the ext included in the file name 
    24512435                # especially on MAC 
    2452                 fName = os.path.splitext(path)[0] + ext_format 
     2436                # Instantiate a loader 
     2437                loader = Loader() 
    24532438                loader.save(fName, data, ext_format) 
     2439            elif os.path.splitext(mypath)[1].lower() == options[2]: 
     2440                nxcansaswriter = NXcanSASWriter() 
     2441                nxcansaswriter.write([data], fName) 
    24542442            try: 
    24552443                self._default_save_location = os.path.dirname(path) 
     
    24782466            if has_errors: 
    24792467                if data.dx is not None and data.dx != []: 
    2480                     out.write("<X>   <Y>   <dY>   <dX>\n") 
     2468                    out.write("<X>\t<Y>\t<dY>\t<dX>\n") 
    24812469                else: 
    2482                     out.write("<X>   <Y>   <dY>\n") 
     2470                    out.write("<X>\t<Y>\t<dY>\n") 
    24832471            else: 
    2484                 out.write("<X>   <Y>\n") 
     2472                out.write("<X>\t<Y>\n") 
    24852473 
    24862474            for i in range(len(data.x)): 
     
    25262514            text += 'dY_min = %s:  dY_max = %s\n' % (min(data.dy), max(data.dy)) 
    25272515        text += '\nData Points:\n' 
    2528         x_st = "X" 
     2516        text += "<index> \t<X> \t<Y> \t<dY> " 
     2517        text += "\t<dXl> \t<dXw>\n" if(data.dxl is not None and 
     2518                                       data.dxw is not None) else "\t<dX>\n" 
    25292519        for index in range(len(data.x)): 
    25302520            if data.dy is not None and len(data.dy) > index: 
     
    25372527                dx_val = 0.0 
    25382528            if data.dxl is not None and len(data.dxl) > index: 
    2539                 if index == 0: 
    2540                     x_st = "Xl" 
    25412529                dx_val = data.dxl[index] 
    2542             elif data.dxw is not None and len(data.dxw) > index: 
    2543                 if index == 0: 
    2544                     x_st = "Xw" 
    2545                 dx_val = data.dxw[index] 
    2546  
    2547             if index == 0: 
    2548                 text += "<index> \t<X> \t<Y> \t<dY> \t<d%s>\n" % x_st 
     2530                if data.dxw is not None and len(data.dxw) > index: 
     2531                    dx_val = "%s \t%s" % (data.dxl[index], data.dxw[index]) 
     2532 
    25492533            text += "%s \t%s \t%s \t%s \t%s\n" % (index, 
    25502534                                                  data.x[index], 
     
    25632547        """ 
    25642548        default_name = fname 
    2565         wildcard = "IGOR/DAT 2D file in Q_map (*.dat)|*.DAT" 
     2549        wildcard = "IGOR/DAT 2D file in Q_map (*.dat)|*.DAT|"\ 
     2550                   "NXcanSAS files (*.h5)|*.h5|" 
    25662551        dlg = wx.FileDialog(self, "Choose a file", 
    25672552                            self._default_save_location, 
     
    25752560            if ext_num == 0: 
    25762561                ext_format = '.dat' 
     2562            elif ext_num == 1: 
     2563                ext_format = '.h5' 
    25772564            else: 
    25782565                ext_format = '' 
     
    25822569            # Instantiate a loader 
    25832570            loader = Loader() 
    2584  
    2585             ext_format = ".dat" 
    2586             if os.path.splitext(mypath)[1].lower() == ext_format: 
     2571            ext = os.path.splitext(mypath)[1].lower() 
     2572            if ext == '.dat': 
    25872573                # Make sure the ext included in the file name 
    25882574                # especially on MAC 
    25892575                fileName = os.path.splitext(path)[0] + ext_format 
    25902576                loader.save(fileName, data, ext_format) 
     2577            elif ext == '.h5': 
     2578                # Make sure the ext included in the file name 
     2579                # especially on MAC 
     2580                fileName = os.path.splitext(path)[0] + ext_format 
     2581                nxcansaswriter = NXcanSASWriter() 
     2582                nxcansaswriter.write([data], fileName) 
    25912583            try: 
    25922584                self._default_save_location = os.path.dirname(path) 
  • src/sas/sasgui/guiframe/local_perspectives/data_loader/data_loader.py

    r5251ec6 r82d88d5  
    205205            except NoKnownLoaderException as e: 
    206206                exception_occurred = True 
    207                 error_message = "Loading data failed!" + e.message 
     207                error_message = "Loading data failed!\n" + e.message 
    208208                file_errors[basename] = [error_message] 
    209209            except Exception as e: 
     
    224224                for message in error_array: 
    225225                    error_message += message + "\n" 
     226                error_message = error_message[:-1] 
    226227            self.load_complete(output=output, 
    227228                               message=error_message, 
     
    231232            self.load_complete(output=output, message="Loading data complete!", 
    232233                               info="info") 
    233         else: 
    234             self.load_complete(output=None, message=error_message, info="error") 
    235234 
    236235    def load_update(self, message="", info="warning"): 
  • src/sas/sasgui/guiframe/CategoryInstaller.py

    ra26f67f rcb64d86  
    2020 
    2121logger = logging.getLogger(__name__) 
     22 
     23if sys.version_info[0] > 2: 
     24    def json_dump(obj, filename): 
     25        with open(filename, 'w', newline='\n') as fd: 
     26            json.dump(obj, fd) 
     27else: # CRUFT: python 2.7 support 
     28    def json_dump(obj, filename): 
     29        with open(filename, 'wb') as fd: 
     30            json.dump(obj, fd) 
    2231 
    2332class CategoryInstaller(object): 
     
    121130        """ 
    122131        _model_dict = {model.name: model for model in model_list} 
    123         _model_list = _model_dict.keys() 
     132        _model_list = list(_model_dict.keys()) 
    124133 
    125134        serialized_file = None 
     
    146155                        by_model_dict.pop(model_name) 
    147156                        model_enabled_dict.pop(model_name) 
    148                     except Exception: 
    149                         logger.error("CategoryInstaller: %s", sys.exc_value) 
     157                    except Exception as exc: 
     158                        logger.error("CategoryInstaller: %s", exc) 
    150159                else: 
    151160                    add_list.remove(model_name) 
     
    171180                                                          model_enabled_dict) 
    172181 
    173             json.dump(master_category_dict, open(serialized_file, 'wb')) 
     182            json_dump(master_category_dict, serialized_file) 
  • src/sas/sasgui/guiframe/CategoryManager.py

    r463e7ffc r5251ec6  
    230230 
    231231        for model in model_name_list: 
    232             index = self.cat_list.InsertStringItem(sys.maxint, model) 
     232            index = self.cat_list.InsertStringItem(sys.maxsize, model) 
    233233            self.cat_list.SetStringItem(index, 1, \ 
    234234                                            str(self.by_model_dict[model]).\ 
     
    384384        """ 
    385385        cat_list = list() 
    386         for category in self.master_category_dict.iterkeys(): 
     386        for category in self.master_category_dict.keys(): 
    387387            if not category == 'Uncategorized': 
    388388                cat_list.append(category) 
  • src/sas/sasgui/guiframe/custom_pstats.py

    r959eb01 r5251ec6  
    3636        width = self.max_name_len 
    3737        if self.fcn_list: 
    38             list = self.fcn_list[:] 
     38            stats = self.fcn_list[:] 
    3939            temp_msg = "   Ordered by: " + self.sort_type + '\n' 
    4040        else: 
    41             list = self.stats.keys() 
     41            stats = list(self.stats.keys()) 
    4242            temp_msg = "   Random listing order was used\n" 
    4343 
    4444        for selection in amount: 
    45             list, temp_msg = self.eval_print_amount(selection, list, temp_msg) 
     45            stats, temp_msg = self.eval_print_amount(selection, stats, temp_msg) 
    4646 
    47         count = len(list) 
     47        count = len(stats) 
    4848 
    49         if not list: 
    50             width, list = 0, list 
     49        if not stats: 
     50            width = 0 
    5151        else: 
    52             msg +=   str(temp_msg) + '\n' 
     52            msg += str(temp_msg) + '\n' 
    5353            if count < len(self.stats): 
    5454                width = 0 
    55                 for func in list: 
     55                for func in stats: 
    5656                    if  len(func_std_string(func)) > width: 
    5757                        width = len(func_std_string(func)) 
    5858        
    59             width, list = width+2, list 
    60         if list: 
     59            width = width+2 
     60        if stats: 
    6161            msg += '   ncalls  tottime  percall  cumtime  percall' 
    6262            msg +=  ' filename:lineno(function)' + "\n" 
    63             for func in list: 
     63            for func in stats: 
    6464                cc, nc, tt, ct, callers = self.stats[func] 
    6565                c = str(nc) 
  • src/sas/sasgui/guiframe/data_manager.py

    r959eb01 r5251ec6  
    5151        _str += "No of states  is %s \n" % str(len(self.stored_data)) 
    5252        n_count = 0 
    53         for  value in self.stored_data.values(): 
     53        for value in self.stored_data.values(): 
    5454            n_count += 1  
    5555            _str += "State No %s \n"  % str(n_count) 
     
    134134        receive a list of  
    135135        """ 
    136         for id, data in data_list.iteritems(): 
     136        for id, data in data_list.items(): 
    137137            if id  in self.stored_data: 
    138138                msg = "Data manager already stores %s" % str(data.name) 
     
    150150        """ 
    151151        """ 
    152         if prev_data.id not in self.stored_data.keys(): 
     152        if prev_data.id not in self.stored_data: 
    153153            return None, {} 
    154154        data_state = self.stored_data[prev_data.id]  
    155155        self.stored_data[new_data.id]  = data_state.clone() 
    156156        self.stored_data[new_data.id].data = new_data 
    157         if prev_data.id in self.stored_data.keys(): 
     157        if prev_data.id in self.stored_data: 
    158158            del self.stored_data[prev_data.id]  
    159159        return prev_data.id, {new_data.id: self.stored_data[new_data.id]} 
     
    165165        if data_id is None and theory is not None: 
    166166            uid = theory.id 
    167         if uid in self.stored_data.keys(): 
     167        if uid in self.stored_data: 
    168168             data_state = self.stored_data[uid]  
    169169        else: 
     
    195195                if search_id == d_id: 
    196196                    _selected_data[search_id] = data 
    197                 if search_id in theory_list.keys(): 
     197                if search_id in theory_list: 
    198198                     _selected_theory_list[search_id] = theory_list[search_id] 
    199199                    
     
    204204        """ 
    205205        """ 
    206         return self.freeze_theory(self.stored_data.keys(), theory_id) 
     206        return self.freeze_theory(list(self.stored_data.keys()), theory_id) 
    207207         
    208208    def freeze_theory(self, data_id, theory_id): 
     
    215215                theory_list = data_state.get_theory() 
    216216                for t_id in theory_id: 
    217                     if t_id in theory_list.keys(): 
     217                    if t_id in theory_list: 
    218218                        theory_data, theory_state = theory_list[t_id] 
    219219                        new_theory = copy.deepcopy(theory_data) 
     
    235235        """ 
    236236        for d_id in data_id: 
    237             if d_id in self.stored_data.keys(): 
     237            if d_id in self.stored_data: 
    238238                data_state = self.stored_data[d_id] 
    239239                if data_state.data.name in self.data_name_dict: 
     
    253253                data_state = self.stored_data[d_id] 
    254254                theory_list = data_state.get_theory() 
    255                 if theory_id in theory_list.keys(): 
     255                if theory_id in theory_list: 
    256256                    del theory_list[theory_id] 
    257257        #del pure theory 
     
    273273        _selected_data = {} 
    274274        for selected_name in name_list: 
    275             for id, data_state in self.stored_data.iteritems(): 
     275            for id, data_state in self.stored_data.items(): 
    276276                if data_state.data.name == selected_name: 
    277277                    _selected_data[id] = data_state.data 
     
    283283        """ 
    284284        for selected_name in name_list: 
    285             for id, data_state in self.stored_data.iteritems(): 
     285            for id, data_state in self.stored_data.items(): 
    286286                if data_state.data.name == selected_name: 
    287287                    del self.stored_data[id] 
     
    293293        _selected_data_state = {} 
    294294        for id in data_id: 
    295             if id in self.stored_data.keys(): 
     295            if id in self.stored_data: 
    296296                _selected_data_state[id] = self.stored_data[id] 
    297297        return _selected_data_state 
     
    303303        return self.stored_data 
    304304     
    305  
    306          
  • src/sas/sasgui/guiframe/data_panel.py

    rb963b20 r5251ec6  
    1313from __future__ import print_function 
    1414 
     15import sys 
     16 
    1517import wx 
    16 from wx.build import build_options 
    17  
    18 import sys 
    1918from wx.lib.scrolledpanel import ScrolledPanel 
    2019import wx.lib.agw.customtreectrl as CT 
     20#from wx.build import build_options 
     21 
    2122from sas.sasgui.guiframe.dataFitting import Data1D 
    2223from sas.sasgui.guiframe.dataFitting import Data2D 
     
    444445            self.parent.get_data_manager().get_by_id(id_list=[id]) 
    445446        if data_list: 
    446             data = data_list.values()[0] 
     447            data = list(data_list.values())[0] 
    447448        if data is None: 
    448             data = theory_list.values()[0][0] 
     449            data = list(theory_list.values())[0][0] 
    449450        return data 
    450451 
     
    667668        """ 
    668669        if list: 
    669             for state_id, dstate in list.iteritems(): 
     670            for state_id, dstate in list.items(): 
    670671                data = dstate.get_data() 
    671672                theory_list = dstate.get_theory() 
     
    764765        if not theory_list: 
    765766            return 
    766         if state_id not in self.list_cb_data.keys(): 
     767        if state_id not in self.list_cb_data: 
    767768            root = self.tree_ctrl_theory.root 
    768769            tree = self.tree_ctrl_theory 
     
    783784        Append theory helper 
    784785        """ 
    785         if state_id in self.list_cb_theory.keys(): 
     786        if state_id in self.list_cb_theory: 
    786787            # update current list of theory for this data 
    787788            theory_list_ctrl = self.list_cb_theory[state_id] 
    788789 
    789             for theory_id, item in theory_list.iteritems(): 
     790            for theory_id, item in theory_list.items(): 
    790791                theory_data, _ = item 
    791792                if theory_data is None: 
     
    828829            # data didn't have a theory associated it before 
    829830            theory_list_ctrl = {} 
    830             for theory_id, item in theory_list.iteritems(): 
     831            for theory_id, item in theory_list.items(): 
    831832                theory_data, _ = item 
    832833                if theory_data is not None: 
     
    868869 
    869870        for theory_dict in self.list_cb_theory.values(): 
    870             for _, value in theory_dict.iteritems(): 
     871            for _, value in theory_dict.items(): 
    871872                item, _, _ = value 
    872873                if item.IsChecked(): 
     
    924925        theory_key = [] 
    925926        # remove  data from treectrl 
    926         for d_key, item in self.list_cb_data.iteritems(): 
     927        for d_key, item in self.list_cb_data.items(): 
    927928            data_c, _, _, _,  _, _, _, _ = item 
    928929            if data_c.IsChecked(): 
    929930                self.tree_ctrl.Delete(data_c) 
    930931                data_key.append(d_key) 
    931                 if d_key in self.list_cb_theory.keys(): 
     932                if d_key in self.list_cb_theory: 
    932933                    theory_list_ctrl = self.list_cb_theory[d_key] 
    933                     theory_to_remove += theory_list_ctrl.keys() 
     934                    theory_to_remove += list(theory_list_ctrl.keys()) 
    934935        # Remove theory from treectrl 
    935         for _, theory_dict in self.list_cb_theory.iteritems(): 
    936             for key, value in theory_dict.iteritems(): 
     936        for _, theory_dict in self.list_cb_theory.items(): 
     937            for key, value in theory_dict.items(): 
    937938                item, _, _ = value 
    938939                if item.IsChecked(): 
     
    950951        # remove theory  references independently of data 
    951952        for key in theory_key: 
    952             for _, theory_dict in self.list_cb_theory.iteritems(): 
     953            for _, theory_dict in self.list_cb_theory.items(): 
    953954                if key in theory_dict: 
    954                     for key, value in theory_dict.iteritems(): 
     955                    for key, value in theory_dict.items(): 
    955956                        item, _, _ = value 
    956957                        if item.IsChecked(): 
     
    10471048        if self.cb_plotpanel and self.cb_plotpanel.IsBeingDeleted(): 
    10481049            return 
    1049         for _, value in self.parent.plot_panels.iteritems(): 
     1050        for _, value in self.parent.plot_panels.items(): 
    10501051            name_plot_panel = str(value.window_caption) 
    10511052            if name_plot_panel not in self.cb_plotpanel.GetItems(): 
     
    11291130        #import documentation window here to avoid circular imports 
    11301131        #if put at top of file with rest of imports. 
    1131         from documentation_window import DocumentationWindow 
     1132        from .documentation_window import DocumentationWindow 
    11321133 
    11331134        _TreeLocation = "user/sasgui/guiframe/data_explorer_help.html" 
     
    14991500        window.Show(True) 
    15001501        window.load_data_list(list=temp_data_list) 
    1501     except: 
     1502    except Exception as exc: 
    15021503        # raise 
    1503         print("error", sys.exc_value) 
     1504        print("error", exc) 
    15041505 
    15051506    app.MainLoop() 
  • src/sas/sasgui/guiframe/data_processor.py

    r20fa5fe r5251ec6  
    234234        # overriden in this subclassn - actually we have currently 
    235235        # disabled the on_context_menu that would override the OnRightClick 
    236         self.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.OnCellChange) 
     236        try: 
     237            EVT_GRID_CELL_CHANGED = wx.grid.EVT_GRID_CELL_CHANGED 
     238        except AttributeError: 
     239            # CRUFT: wx 3.x uses CHANGE rather than CHANGING/CHANGED 
     240            EVT_GRID_CELL_CHANGED = wx.grid.EVT_GRID_CELL_CHANGE 
     241        self.Bind(EVT_GRID_CELL_CHANGED, self.OnCellChange) 
    237242        self.Bind(wx.grid.EVT_GRID_CELL_LEFT_CLICK, self.OnLeftClick) 
    238243        self.Bind(wx.grid.EVT_GRID_CELL_RIGHT_CLICK, self.OnRightClick) 
     
    561566                value = self.GetCellValue(row, col) 
    562567                self.data[col_name].append(value) 
    563                 for k, value_list in self.data.iteritems(): 
     568                for k, value_list in self.data.items(): 
    564569                    if k != col_name: 
    565570                        length = len(value_list) 
     
    621626        if col_name.strip() != "Empty": 
    622627            self.SetCellValue(row, col, str(col_name.strip())) 
    623         if col_name in self.data.keys(): 
     628        if col_name in self.data: 
    624629            value_list = self.data[col_name] 
    625630            cell_row = 1 
     
    674679            self._cols = self.GetNumberCols() 
    675680            self._rows = self.GetNumberRows() 
    676             self.col_names = self.data_outputs.keys() 
     681            self.col_names = list(self.data_outputs.keys()) 
    677682            self.col_names.sort() 
    678683            nbr_user_cols = len(self.col_names) 
     
    682687                self.AppendCols(new_col_nbr, True) 
    683688            #Add more rows to the grid if necessary 
    684             nbr_user_row = len(self.data_outputs.values()[0]) 
     689            nbr_user_row = len(list(self.data_outputs.values())[0]) 
    685690            if nbr_user_row > self._rows + 1: 
    686691                new_row_nbr = nbr_user_row - self._rows + 1 
     
    909914                    msg = "Edit axis doesn't understand this selection.\n" 
    910915                    msg += "Please select only one column" 
    911                     raise ValueError, msg 
     916                    raise ValueError(msg) 
    912917            for (_, cell_col) in grid.selected_cells: 
    913918                if cell_col != col: 
     
    915920                    msg += "this operation.\n" 
    916921                    msg += "Please select elements of the same col.\n" 
    917                     raise ValueError, msg 
     922                    raise ValueError(msg) 
    918923 
    919924            # Finally check the highlighted cell if any cells missing 
     
    922927            msg = "No item selected.\n" 
    923928            msg += "Please select only one column or one cell" 
    924             raise ValueError, msg 
     929            raise ValueError(msg) 
    925930        return grid.selected_cells 
    926931 
     
    13261331            if sentence.strip() == "": 
    13271332                msg = "Select column values for x axis" 
    1328                 raise ValueError, msg 
     1333                raise ValueError(msg) 
    13291334        except: 
    13301335            msg = "X axis value error." 
     
    13451350            if sentence.strip() == "": 
    13461351                msg = "select value for y axis" 
    1347                 raise ValueError, msg 
     1352                raise ValueError(msg) 
    13481353        except: 
    13491354            msg = "Y axis value error." 
     
    14401445        """ 
    14411446 
    1442         for tok, (col_name, list) in dict.iteritems(): 
     1447        for tok, (col_name, list) in dict.items(): 
    14431448            col = column_names[col_name] 
    14441449            axis = self.get_plot_axis(col, list) 
     
    14461451                return None 
    14471452            sentence = sentence.replace(tok, "numpy.array(%s)" % str(axis)) 
    1448         for key, value in FUNC_DICT.iteritems(): 
     1453        for key, value in FUNC_DICT.items(): 
    14491454            sentence = sentence.replace(key.lower(), value) 
    14501455        return sentence 
     
    15461551            cell_list = self.notebook.on_edit_axis() 
    15471552            label, title = self.create_axis_label(cell_list) 
    1548         except: 
    1549             msg = str(sys.exc_value) 
     1553        except Exception as exc: 
     1554            msg = str(exc) 
    15501555            wx.PostEvent(self.parent.parent, StatusEvent(status=msg, info="error")) 
    15511556            return 
     
    20362041        frame = GridFrame(data_outputs=data, data_inputs=data_input) 
    20372042        frame.Show(True) 
    2038     except: 
    2039         print(sys.exc_value) 
     2043    except Exception as exc: 
     2044        print(exc) 
    20402045 
    20412046    app.MainLoop() 
  • src/sas/sasgui/guiframe/data_state.py

    r959eb01 r5251ec6  
    3737        _str += "Theories available: %s \n" % len(self.theory_list) 
    3838        if self.theory_list: 
    39             for id, item in self.theory_list.iteritems(): 
     39            for id, item in self.theory_list.items(): 
    4040                theory_data, theory_state = item 
    4141                _str += "Theory name : %s \n" % str(theory_data.name) 
     
    5353        obj.message = self.message 
    5454        obj.id = self.id 
    55         for id, item in self.theory_list.iteritems(): 
     55        for id, item in self.theory_list.items(): 
    5656            theory_data, theory_state = item 
    5757            state = None 
     
    9595        """ 
    9696        self.theory_list[theory_data.id] = [theory_data, theory_state] 
    97         data, state = self.theory_list.values()[0] 
     97        data, state = list(self.theory_list.values())[0] 
    9898        
    9999    def get_theory(self): 
     
    106106        return self.message 
    107107     
    108    
  • src/sas/sasgui/guiframe/gui_statusbar.py

    r463e7ffc r5251ec6  
    8686                                                    wx.ART_TOOLBAR) 
    8787        self.msg_txt.Newline() 
    88         self.msg_txt.WriteBitmap(icon_bmp) 
     88        # wx 3 has WriteImage and WriteBitmap; not sure if there 
     89        # is any difference between them.  wx 4 has only WriteImage. 
     90        self.msg_txt.WriteImage(icon_bmp) 
    8991        self.msg_txt.BeginTextColour(color) 
    9092        self.msg_txt.WriteText("\t") 
  • src/sas/sasgui/guiframe/gui_style.py

    ra1b8fee r5251ec6  
    5858    DRAG_ID_PATH = os.path.join(PATH, 'drag_hand.png') 
    5959    RESET_ID_PATH = os.path.join(PATH, 'reset.png') 
    60     PREVIEW_ID_PATH = os.path.join(PATH, 'report.png') 
     60    REPORT_ID_PATH = os.path.join(PATH, 'report.png') 
     61    PREVIEW_ID_PATH = os.path.join(PATH, 'preview.png') 
    6162    PRINT_ID_PATH = os.path.join(PATH, 'printer.png') 
    6263    HIDE_ID_PATH = os.path.join(PATH, 'hide.png') 
    6364     
    64    
    65     SAVE_ICON = wx.Image(os.path.join(PATH, 'save.png')) 
    66     UNDO_ICON = wx.Image(os.path.join(PATH, 'undo.png')) 
    67     REDO_ICON = wx.Image(os.path.join(PATH, 'redo.png')) 
    68     COPY_ICON = wx.Image(os.path.join(PATH, 'copy.png')) 
    69     PASTE_ICON = wx.Image(os.path.join(PATH, 'paste.png')) 
    70     BOOKMARK_ICON = wx.Image(os.path.join(PATH, 'bookmark.png')) 
    71     ZOOM_IN_ICON = wx.Image(os.path.join(PATH, 'zoom_in.png')) 
    72     ZOOM_OUT_ICON = wx.Image(os.path.join(PATH, 'zoom_out.png')) 
    73     ZOOM_ICON = wx.Image(os.path.join(PATH, 'search_pan.png')) 
    74     DRAG_ICON = wx.Image(os.path.join(PATH, 'drag_hand.png')) 
    75     RESET_ICON = wx.Image(os.path.join(PATH, 'reset.png')) 
    76     REPORT_ICON = wx.Image(os.path.join(PATH, 'report.png')) 
    77     PREVIEW_ICON = wx.Image(os.path.join(PATH, 'preview.png')) 
    78     PRINT_ICON = wx.Image(os.path.join(PATH, 'printer.png')) 
    79     HIDE_ICON = wx.Image(os.path.join(PATH, 'hide.png')) 
     65    # Note: wx 4 requires that the app be defined before 
     66    # the images are loaded, so they can't be processed 
     67    # at module load time.  Instead, need to load icons 
     68    # when the app is created. 
     69    @classmethod 
     70    def load_icons(cls): 
     71        cls.SAVE_ICON = wx.Image(cls.SAVE_ICON_PATH) 
     72        cls.UNDO_ICON = wx.Image(cls.UNDO_ICON_PATH) 
     73        cls.REDO_ICON = wx.Image(cls.REDO_ICON_PATH) 
     74        cls.COPY_ICON = wx.Image(cls.COPY_ICON_PATH) 
     75        cls.PASTE_ICON = wx.Image(cls.PASTE_ICON_PATH) 
     76        cls.BOOKMARK_ICON = wx.Image(cls.BOOKMARK_ICON_PATH) 
     77        cls.ZOOM_IN_ICON = wx.Image(cls.ZOOM_IN_ID_PATH) 
     78        cls.ZOOM_OUT_ICON = wx.Image(cls.ZOOM_OUT_ID_PATH) 
     79        cls.ZOOM_ICON = wx.Image(cls.ZOOM_ID_PATH) 
     80        cls.DRAG_ICON = wx.Image(cls.DRAG_ID_PATH) 
     81        cls.RESET_ICON = wx.Image(cls.RESET_ID_PATH) 
     82        cls.REPORT_ICON = wx.Image(cls.REPORT_ID_PATH) 
     83        cls.PREVIEW_ICON = wx.Image(cls.PREVIEW_ID_PATH) 
     84        cls.PRINT_ICON = wx.Image(cls.PRINT_ID_PATH) 
     85        cls.HIDE_ICON = wx.Image(cls.HIDE_ID_PATH) 
    8086 
    8187if __name__ == "__main__": 
  • src/sas/sasgui/guiframe/local_perspectives/data_loader/load_thread.py

    r959eb01 r5251ec6  
    7272                if self.updatefn is not None: 
    7373                    self.updatefn(output=output, message=message) 
    74             except: 
     74            except Exception as exc: 
    7575                error_message = "Error while loading: %s\n" % str(path) 
    76                 error_message += str(sys.exc_value) + "\n" 
     76                error_message += str(exc) + "\n" 
    7777                self.updatefn(output=output, message=error_message) 
    7878 
  • src/sas/sasgui/guiframe/local_perspectives/plotting/AnnulusSlicer.py

    r7432acb r5251ec6  
    77 
    88import math 
     9# from copy import deepcopy 
     10 
    911import wx 
    10 # from copy import deepcopy 
    11 # Debug printout 
     12 
    1213from sas.sasgui.guiframe.events import NewPlotEvent 
    1314from sas.sasgui.guiframe.events import StatusEvent 
    1415from sas.sasgui.guiframe.events import SlicerParameterEvent 
    1516from sas.sasgui.guiframe.events import EVT_SLICER_PARS 
    16 from BaseInteractor import _BaseInteractor 
    1717from sas.sasgui.guiframe.dataFitting import Data1D 
     18 
     19from .BaseInteractor import _BaseInteractor 
    1820 
    1921class AnnulusInteractor(_BaseInteractor): 
  • src/sas/sasgui/guiframe/local_perspectives/plotting/Arc.py

    r7432acb r5251ec6  
    44import math 
    55 
    6 from BaseInteractor import _BaseInteractor 
    76from sas.sasgui.guiframe.events import SlicerParameterEvent 
     7 
     8from .BaseInteractor import _BaseInteractor 
    89 
    910class ArcInteractor(_BaseInteractor): 
  • src/sas/sasgui/guiframe/local_perspectives/plotting/AzimutSlicer.py

    rd85c194 r5251ec6  
    55# 
    66import math 
     7 
    78import wx 
    8 from BaseInteractor import _BaseInteractor 
     9 
    910from sas.sasgui.guiframe.events import NewPlotEvent 
    1011from sas.sasgui.guiframe.events import EVT_SLICER_PARS 
     12 
     13from .BaseInteractor import _BaseInteractor 
    1114 
    1215class SectorInteractor(_BaseInteractor): 
     
    2932 
    3033        # Inner circle 
    31         from Arc import ArcInteractor 
     34        from .Arc import ArcInteractor 
    3235        self.inner_circle = ArcInteractor(self, self.base.subplot, 
    3336                                          zorder=zorder, 
     
    4346        self.outer_circle.qmax = self.qmax * 1.2 
    4447        # self.outer_circle.set_cursor(self.base.qmax/1.8, 0) 
    45         from Edge import RadiusInteractor 
     48        from .Edge import RadiusInteractor 
    4649        self.right_edge = RadiusInteractor(self, self.base.subplot, 
    4750                                           zorder=zorder + 1, 
  • src/sas/sasgui/guiframe/local_perspectives/plotting/Edge.py

    r7432acb r5251ec6  
    11import math 
    2 from BaseInteractor import _BaseInteractor 
     2 
     3from .BaseInteractor import _BaseInteractor 
    34 
    45 
  • src/sas/sasgui/guiframe/local_perspectives/plotting/Plotter1D.py

    r2469df7 r5251ec6  
    1111 
    1212 
    13 import wx 
    1413import sys 
    1514import math 
     15import logging 
     16 
     17import wx 
    1618import numpy as np 
    17 import logging 
     19 
    1820from sas.sasgui.plottools.PlotPanel import PlotPanel 
    1921from sas.sasgui.guiframe.events import StatusEvent 
     
    2224from sas.sasgui.guiframe.panel_base import PanelBase 
    2325from sas.sasgui.guiframe.gui_style import GUIFRAME_ICON 
    24 from appearanceDialog import appearanceDialog 
    25 from graphAppearance import graphAppearance 
     26 
     27from .appearanceDialog import appearanceDialog 
     28from .graphAppearance import graphAppearance 
    2629 
    2730logger = logging.getLogger(__name__) 
     
    3639def find_key(dic, val): 
    3740    """return the key of dictionary dic given the value""" 
    38     return [k for k, v in dic.iteritems() if v == val][0] 
     41    return [k for k, v in dic.items() if v == val][0] 
    3942 
    4043class ModelPanel1D(PlotPanel, PanelBase): 
     
    220223        if hasattr(event, 'is_corfunc'): 
    221224            self.is_corfunc = event.is_corfunc 
    222         if event.id in self.plots.keys(): 
     225        if event.id in self.plots: 
    223226            ctrl = event.ctrl 
    224227            self.cursor_id = event.id 
     
    243246                if position is not None and not self.is_corfunc: 
    244247                    wx.PostEvent(self.parent, StatusEvent(status=position)) 
    245             except: 
    246                 logger.error(sys.exc_value) 
     248            except Exception as exc: 
     249                logger.error(exc) 
    247250            if not event.leftdown: 
    248251                # text event 
     
    256259                    if is_moved: 
    257260                        self.canvas.draw() 
    258                 except: 
    259                     logger.error(sys.exc_value) 
     261                except Exception as exc: 
     262                    logger.error(exc) 
    260263                event.Skip() 
    261264                return 
     
    410413            self.canvas.draw() 
    411414            self.q_ctrl[vl_ind].SetValue(str(pos_x)) 
    412         except: 
    413             logger.error(sys.exc_value) 
     415        except Exception as exc: 
     416            logger.error(exc) 
    414417 
    415418    def set_resizing(self, resizing=False): 
     
    431434            Remove data from plot 
    432435        """ 
    433         if id in self.plots.keys(): 
     436        if id in self.plots: 
    434437            data = self.plots[id] 
    435438            self.graph.delete(data) 
     
    437440            data_list, theory_list = data_manager.get_by_id(id_list=[id]) 
    438441 
    439             if id in data_list.keys(): 
     442            if id in data_list: 
    440443                data = data_list[id] 
    441             if id in theory_list.keys(): 
     444            if id in theory_list: 
    442445                data = theory_list[id] 
    443446 
     
    457460        if data.__class__.__name__ == 'Data2D': 
    458461            return 
    459         plot_keys = self.plots.keys() 
     462        plot_keys = list(self.plots.keys()) 
    460463        if data.id in plot_keys: 
    461464            # Recover panel prop.s 
     
    476479            try: 
    477480                self._onEVT_FUNC_PROPERTY() 
    478             except Exception, exc: 
     481            except Exception as exc: 
    479482                wx.PostEvent(self.parent, 
    480483                             StatusEvent(status="Plotting Error: %s" % str(exc), info="error")) 
     
    493496                    # MAC: forcing to plot 2D avg 
    494497                    self.canvas._onDrawIdle() 
    495             except Exception, exc: 
     498            except Exception as exc: 
    496499                wx.PostEvent(self.parent, StatusEvent(status=\ 
    497500                    "Plotting Error: %s" % str(exc), info="error")) 
     
    567570        self.set_selected_from_menu(menu, event_id) 
    568571        ## Check if there is a selected graph to remove 
    569         if self.graph.selected_plottable in self.plots.keys(): 
     572        if self.graph.selected_plottable in self.plots: 
    570573            graph_id = self.graph.selected_plottable 
    571574            self.remove_data_by_id(graph_id) 
     
    603606            plot_menu = wx.Menu() 
    604607            if self.graph.selected_plottable: 
    605                 if not self.graph.selected_plottable in self.plots.keys(): 
     608                if not self.graph.selected_plottable in self.plots: 
    606609                    continue 
    607610                if plot != self.plots[self.graph.selected_plottable]: 
     
    623626                        plot_menu.Append(wx_id, item[0], name) 
    624627                        wx.EVT_MENU(self, wx_id, item[2]) 
    625                     except: 
     628                    except Exception as exc: 
    626629                        msg = "ModelPanel1D.onContextMenu: " 
    627                         msg += "bad menu item  %s" % sys.exc_value 
     630                        msg += "bad menu item  %s" % exc 
    628631                        wx.PostEvent(self.parent, StatusEvent(status=msg)) 
    629632                plot_menu.AppendSeparator() 
  • src/sas/sasgui/guiframe/local_perspectives/plotting/Plotter2D.py

    r3e5648b r5251ec6  
    1111 
    1212 
    13 import wx 
    1413import sys 
    1514import math 
     15import logging 
     16 
     17import wx 
    1618import numpy as np 
    17 import logging 
     19from matplotlib.font_manager import FontProperties 
     20 
    1821from sas.sasgui.plottools.PlotPanel import PlotPanel 
    1922from sas.sasgui.plottools.plottables import Graph 
     
    2427from sas.sasgui.guiframe.events import SlicerEvent 
    2528from sas.sasgui.guiframe.utils import PanelMenu 
    26 from  sas.sasgui.guiframe.local_perspectives.plotting.binder import BindArtist 
    27 from Plotter1D import ModelPanel1D 
     29from sas.sasgui.guiframe.local_perspectives.plotting.binder import BindArtist 
    2830from sas.sasgui.plottools.toolbar import NavigationToolBar 
    29 from matplotlib.font_manager import FontProperties 
    30 from graphAppearance import graphAppearance 
     31 
     32from .Plotter1D import ModelPanel1D 
     33from .graphAppearance import graphAppearance 
     34 
    3135(InternalEvent, EVT_INTERNAL) = wx.lib.newevent.NewEvent() 
    3236 
     
    4145def find_key(dic, val): 
    4246    """return the key of dictionary dic given the value""" 
    43     return [k for k, v in dic.iteritems() if v == val][0] 
     47    return [k for k, v in dic.items() if v == val][0] 
    4448 
    4549 
     
    200204        ## Update self.data2d with the current plot 
    201205        self.data2D = data 
    202         if data.id in self.plots.keys(): 
     206        if data.id in self.plots: 
    203207            #replace 
    204208            xlo, xhi = self.subplot.get_xlim() 
     
    326330                        slicerpop.Append(wx_id, item[0], item[1]) 
    327331                        wx.EVT_MENU(self, wx_id, item[2]) 
    328                     except: 
     332                    except Exception as exc: 
    329333                        msg = "ModelPanel1D.onContextMenu: " 
    330                         msg += "bad menu item  %s" % sys.exc_value 
     334                        msg += "bad menu item  %s" % exc 
    331335                        wx.PostEvent(self.parent, StatusEvent(status=msg)) 
    332336                slicerpop.AppendSeparator() 
     
    447451 
    448452        """ 
    449         import detector_dialog 
     453        from . import detector_dialog 
    450454        dialog = detector_dialog.DetectorDialog(self, -1, base=self.parent, 
    451455                                                reset_zmin_ctl=self.default_zmin_ctl, 
     
    630634        """ 
    631635        if self.slicer is not None: 
    632             from parameters_panel_slicer import SlicerParameterPanel 
     636            from .parameters_panel_slicer import SlicerParameterPanel 
    633637            dialog = SlicerParameterPanel(self, -1, "Slicer Parameters") 
    634638            dialog.set_slicer(self.slicer.__class__.__name__, 
     
    641645        Perform sector averaging on Q and draw sector slicer 
    642646        """ 
    643         from SectorSlicer import SectorInteractor 
     647        from .SectorSlicer import SectorInteractor 
    644648        self.onClearSlicer(event) 
    645649        wx.PostEvent(self, InternalEvent(slicer=SectorInteractor)) 
     
    649653        Perform sector averaging on Phi and draw annulus slicer 
    650654        """ 
    651         from AnnulusSlicer import AnnulusInteractor 
     655        from .AnnulusSlicer import AnnulusInteractor 
    652656        self.onClearSlicer(event) 
    653657        wx.PostEvent(self, InternalEvent(slicer=AnnulusInteractor)) 
     
    657661        """ 
    658662        from sas.sasgui.guiframe.gui_manager import MDIFrame 
    659         from boxSum import BoxSum 
     663        from .boxSum import BoxSum 
    660664        self.onClearSlicer(event) 
    661665        self.slicer_z += 1 
     
    668672        params = self.slicer.get_params() 
    669673        ## Create a new panel to display results of summation of Data2D 
    670         from parameters_panel_boxsum import SlicerPanel 
     674        from .parameters_panel_boxsum import SlicerPanel 
    671675        win = MDIFrame(self.parent, None, 'None', (100, 200)) 
    672676        new_panel = SlicerPanel(parent=win, id=-1, 
     
    699703        :param event: wx.menu event 
    700704        """ 
    701         from boxSlicer import BoxInteractorX 
     705        from .boxSlicer import BoxInteractorX 
    702706        self.onClearSlicer(event) 
    703707        wx.PostEvent(self, InternalEvent(slicer=BoxInteractorX)) 
     
    711715 
    712716        """ 
    713         from boxSlicer import BoxInteractorY 
     717        from .boxSlicer import BoxInteractorY 
    714718        self.onClearSlicer(event) 
    715719        wx.PostEvent(self, InternalEvent(slicer=BoxInteractorY)) 
  • src/sas/sasgui/guiframe/local_perspectives/plotting/SectorSlicer.py

    r8de66b6 r5251ec6  
    33""" 
    44import math 
     5 
    56import wx 
    6 from BaseInteractor import _BaseInteractor 
     7 
    78from sas.sasgui.guiframe.events import NewPlotEvent 
    89from sas.sasgui.guiframe.events import StatusEvent 
     
    1011from sas.sasgui.guiframe.events import EVT_SLICER_PARS 
    1112from sas.sasgui.guiframe.dataFitting import Data1D 
     13 
     14from .BaseInteractor import _BaseInteractor 
    1215 
    1316 
     
    238241            msg = "Phi left and phi right are different" 
    239242            msg += " %f, %f" % (self.left_line.phi, self.right_line.phi) 
    240             raise ValueError, msg 
     243            raise ValueError(msg) 
    241244        params["Phi [deg]"] = self.main_line.theta * 180 / math.pi 
    242245        params["Delta_Phi [deg]"] = math.fabs(self.left_line.phi * 180 / math.pi) 
  • src/sas/sasgui/guiframe/local_perspectives/plotting/appearanceDialog.py

    rd85c194 r5251ec6  
    153153        Populate Symbols 
    154154        """ 
    155         self.sorted_symbo_labels = sorted(self.symbo_labels.iteritems(), 
     155        self.sorted_symbo_labels = sorted(self.symbo_labels.items(), 
    156156                                          key=operator.itemgetter(1)) 
    157157        self.sorted_sym_dic = {} 
     
    166166        Populate Colors 
    167167        """ 
    168         sortedcolor_labels = sorted(self.color_labels.iteritems(), 
     168        sortedcolor_labels = sorted(self.color_labels.items(), 
    169169                                    key=operator.itemgetter(1)) 
    170170        for color in sortedcolor_labels: 
     
    197197        Find key 
    198198        """ 
    199         return [k for k, v in dic.iteritems() if v == val][0] 
     199        return [k for k, v in dic.items() if v == val][0] 
    200200 
    201201    def get_current_values(self): 
  • src/sas/sasgui/guiframe/local_perspectives/plotting/binder.py

    r20fa5fe r5251ec6  
    22Extension to MPL to support the binding of artists to key/mouse events. 
    33""" 
     4from __future__ import print_function 
     5 
     6import sys 
    47import logging 
    5 import sys 
    68 
    79logger = logging.getLogger(__name__) 
     
    1618    artist = None 
    1719    prop = {} 
     20 
    1821    def __init__(self, artist=None, prop={}): 
    1922        self.artist, self.prop = artist, self.prop 
     
    2528        return self.artist is not other.artist 
    2629 
    27     def __nonzero__(self): 
     30    def __bool__(self): 
    2831        return self.artist is not None 
     32 
     33    __nonzero__ = __bool__ 
     34 
    2935 
    3036class BindArtist(object): 
    3137    """ 
    32         Track keyboard modifiers for events. 
    33         TODO: Move keyboard modifier support into the backend.  We cannot 
    34         TODO: properly support it from outside the windowing system since there 
    35         TODO: is no way to recognized whether shift is held down when the mouse 
    36         TODO: first clicks on the the application window. 
     38    Track keyboard modifiers for events. 
    3739    """ 
     40    # TODO: Move keyboard modifier support into the backend.  We cannot 
     41    # TODO: properly support it from outside the windowing system since there 
     42    # TODO: is no way to recognized whether shift is held down when the mouse 
     43    # TODO: first clicks on the the application window. 
    3844    control, shift, alt, meta = False, False, False, False 
    3945 
     
    4652              'scroll', 'key', 'keyup'] 
    4753    # TODO: Need our own event structure 
     54 
    4855    def __init__(self, figure): 
    4956        canvas = figure.canvas 
     57 
    5058        # Link to keyboard/mouse 
    5159        try: 
     
    5967            ] 
    6068        except: 
    61             # print "bypassing scroll_event: wrong matplotlib version" 
     69            logger.warn("bypassing scroll_event: wrong matplotlib version") 
    6270            self._connections = [ 
    6371                canvas.mpl_connect('motion_notify_event', self._onMotion), 
     
    6775                canvas.mpl_connect('key_release_event', self._onKeyRelease), 
    6876            ] 
     77 
    6978        # Turn off picker if it hasn't already been done 
    7079        try: 
    7180            canvas.mpl_disconnect(canvas.button_pick_id) 
    7281            canvas.mpl_disconnect(canvas.scroll_pick_id) 
    73         except: 
    74             logger.error(sys.exc_value) 
     82        except Exception as exc: 
     83            logger.error(exc) 
     84 
     85        self._current = None 
     86        self._actions = {} 
    7587        self.canvas = canvas 
    7688        self.figure = figure 
     
    8395 
    8496        Use clearall() to reset all connections. 
    85  
    8697        """ 
    8798        for h in artists: 
     
    108119        for action in self.events: 
    109120            self._actions[action] = {} 
     121 
    110122        # Need activity state 
    111123        self._artists = [] 
     
    121133            for cid in self._connections: 
    122134                self.canvas.mpl_disconnect(cid) 
    123         except: 
    124             pass 
     135        except Exception as exc: 
     136            logger.error("Error disconnection canvas: %s" % exc) 
    125137        self._connections = [] 
    126138 
     
    169181        sure it applies.  E.g., the callback for 'press' might be: 
    170182            if event.button == 1 and event.shift: process Shift-click 
    171  
    172         :TODO: Only receive events with the correct modifiers (e.g., S-click, 
    173         :TODO:   or *-click for any modifiers). 
    174         :TODO: Only receive button events for the correct button (e.g., click1 
    175         :TODO:   release3, or dclick* for any button) 
    176         :TODO: Support virtual artist, so that and artist can be flagged as 
    177         :TODO:   having a tag list and receive the correct events 
    178         :TODO: Support virtual events for binding to button-3 vs shift button-1 
    179         :TODO:   without changing callback code 
    180         :TODO: Attach multiple callbacks to the same event? 
    181         :TODO: Clean up interaction with toolbar modes 
    182         :TODO: push/pushclear/pop context so that binding changes 
    183             for the duration 
    184         :TODO:   e.g., to support ? context sensitive help 
    185  
    186         """ 
     183        """ 
     184        #TODO: Only receive events with the correct modifiers (e.g., S-click, 
     185        #TODO:   or *-click for any modifiers). 
     186        #TODO: Only receive button events for the correct button (e.g., click1 
     187        #TODO:   release3, or dclick* for any button) 
     188        #TODO: Support virtual artist, so that and artist can be flagged as 
     189        #TODO:   having a tag list and receive the correct events 
     190        #TODO: Support virtual events for binding to button-3 vs shift button-1 
     191        #TODO:   without changing callback code 
     192        #TODO: Attach multiple callbacks to the same event? 
     193        #TODO: Clean up interaction with toolbar modes 
     194        #TODO: push/pushclear/pop context so that binding changes for the duration 
     195        #TODO:   e.g., to support ? context sensitive help 
     196 
    187197        # Check that the trigger is valid 
    188198        if trigger not in self._actions: 
    189             raise ValueError, "%s invalid --- valid triggers are %s" \ 
    190                 % (trigger, ", ".join(self.events)) 
     199            raise ValueError("%s invalid --- valid triggers are %s" 
     200                % (trigger, ", ".join(self.events))) 
     201 
    191202        # Register the trigger callback 
    192203        self._actions[trigger][artist] = action 
    193         # print "==> added",artist,[artist],"to",trigger,":", 
    194         # self._actions[trigger].keys() 
     204 
    195205        # Maintain a list of all artists 
    196206        if artist not in self._artists: 
     
    203213        """ 
    204214        if action not in self.events: 
    205             raise ValueError, "Trigger expects " + ", ".join(self.events) 
     215            raise ValueError("Trigger expects " + ", ".join(self.events)) 
     216 
    206217        # Tag the event with modifiers 
    207218        for mod in ('alt', 'control', 'shift', 'meta'): 
     
    210221        setattr(ev, 'action', action) 
    211222        setattr(ev, 'prop', {}) 
     223 
    212224        # Fallback scheme. If the event does not return false, pass to parent. 
    213225        processed = False 
     
    233245        """ 
    234246        # TODO: sort by zorder of axes then by zorder within axes 
    235         self._artists.sort(cmp=lambda x, y: cmp(y.zorder, x.zorder)) 
    236         # print "search"," ".join([str(h) for h in self._artists]) 
     247        self._artists.sort(key=lambda x: x.zorder, reverse=True) 
    237248        found = Selection() 
    238         # print "searching in",self._artists 
    239249        for artist in self._artists: 
    240250            # TODO: should contains() return false if invisible? 
     
    250260                found.artist, found.prop = artist, prop 
    251261                break 
    252         # print "found",found.artist 
    253262 
    254263        # TODO: how to check if prop is equal? 
     
    257266            self.trigger(found, 'enter', event) 
    258267        self._current = found 
     268 
    259269        return found 
    260270 
     
    274284 
    275285            transform = self._hasclick.artist.get_transform() 
    276             # x,y = event.xdata,event.ydata 
     286            #x,y = event.xdata,event.ydata 
    277287            x, y = event.x, event.y 
    278288            try: 
    279289                x, y = transform.inverted().transform_point((x, y)) 
    280  
    281             except: 
     290            except: # CRUFT: matplotlib-0.91 support 
    282291                x, y = transform.inverse_xy_tup((x, y)) 
     292 
    283293            event.xdata, event.ydata = x, y 
    284294            self.trigger(self._hasclick, 'drag', event) 
    285295        else: 
    286296            found = self._find_current(event) 
    287             # print "found",found.artist 
    288297            self.trigger(found, 'motion', event) 
    289298 
     
    296305        # Check for double-click 
    297306        event_time = time.time() 
    298         # print event_time,self._last_time,self.dclick_threshhold 
    299         # print (event_time > self._last_time + self.dclick_threshhold) 
    300         # print event.button,self._last_button 
    301307        if (event.button != self._last_button) or \ 
    302308                (event_time > self._last_time + self.dclick_threshhold): 
     
    381387            setattr(self, event.key, False) 
    382388            return 
     389 
    383390        if self._haskey: 
    384391            self.trigger(self._haskey, 'keyup', event) 
     
    391398        found = self._find_current(event) 
    392399        self.trigger(found, 'scroll', event) 
    393  
  • src/sas/sasgui/guiframe/local_perspectives/plotting/boxMask.py

    r7432acb r5251ec6  
    11import math 
    2 from BaseInteractor import _BaseInteractor 
    3 from boxSum import PointInteractor 
    4 from boxSum import VerticalDoubleLine 
    5 from boxSum import HorizontalDoubleLine 
     2from .BaseInteractor import _BaseInteractor 
     3from .boxSum import PointInteractor 
     4from .boxSum import VerticalDoubleLine 
     5from .boxSum import HorizontalDoubleLine 
    66 
    77 
  • src/sas/sasgui/guiframe/local_perspectives/plotting/boxSlicer.py

    r20fa5fe r5251ec6  
     1import math 
     2 
    13import wx 
    2 import math 
    34import numpy as np 
     5 
    46from sas.sasgui.guiframe.events import NewPlotEvent 
    57from sas.sasgui.guiframe.events import StatusEvent 
    68from sas.sasgui.guiframe.events import SlicerParameterEvent 
    79from sas.sasgui.guiframe.events import EVT_SLICER_PARS 
    8 from BaseInteractor import _BaseInteractor 
    910from sas.sasgui.guiframe.dataFitting import Data1D 
     11 
     12from .BaseInteractor import _BaseInteractor 
    1013 
    1114 
     
    152155            if new_slab is None: 
    153156                msg = "post data:cannot average , averager is empty" 
    154                 raise ValueError, msg 
     157                raise ValueError(msg) 
    155158            self.averager = new_slab 
    156159        if self.direction == "X": 
     
    168171        else: 
    169172            msg = "post data:no Box Average direction was supplied" 
    170             raise ValueError, msg 
     173            raise ValueError(msg) 
    171174        # # Average data2D given Qx or Qy 
    172175        box = self.averager(x_min=x_min, x_max=x_max, y_min=y_min, y_max=y_max, 
  • src/sas/sasgui/guiframe/local_perspectives/plotting/boxSum.py

    r7432acb r5251ec6  
    44""" 
    55import math 
     6 
    67import wx 
    7 from BaseInteractor import _BaseInteractor 
     8 
    89from sas.sasgui.guiframe.events import SlicerParamUpdateEvent 
    910from sas.sasgui.guiframe.events import EVT_SLICER_PARS 
    1011from sas.sasgui.guiframe.events import StatusEvent 
     12 
     13from .BaseInteractor import _BaseInteractor 
    1114 
    1215 
  • src/sas/sasgui/guiframe/local_perspectives/plotting/detector_dialog.py

    r7432acb r5251ec6  
    9999            self.cmap_selector.SetStringSelection("jet") 
    100100            self._on_select_cmap(event=None) 
    101         except: 
    102             msg = "error occurs while resetting Detector: %s" % sys.exc_value 
     101        except Exception as exc: 
     102            msg = "error occurs while resetting Detector: %s" % exc 
    103103            wx.PostEvent(self.parent, StatusEvent(status=msg)) 
    104104 
  • src/sas/sasgui/guiframe/local_perspectives/plotting/masking.py

    r20fa5fe r5251ec6  
    1818 
    1919# #Todo: cleaning up, improving the maskplotpanel initialization, and testing. 
    20 import wx 
    2120import sys 
    2221import time 
    23 import matplotlib.cm as cm 
    2422import math 
    2523import copy 
     24from functools import partial 
     25 
     26import wx 
    2627import numpy as np 
     28import matplotlib.cm as cm 
     29 
    2730from sas.sasgui.plottools.PlotPanel import PlotPanel 
    2831from sas.sasgui.plottools.plottables import Graph 
    29 from binder import BindArtist 
    3032from sas.sasgui.guiframe.dataFitting import Data1D, Data2D 
    31 from boxMask import BoxMask 
    32 from sector_mask import SectorMask 
    33 from AnnulusSlicer import CircularMask 
    34  
    3533from sas.sasgui.guiframe.events import SlicerEvent 
    3634from sas.sasgui.guiframe.events import StatusEvent 
    37 from functools import partial 
     35 
     36from .binder import BindArtist 
     37from .boxMask import BoxMask 
     38from .sector_mask import SectorMask 
     39from .AnnulusSlicer import CircularMask 
     40 
    3841 
    3942(InternalEvent, EVT_INTERNAL) = wx.lib.newevent.NewEvent() 
  • src/sas/sasgui/guiframe/local_perspectives/plotting/parameters_panel_boxsum.py

    r37d461c r5251ec6  
    11import wx 
    22import wx.lib.newevent 
    3 from parameters_panel_slicer import SlicerParameterPanel 
     3 
    44from sas.sasgui.guiframe.utils import format_number 
    55from sas.sasgui.guiframe.panel_base import PanelBase 
     
    77                                        EVT_SLICER) 
    88 
     9from .parameters_panel_slicer import SlicerParameterPanel 
    910 
    1011class SlicerPanel(wx.Panel, PanelBase): 
     
    6465            n = 1 
    6566            self.parameters = [] 
    66             keys = params.keys() 
    67             keys.sort() 
     67            keys = list(sorted(params.keys())) 
    6868            for item in keys: 
    6969                if not item.lower() in ["num_points", "avg", "avg_error", "sum", 
  • src/sas/sasgui/guiframe/local_perspectives/plotting/parameters_panel_slicer.py

    ra20a255 r5251ec6  
    22 
    33import os 
     4 
    45import wx 
    56import wx.lib.newevent 
     7 
    68from sas.sascalc.dataloader.readers.cansas_reader import Reader 
    79from sas.sasgui.guiframe.utils import format_number 
    810from sas.sasgui.guiframe.events import EVT_SLICER_PARS, EVT_SLICER 
    911from sas.sasgui.guiframe.events import SlicerParameterEvent, StatusEvent 
    10 from Plotter2D import ModelPanel2D 
     12 
     13from .Plotter2D import ModelPanel2D 
     14 
    1115apply_params, EVT_APPLY_PARAMS = wx.lib.newevent.NewEvent() 
    1216save_files, EVT_AUTO_SAVE = wx.lib.newevent.NewEvent() 
     
    100104            iy = 1 
    101105            self.parameters = [] 
    102             keys = params.keys() 
    103             keys.sort() 
     106            keys = list(sorted(params.keys())) 
    104107            for item in keys: 
    105108                ix = 0 
     
    127130                    self.bck.Add(text, (iy, ix), (1, 1), 
    128131                                 wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) 
    129                     options = BINNING_OPTIONS.keys() 
     132                    options = list(BINNING_OPTIONS.keys()) 
    130133                    self.bin_ctl = wx.ComboBox(parent=self, choices=options) 
    131134                    hint_msg = "Modify the value of %s to change" % item 
     
    325328 
    326329        # Find desired 2D data panels 
    327         for key, mgr in spp.plot_panels.iteritems(): 
     330        for key, mgr in spp.plot_panels.items(): 
    328331            if mgr.graph.prop['title'] in self.data_list.CheckedStrings: 
    329332                apply_to_list.append(mgr) 
     
    377380        self.loaded_data = [] 
    378381        # Iterate over the loaded plots and find all 2D panels 
    379         for key, value in self.main_window.plot_panels.iteritems(): 
     382        for key, value in self.main_window.plot_panels.items(): 
    380383            if isinstance(value, ModelPanel2D): 
    381384                self.loaded_data.append(value.data2D.name) 
     
    453456 
    454457        # Find the correct plots to save 
    455         for key, plot in self.main_window.plot_panels.iteritems(): 
     458        for key, plot in self.main_window.plot_panels.items(): 
    456459            if not hasattr(plot, "data2D"): 
    457460                for item in plot.plots: 
     
    461464 
    462465        # Save files as Text 
    463         for item, data1d in data_dic.iteritems(): 
     466        for item, data1d in data_dic.items(): 
    464467            base = '.'.join(item.split('.')[:-1]) 
    465468            file_name = base + append + ".txt" 
  • src/sas/sasgui/guiframe/local_perspectives/plotting/plotting.py

    r2d9526d r5251ec6  
    1212################################################################################ 
    1313 
    14 import wx 
    1514import sys 
    1615from copy import deepcopy 
     16 
     17import wx 
     18 
    1719from sas.sasgui.guiframe.events import EVT_NEW_PLOT 
    1820from sas.sasgui.guiframe.events import EVT_PLOT_QRANGE 
     
    2325from sas.sasgui.guiframe.dataFitting import Data2D 
    2426from sas.sasgui.guiframe.gui_manager import MDIFrame 
     27 
    2528DEFAULT_MENU_ITEM_LABEL = "No graph available" 
    2629DEFAULT_MENU_ITEM_ID = wx.NewId() 
     
    9194        if event is None: 
    9295            return 
    93         if event.id in self.plot_panels.keys(): 
     96        if event.id in self.plot_panels: 
    9497            panel = self.plot_panels[event.id] 
    95         elif event.group_id in self.plot_panels.keys(): 
     98        elif event.group_id in self.plot_panels: 
    9699            panel = self.plot_panels[event.group_id] 
    97100        else: 
     
    102105        if event is None: 
    103106            return 
    104         if event.id in self.plot_panels.keys(): 
     107        if event.id in self.plot_panels: 
    105108            panel = self.plot_panels[event.id] 
    106         elif event.group_id in self.plot_panels.keys(): 
     109        elif event.group_id in self.plot_panels: 
    107110            panel = self.plot_panels[event.group_id] 
    108111        else: 
     
    123126        """ 
    124127 
    125         if group_id in self.plot_panels.keys(): 
     128        if group_id in self.plot_panels: 
    126129            panel = self.plot_panels[group_id] 
    127130            panel.remove_data_by_id(id=id) 
     
    134137        Clear and Hide all plot panels, and remove them from menu 
    135138        """ 
    136         for group_id in self.plot_panels.keys(): 
     139        for group_id in self.plot_panels: 
    137140            self.clear_panel_by_id(group_id) 
    138141        self.plot_panels = {} 
     
    142145        clear the graph 
    143146        """ 
    144         if group_id in self.plot_panels.keys(): 
     147        if group_id in self.plot_panels: 
    145148            panel = self.plot_panels[group_id] 
    146149            for plottable in panel.graph.plottables.keys(): 
     
    184187        # Create a new plot panel if none was available 
    185188        if issubclass(data.__class__, Data1D): 
    186             from Plotter1D import ModelPanel1D 
     189            from .Plotter1D import ModelPanel1D 
    187190            ## get the data representation label of the data to plot 
    188191            ## when even the user select "change scale" 
     
    200203 
    201204        msg = "1D Panel of group ID %s could not be created" % str(group_id) 
    202         raise ValueError, msg 
     205        raise ValueError(msg) 
    203206 
    204207    def create_2d_panel(self, data, group_id): 
     
    207210        if issubclass(data.__class__, Data2D): 
    208211            ##Create a new plotpanel for 2D data 
    209             from Plotter2D import ModelPanel2D 
     212            from .Plotter2D import ModelPanel2D 
    210213            scale = data.scale 
    211214            win = MDIFrame(self.parent, None, 'None', (200, 150)) 
     
    218221            return new_panel 
    219222        msg = "2D Panel of group ID %s could not be created" % str(group_id) 
    220         raise ValueError, msg 
     223        raise ValueError(msg) 
    221224 
    222225    def update_panel(self, data, panel): 
     
    238241            msg += " to panel %s\n" % str(panel.window_caption) 
    239242            msg += "Please edit %s's units, labels" % str(data.name) 
    240             raise ValueError, msg 
     243            raise ValueError(msg) 
    241244        else: 
    242245            if panel.group_id not in data.list_group_id: 
     
    247250        """ 
    248251        """ 
    249         if group_id in self.plot_panels.keys(): 
     252        if group_id in self.plot_panels: 
    250253            panel = self.plot_panels[group_id] 
    251254            uid = panel.uid 
     
    254257                                              caption=panel.window_caption)) 
    255258            del self.plot_panels[group_id] 
    256             if uid in self.parent.plot_panels.keys(): 
     259            if uid in self.parent.plot_panels: 
    257260                del self.parent.plot_panels[uid] 
    258261                panel.frame.Destroy() 
     
    280283                    for data in event.plots: 
    281284                        for panel in self.plot_panels.values(): 
    282                             if data.id in panel.plots.keys(): 
     285                            if data.id in panel.plots: 
    283286                                plot_exists = True 
    284287                                # Pass each panel it's own copy of the data 
     
    310313        data = event.plot 
    311314        group_id = data.group_id 
    312         if group_id in self.plot_panels.keys(): 
     315        if group_id in self.plot_panels: 
    313316            if action_check: 
    314317                # Check if the plot already exist. if it does, do nothing. 
    315                 if data.id in self.plot_panels[group_id].plots.keys(): 
     318                if data.id in self.plot_panels[group_id].plots: 
    316319                    return 
    317320            #update a panel graph 
     
    327330                    for p_group_id in self.plot_panels.keys(): 
    328331                        p_plot = self.plot_panels[p_group_id] 
    329                         if data.id in p_plot.plots.keys(): 
     332                        if data.id in p_plot.plots: 
    330333                            p_plot.plots[data.id] = data 
    331334                            self.plot_panels[group_id] = p_plot 
  • src/sas/sasgui/guiframe/local_perspectives/plotting/sector_mask.py

    r7432acb r5251ec6  
    33""" 
    44import math 
     5 
    56import wx 
    6 #from copy import deepcopy 
    7 from BaseInteractor import _BaseInteractor 
    8 from SectorSlicer import SideInteractor 
    9 from SectorSlicer import LineInteractor 
     7 
    108from sas.sasgui.guiframe.events import SlicerParameterEvent 
     9 
     10from .BaseInteractor import _BaseInteractor 
     11from .SectorSlicer import SideInteractor 
     12from .SectorSlicer import LineInteractor 
    1113 
    1214class SectorMask(_BaseInteractor): 
     
    175177            msg += "different %f, %f" % (self.left_line.phi, 
    176178                                         self.right_line.phi) 
    177             raise ValueError, msg 
     179            raise ValueError(msg) 
    178180        params["Phi"] = self.main_line.theta 
    179181        params["Delta_Phi"] = math.fabs(self.left_line.phi) 
  • src/sas/sasgui/guiframe/plugin_base.py

    r20fa5fe r5251ec6  
    112112        Load  data 
    113113        """ 
    114         raise NotImplementedError 
     114        raise NotImplementedError() 
    115115 
    116116    def load_folder(self, event): 
     
    118118        Load entire folder 
    119119        """ 
    120         raise NotImplementedError 
     120        raise NotImplementedError() 
    121121 
    122122    def set_is_active(self, active=False): 
     
    277277        """ 
    278278        msg = "%s plugin: does not support import theory" % str(self.sub_menu) 
    279         raise ValueError, msg 
     279        raise ValueError(msg) 
    280280 
    281281    def on_set_state_helper(self, event): 
  • src/sas/sasgui/guiframe/proxy.py

    r20fa5fe r5251ec6  
    33from __future__ import print_function 
    44 
    5 import urllib2 
    65import sys 
    76import json 
     
    98import re 
    109 
     10try: 
     11    # CRUFT: python 3 uses urllib.request instead of urllib2 
     12    import urllib2 
     13except ImportError: 
     14    from urllib import request as urllib2 
    1115 
    1216logger = logging.getLogger(__name__) 
     
    5054                this_name, this_val, this_type = winreg.EnumValue(net, i) 
    5155                subkeys[this_name] = this_val 
    52             if 'AutoConfigURL' in subkeys.keys() and len(subkeys['AutoConfigURL']) > 0: 
     56            if 'AutoConfigURL' in subkeys and len(subkeys['AutoConfigURL']) > 0: 
    5357                pac_files.append(subkeys['AutoConfigURL']) 
    5458        elif sys.platform == 'darwin': 
     
    6165                # the first part is a long identifier 
    6266                net_key, network = network 
    63                 if 'ProxyAutoConfigURLString' in network['Proxies'].keys(): 
     67                if 'ProxyAutoConfigURLString' in network['Proxies']: 
    6468                    pac_files.append( 
    6569                        network['Proxies']['ProxyAutoConfigURLString']) 
     
    127131            logger.debug("Trying Direct connection to %s..."%self.url) 
    128132            response = urllib2.urlopen(req, timeout=self.timeout) 
    129         except Exception, e: 
     133        except Exception as exc: 
    130134            logger.debug("Failed!") 
    131             logger.debug(e) 
     135            logger.debug(exc) 
    132136            try: 
    133137                logger.debug("Trying to use system proxy if it exists...") 
    134138                self._set_proxy() 
    135139                response = urllib2.urlopen(req, timeout=self.timeout) 
    136             except Exception, e: 
     140            except Exception as exc: 
    137141                logger.debug("Failed!") 
    138                 logger.debug(e) 
     142                logger.debug(exc) 
    139143                pac_urls = self._get_addresses_of_proxy_pac() 
    140144                proxy_urls = self._parse_proxy_pac(pac_urls) 
     
    144148                        self._set_proxy(proxy) 
    145149                        response = urllib2.urlopen(req, timeout=self.timeout) 
    146                     except Exception, e: 
     150                    except Exception as exc: 
    147151                        logger.debug("Failed!") 
    148                         logger.debug(e) 
     152                        logger.debug(exc) 
    149153        if response is not None: 
    150154            logger.debug("The connection to %s was successful."%self.url) 
  • src/sas/sasgui/guiframe/report_dialog.py

    rd0ce666f r5251ec6  
    147147            self.Update() 
    148148            return pisaStatus.err 
    149         except Exception: 
    150             logger.error("Error creating pdf: %s" % sys.exc_value) 
     149        except Exception as exc: 
     150            logger.error("Error creating pdf: %s" % exc) 
    151151        return False 
  • src/sas/sasgui/guiframe/startup_configuration.py

    rb963b20 r5251ec6  
    197197        with open(path, 'w') as out_f: 
    198198            out_f.write("#Application appearance custom configuration\n") 
    199             for key, item in self.return_string.iteritems(): 
     199            for key, item in self.return_string.items(): 
    200200                if (key == 'DEFAULT_PERSPECTIVE') or \ 
    201201                    (key == 'DEFAULT_OPEN_FOLDER' and item != None): 
  • src/sas/sasgui/guiframe/utils.py

    r7432acb r5251ec6  
    208208        self.id_list = id_list 
    209209        self.index = -1 
    210     def next(self): 
     210    def __next__(self): 
    211211        self.index += 1 
    212212        return self.id_list[self.index] 
    213  
     213    # CRUFT: python 2 uses next rather than __next__ for iterator 
     214    next = __next__ 
     215 
Note: See TracChangeset for help on using the changeset viewer.