- Timestamp:
- Oct 26, 2017 3:13:05 AM (7 years ago)
- Branches:
- ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc
- Children:
- 895e7359
- Parents:
- def64a0
- Location:
- src/sas
- Files:
-
- 56 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/Calculators/DataOperationUtilityPanel.py
- Property mode changed from 100644 to 100755
r7d9c83c rb0b09b9 13 13 import sas.qtgui.Utilities.GuiUtils as GuiUtils 14 14 15 from UI.DataOperationUtilityUI import Ui_DataOperationUtility15 from .UI.DataOperationUtilityUI import Ui_DataOperationUtility 16 16 17 17 BG_WHITE = "background-color: rgb(255, 255, 255);" … … 76 76 self.filenames = filenames 77 77 78 if filenames.keys():78 if list(filenames.keys()): 79 79 # clear contents of comboboxes 80 80 self.cbData1.clear() … … 85 85 list_datafiles = [] 86 86 87 for key_id in filenames.keys():87 for key_id in list(filenames.keys()): 88 88 if filenames[key_id].get_data().title: 89 89 # filenames with titles … … 139 139 data1 = self.data1 140 140 data2 = self.data2 141 exec "output = data1 %s data2" % operator141 exec("output = data1 %s data2" % operator) 142 142 except: 143 143 raise … … 300 300 self.cbData1.setStyleSheet(QtCore.QString(BG_RED)) 301 301 self.cbData2.setStyleSheet(QtCore.QString(BG_RED)) 302 print self.data1.__class__.__name__ != self.data2.__class__.__name__302 print(self.data1.__class__.__name__ != self.data2.__class__.__name__) 303 303 logging.warning('Cannot compute data of different dimensions') 304 304 return False … … 354 354 def _findId(self, name): 355 355 """ find id of name in list of filenames """ 356 isinstance(name, basestring)357 358 for key_id in self.filenames.keys():356 isinstance(name, str) 357 358 for key_id in list(self.filenames.keys()): 359 359 # data with title 360 360 if self.filenames[key_id].get_data().title: -
src/sas/qtgui/Calculators/DensityPanel.py
- Property mode changed from 100644 to 100755
rb0c5e8c rb0b09b9 14 14 15 15 def enum(*sequential, **named): 16 enums = dict( zip(sequential, range(len(sequential))), **named)16 enums = dict(list(zip(sequential, list(range(len(sequential))))), **named) 17 17 return type('Enum', (), enums) 18 18 … … 95 95 96 96 def dataChanged(self, top, bottom): 97 for index in xrange(top.row(), bottom.row() + 1):97 for index in range(top.row(), bottom.row() + 1): 98 98 if index == MODEL.MOLECULAR_FORMULA: 99 99 molarMass = toMolarMass(self.model.item(MODEL.MOLECULAR_FORMULA).text()) -
src/sas/qtgui/Calculators/GenericScatteringCalculator.py
- Property mode changed from 100644 to 100755
rfef38e8 rb0b09b9 22 22 23 23 # Local UI 24 from UI.GenericScatteringCalculator import Ui_GenericScatteringCalculator24 from .UI.GenericScatteringCalculator import Ui_GenericScatteringCalculator 25 25 26 26 _Q1D_MIN = 0.001 … … 119 119 TODO Temporary solution to display information about option 'Ellipsoid' 120 120 """ 121 print "The option Ellipsoid has not been implemented yet."121 print("The option Ellipsoid has not been implemented yet.") 122 122 self.communicator.statusBarUpdateSignal.emit( 123 123 "The option Ellipsoid has not been implemented yet.") … … 165 165 self.reader.queue() 166 166 except (RuntimeError, IOError): 167 log_msg = "Generic SAS Calculator: %s" % sys.exc_ value167 log_msg = "Generic SAS Calculator: %s" % sys.exc_info()[1] 168 168 logging.info(log_msg) 169 169 raise … … 556 556 d.addCallback(self.plot_1_2d) 557 557 except: 558 log_msg = "{}. stop".format(sys.exc_ value)558 log_msg = "{}. stop".format(sys.exc_info()[1]) 559 559 logging.info(log_msg) 560 560 return … … 644 644 self.graph_num += 1 645 645 # TODO 646 print 'TRANSFER OF DATA TO MAIN PANEL TO BE IMPLEMENTED'646 print('TRANSFER OF DATA TO MAIN PANEL TO BE IMPLEMENTED') 647 647 return plot1D 648 648 else: … … 662 662 self.graph_num += 1 663 663 # TODO 664 print 'TRANSFER OF DATA TO MAIN PANEL TO BE IMPLEMENTED'664 print('TRANSFER OF DATA TO MAIN PANEL TO BE IMPLEMENTED') 665 665 return plot2D 666 666 … … 744 744 # II. Plot selective points in color 745 745 other_color = numpy.ones(len(pix_symbol), dtype='bool') 746 for key in color_dic.keys():746 for key in list(color_dic.keys()): 747 747 chosen_color = pix_symbol == key 748 748 if numpy.any(chosen_color): … … 758 758 # Get atom names not in the list 759 759 a_names = [symb for symb in pix_symbol \ 760 if symb not in color_dic.keys()]760 if symb not in list(color_dic.keys())] 761 761 a_name = a_names[0] 762 762 for name in a_names: -
src/sas/qtgui/Calculators/KiessigPanel.py
- Property mode changed from 100644 to 100755
rb0c5e8c rb0b09b9 3 3 4 4 from sas.qtgui.UI import main_resources_rc 5 from UI.KiessigPanel import Ui_KiessigPanel5 from .UI.KiessigPanel import Ui_KiessigPanel 6 6 import sas.qtgui.Utilities.GuiUtils as GuiUtils 7 7 -
src/sas/qtgui/Calculators/ResolutionCalculatorPanel.py
- Property mode changed from 100644 to 100755
r170e95d rb0b09b9 20 20 import re 21 21 22 from UI.ResolutionCalculatorPanelUI import Ui_ResolutionCalculatorPanel22 from .UI.ResolutionCalculatorPanelUI import Ui_ResolutionCalculatorPanel 23 23 24 24 _SOURCE_MASS = {'Alpha': 6.64465620E-24, … … 318 318 self, "Choose a spectral distribution file", "", 319 319 "All files (*.*)", 320 None,QtGui.QFileDialog.DontUseNativeDialog)320 QtGui.QFileDialog.DontUseNativeDialog) 321 321 322 322 if datafile is None or str(datafile) == '': … … 328 328 try: 329 329 basename = os.path.basename(datafile) 330 if basename not in self.spectrum_dic.keys():330 if basename not in list(self.spectrum_dic.keys()): 331 331 self.cbCustomSpectrum.addItem(basename) 332 332 … … 604 604 msg = "The numbers must be one or two (separated by ',')" 605 605 logging.info(msg) 606 raise RuntimeError , msg606 raise RuntimeError(msg) 607 607 608 608 return new_numbers_list … … 618 618 new_list = [float(t) for t in string_split] 619 619 except: 620 logging.error(sys.exc_ value)620 logging.error(sys.exc_info()[1]) 621 621 return new_list 622 622 … … 658 658 return out 659 659 except: 660 logging.error(sys.exc_ value)660 logging.error(sys.exc_info()[1]) 661 661 662 662 def _validate_q_input(self, qx, qy): -
src/sas/qtgui/Calculators/SldPanel.py
- Property mode changed from 100644 to 100755
rb0c5e8c rb0b09b9 15 15 16 16 def enum(*sequential, **named): 17 enums = dict( zip(sequential, range(len(sequential))), **named)17 enums = dict(list(zip(sequential, list(range(len(sequential))))), **named) 18 18 return type('Enum', (), enums) 19 19 … … 60 60 if len(formula.atoms) != 1: 61 61 raise NotImplementedError() 62 energy = xray_energy( formula.atoms.keys()[0].K_alpha)62 energy = xray_energy(list(formula.atoms.keys())[0].K_alpha) 63 63 return xray_sld_from_atoms( 64 64 sld_formula.atoms, … … 142 142 self.model.setItem(MODEL.WAVELENGTH , QtGui.QStandardItem()) 143 143 144 for key in self._getOutputs().keys():144 for key in list(self._getOutputs().keys()): 145 145 self.model.setItem(key, QtGui.QStandardItem()) 146 146 … … 161 161 self.mapper.addMapping(self.ui.editWavelength , MODEL.WAVELENGTH) 162 162 163 for key, edit in self._getOutputs().ite ritems():163 for key, edit in self._getOutputs().items(): 164 164 self.mapper.addMapping(edit, key) 165 165 … … 168 168 def dataChanged(self, top, bottom): 169 169 update = False 170 for index in xrange(top.row(), bottom.row() + 1):170 for index in range(top.row(), bottom.row() + 1): 171 171 if (index == MODEL.MOLECULAR_FORMULA) or (index == MODEL.MASS_DENSITY) or (index == MODEL.WAVELENGTH): 172 172 update = True … … 202 202 pass 203 203 204 for key in self._getOutputs().keys():204 for key in list(self._getOutputs().keys()): 205 205 self.model.item(key).setText("") 206 206 -
src/sas/qtgui/Calculators/SlitSizeCalculator.py
- Property mode changed from 100644 to 100755
rf4a1433 rb0b09b9 11 11 import sas.qtgui.Utilities.GuiUtils as GuiUtils 12 12 13 from UI.SlitSizeCalculator import Ui_SlitSizeCalculator13 from .UI.SlitSizeCalculator import Ui_SlitSizeCalculator 14 14 from sas.sascalc.dataloader.loader import Loader 15 15 from sas.sascalc.calculator.slit_length_calculator import SlitlengthCalculator … … 76 76 # But only with Qt built-in dialog (non-platform native) 77 77 path = QtGui.QFileDialog.getOpenFileName(self, "Choose a file", "", 78 "SAXSess 1D data (*.txt *.TXT *.dat *.DAT)", None,78 "SAXSess 1D data (*.txt *.TXT *.dat *.DAT)", 79 79 QtGui.QFileDialog.DontUseNativeDialog) 80 80 … … 107 107 self.clearResults() 108 108 msg = "ERROR: Data hasn't been loaded correctly" 109 raise RuntimeError , msg109 raise RuntimeError(msg) 110 110 111 111 if data.__class__.__name__ == 'Data2D': 112 112 self.clearResults() 113 113 msg = "Slit Length cannot be computed for 2D Data" 114 raise RuntimeError , msg114 raise RuntimeError(msg) 115 115 116 116 #compute the slit size … … 120 120 if xdata == [] or xdata is None or ydata == [] or ydata is None: 121 121 msg = "The current data is empty please check x and y" 122 raise ValueError , msg122 raise ValueError(msg) 123 123 slit_length_calculator = SlitlengthCalculator() 124 124 slit_length_calculator.set_data(x=xdata, y=ydata) … … 126 126 except: 127 127 self.clearResults() 128 msg = "Slit Size Calculator: %s" % (sys.exc_ value)129 raise RuntimeError , msg128 msg = "Slit Size Calculator: %s" % (sys.exc_info()[1]) 129 raise RuntimeError(msg) 130 130 131 131 slit_length_str = "{:.5f}".format(slit_length) -
src/sas/qtgui/Calculators/UnitTesting/SlitSizeCalculatorTest.py
- Property mode changed from 100644 to 100755
rf4a1433 rb0b09b9 84 84 loader = Loader() 85 85 data = loader.load(filename)[0] 86 self.assertRaisesRegex p(RuntimeError,86 self.assertRaisesRegex(RuntimeError, 87 87 "Slit Length cannot be computed for 2D Data", 88 88 self.widget.calculateSlitSize, data) 89 89 90 90 data = None 91 self.assertRaisesRegex p(RuntimeError,91 self.assertRaisesRegex(RuntimeError, 92 92 "ERROR: Data hasn't been loaded correctly", 93 93 self.widget.calculateSlitSize, data) -
src/sas/qtgui/MainWindow/AboutBox.py
- Property mode changed from 100644 to 100755
rcd2cc745 rb0b09b9 8 8 from sas.qtgui.UI import main_resources_rc 9 9 10 from UI.AboutUI import Ui_AboutUI10 from .UI.AboutUI import Ui_AboutUI 11 11 12 12 class AboutBox(QtGui.QDialog, Ui_AboutUI): -
src/sas/qtgui/MainWindow/DataExplorer.py
- Property mode changed from 100644 to 100755
r88e1f57 rb0b09b9 155 155 Populate the Perspective combobox and define callbacks 156 156 """ 157 available_perspectives = sorted([p for p in Perspectives.PERSPECTIVES.keys()])157 available_perspectives = sorted([p for p in list(Perspectives.PERSPECTIVES.keys())]) 158 158 if available_perspectives: 159 159 self.cbFitting.clear() … … 240 240 241 241 self.manager.assign(manager) 242 for id, item in self.manager.get_all_data().ite ritems():242 for id, item in self.manager.get_all_data().items(): 243 243 self.updateModel(item.data, item.path) 244 244 … … 345 345 # Figure out which rows are checked 346 346 selected_items = [self.model.item(index) 347 for index in xrange(self.model.rowCount())347 for index in range(self.model.rowCount()) 348 348 if isItemReady(index)] 349 349 … … 400 400 else: 401 401 freeze_msg = "Unexpected number of theories copied: %i" % theories_copied 402 raise AttributeError , freeze_msg402 raise AttributeError(freeze_msg) 403 403 self.communicator.statusBarUpdateSignal.emit(freeze_msg) 404 404 # Actively switch tabs … … 411 411 new_item = item.clone() 412 412 # clone doesn't do deepcopy :( 413 for child_index in xrange(item.rowCount()):413 for child_index in range(item.rowCount()): 414 414 child_item = self.recursivelyCloneItem(item.child(child_index)) 415 415 new_item.setChild(child_index, child_item) … … 435 435 return 436 436 new_plots = [PlotHelper.plotById(plot) for plot in graph_list] 437 active_plots_copy = self.active_plots.keys()437 active_plots_copy = list(self.active_plots.keys()) 438 438 for plot in active_plots_copy: 439 439 if self.active_plots[plot] in new_plots: … … 478 478 for plot in plots: 479 479 plot_id = plot.id 480 if plot_id in self.active_plots.keys():480 if plot_id in list(self.active_plots.keys()): 481 481 self.active_plots[plot_id].replacePlot(plot_id, plot) 482 482 else: … … 530 530 else: 531 531 msg = "Incorrect data type passed to Plotting" 532 raise AttributeError , msg532 raise AttributeError(msg) 533 533 534 534 if 'new_plot' in locals() and \ … … 597 597 598 598 id = data.id 599 if data.id in self.active_plots.keys():599 if data.id in list(self.active_plots.keys()): 600 600 self.active_plots[id].replacePlot(id, data) 601 601 … … 610 610 # But only with Qt built-in dialog (non-platform native) 611 611 paths = QtGui.QFileDialog.getOpenFileNames(self, "Choose a file", "", 612 wlist, None,QtGui.QFileDialog.DontUseNativeDialog)612 wlist, QtGui.QFileDialog.DontUseNativeDialog) 613 613 if paths is None: 614 614 return 615 615 616 if isinstance(paths, QtCore.QStringList):617 paths = [str(f) for f in paths]616 #if isinstance(paths, QtCore.QStringList): 617 # paths = [str(f) for f in paths] 618 618 619 619 if not isinstance(paths, list): … … 687 687 688 688 except Exception as ex: 689 logging.error(sys.exc_ value)689 logging.error(sys.exc_info()[1]) 690 690 691 691 any_error = True … … 747 747 if not isinstance(index, int): 748 748 msg = "Incorrect type passed to DataExplorer.selectData()" 749 raise AttributeError , msg749 raise AttributeError(msg) 750 750 751 751 # Respond appropriately … … 773 773 except AttributeError: 774 774 msg = "Bad structure of the data model." 775 raise RuntimeError , msg775 raise RuntimeError(msg) 776 776 777 777 if is1D: … … 787 787 except AttributeError: 788 788 msg = "Bad structure of the data model." 789 raise RuntimeError , msg789 raise RuntimeError(msg) 790 790 791 791 if item.isCheckable() and item.checkState() == QtCore.Qt.Checked and is1D: … … 801 801 except AttributeError: 802 802 msg = "Bad structure of the data model." 803 raise RuntimeError , msg803 raise RuntimeError(msg) 804 804 805 805 if is2D: … … 815 815 except AttributeError: 816 816 msg = "Bad structure of the data model." 817 raise RuntimeError , msg817 raise RuntimeError(msg) 818 818 819 819 if item.isCheckable() and item.checkState() == QtCore.Qt.Checked and is2D: … … 823 823 msg = "Incorrect value in the Selection Option" 824 824 # Change this to a proper logging action 825 raise Exception , msg825 raise Exception(msg) 826 826 827 827 def contextMenu(self): … … 1016 1016 # Add the actual Data1D/Data2D object 1017 1017 object_item = QtGui.QStandardItem() 1018 object_item.setData( QtCore.QVariant(data))1018 object_item.setData(data) 1019 1019 1020 1020 checkbox_item.setChild(0, object_item) … … 1040 1040 if not isinstance(model_item, QtGui.QStandardItem): 1041 1041 msg = "Wrong data type returned from calculations." 1042 raise AttributeError , msg1042 raise AttributeError(msg) 1043 1043 1044 1044 # TODO: Assert other properties … … 1057 1057 if not isinstance(model_item, QtGui.QStandardItem): 1058 1058 msg = "Wrong data type returned from calculations." 1059 raise AttributeError , msg1059 raise AttributeError(msg) 1060 1060 1061 1061 # Check if there are any other items for this tab … … 1064 1064 # 1065 1065 current_tab_name = model_item.text()[:2] 1066 for current_index in xrange(self.theory_model.rowCount()):1066 for current_index in range(self.theory_model.rowCount()): 1067 1067 if current_tab_name in self.theory_model.item(current_index).text(): 1068 1068 self.theory_model.removeRow(current_index) -
src/sas/qtgui/MainWindow/DataManager.py
- Property mode changed from 100644 to 100755
rf4a1433 rb0b09b9 24 24 import json 25 25 import time 26 from StringIOimport StringIO26 from io import StringIO 27 27 import numpy as np 28 28 … … 66 66 _str += "No of states is %s \n" % str(len(self.stored_data)) 67 67 n_count = 0 68 for value in self.stored_data.values():68 for value in list(self.stored_data.values()): 69 69 n_count += 1 70 70 _str += "State No %s \n" % str(n_count) … … 146 146 receive a list of 147 147 """ 148 for id, data in data_list.ite ritems():148 for id, data in data_list.items(): 149 149 if id in self.stored_data: 150 150 msg = "Data manager already stores %s" % str(data.name) … … 162 162 """ 163 163 """ 164 if prev_data.id not in self.stored_data.keys():164 if prev_data.id not in list(self.stored_data.keys()): 165 165 return None, {} 166 166 data_state = self.stored_data[prev_data.id] 167 167 self.stored_data[new_data.id] = data_state.clone() 168 168 self.stored_data[new_data.id].data = new_data 169 if prev_data.id in self.stored_data.keys():169 if prev_data.id in list(self.stored_data.keys()): 170 170 del self.stored_data[prev_data.id] 171 171 return prev_data.id, {new_data.id: self.stored_data[new_data.id]} … … 177 177 if data_id is None and theory is not None: 178 178 uid = theory.id 179 if uid in self.stored_data.keys():179 if uid in list(self.stored_data.keys()): 180 180 data_state = self.stored_data[uid] 181 181 else: … … 207 207 if search_id == d_id: 208 208 _selected_data[search_id] = data 209 if search_id in theory_list.keys():209 if search_id in list(theory_list.keys()): 210 210 _selected_theory_list[search_id] = theory_list[search_id] 211 211 … … 216 216 """ 217 217 """ 218 return self.freeze_theory( self.stored_data.keys(), theory_id)218 return self.freeze_theory(list(self.stored_data.keys()), theory_id) 219 219 220 220 def freeze_theory(self, data_id, theory_id): … … 227 227 theory_list = data_state.get_theory() 228 228 for t_id in theory_id: 229 if t_id in theory_list.keys():229 if t_id in list(theory_list.keys()): 230 230 theory_data, theory_state = theory_list[t_id] 231 231 new_theory = copy.deepcopy(theory_data) … … 247 247 """ 248 248 for d_id in data_id: 249 if d_id in self.stored_data.keys():249 if d_id in list(self.stored_data.keys()): 250 250 data_state = self.stored_data[d_id] 251 251 if data_state.data.name in self.data_name_dict: … … 265 265 data_state = self.stored_data[d_id] 266 266 theory_list = data_state.get_theory() 267 if theory_id in theory_list.keys():267 if theory_id in list(theory_list.keys()): 268 268 del theory_list[theory_id] 269 269 #del pure theory … … 284 284 _selected_data = {} 285 285 for selected_name in name_list: 286 for id, data_state in self.stored_data.ite ritems():286 for id, data_state in self.stored_data.items(): 287 287 if data_state.data.name == selected_name: 288 288 _selected_data[id] = data_state.data … … 294 294 """ 295 295 for selected_name in name_list: 296 for id, data_state in self.stored_data.ite ritems():296 for id, data_state in self.stored_data.items(): 297 297 if data_state.data.name == selected_name: 298 298 del self.stored_data[id] … … 303 303 # Take the copy of current, possibly shorter stored_data dict 304 304 stored_data = copy.deepcopy(self.stored_data) 305 for idx in stored_data.keys():305 for idx in list(stored_data.keys()): 306 306 if str(selected_name) in str(idx): 307 307 del self.stored_data[idx] … … 313 313 _selected_data_state = {} 314 314 for id in data_id: 315 if id in self.stored_data.keys():315 if id in list(self.stored_data.keys()): 316 316 _selected_data_state[id] = self.stored_data[id] 317 317 return _selected_data_state … … 396 396 class Empty(object): 397 397 def __init__(self): 398 for key, value in data.ite ritems():398 for key, value in data.items(): 399 399 setattr(self, key, generate(value, level)) 400 400 … … 451 451 # if dictionary doesn't have __type__ then it is assumed to be just an ordinary dictionary 452 452 o = {} 453 for key, value in data.ite ritems():453 for key, value in data.items(): 454 454 o[key] = generate(value, level) 455 455 return o … … 463 463 464 464 new_stored_data = {} 465 for id, data in json.load(fp).ite ritems():465 for id, data in json.load(fp).items(): 466 466 try: 467 467 new_stored_data[id] = generate(data, 0) -
src/sas/qtgui/MainWindow/DataState.py
rdc5ef15 rb0b09b9 37 37 _str += "Theories available: %s \n" % len(self.theory_list) 38 38 if self.theory_list: 39 for id, item in self.theory_list.ite ritems():39 for id, item in self.theory_list.items(): 40 40 theory_data, theory_state = item 41 41 _str += "Theory name : %s \n" % str(theory_data.name) … … 53 53 obj.message = self.message 54 54 obj.id = self.id 55 for id, item in self.theory_list.ite ritems():55 for id, item in self.theory_list.items(): 56 56 theory_data, theory_state = item 57 57 state = None … … 95 95 """ 96 96 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] 98 98 99 99 def get_theory(self): -
src/sas/qtgui/MainWindow/GuiManager.py
- Property mode changed from 100644 to 100755
rf0bb711 rb0b09b9 191 191 workspace_height = self._workspace.workspace.sizeHint().height() 192 192 perspective_size = self._current_perspective.sizeHint() 193 if workspace_height < perspective_size.height :193 if workspace_height < perspective_size.height(): 194 194 perspective_width = perspective_size.width() 195 195 self._current_perspective.resize(perspective_width, workspace_height-10) … … 202 202 assert isinstance(data, list) 203 203 if self._current_perspective is not None: 204 self._current_perspective.setData( data.values())204 self._current_perspective.setData(list(data.values())) 205 205 else: 206 206 msg = "No perspective is currently active." … … 246 246 """ 247 247 if self._current_perspective is not None: 248 self._current_perspective.setData( data.values())248 self._current_perspective.setData(list(data.values())) 249 249 else: 250 250 msg = "Guiframe does not have a current perspective" … … 289 289 version_info = json.loads(content) 290 290 self.processVersion(version_info) 291 except ValueError ,ex:291 except ValueError as ex: 292 292 logging.info("Failed to connect to www.sasview.org:", ex) 293 293 … … 321 321 except: 322 322 msg = "guiframe: could not get latest application" 323 msg += " version number\n %s" % sys.exc_ value323 msg += " version number\n %s" % sys.exc_info()[1] 324 324 logging.error(msg) 325 325 msg = "Could not connect to the application server." … … 743 743 not isinstance(new_datalist_item, dict): 744 744 msg = "Wrong data type returned from calculations." 745 raise AttributeError , msg745 raise AttributeError(msg) 746 746 747 747 self.filesWidget.model.appendRow(new_item) -
src/sas/qtgui/MainWindow/MainWindow.py
- Property mode changed from 100644 to 100755
r2a8bd705 rb0b09b9 5 5 # Local UI 6 6 from sas.qtgui.UI import main_resources_rc 7 from UI.MainWindowUI import Ui_MainWindow7 from .UI.MainWindowUI import Ui_MainWindow 8 8 9 9 # Initialize logging … … 21 21 22 22 # Create the gui manager 23 from GuiManager import GuiManager23 from .GuiManager import GuiManager 24 24 self.guiManager = GuiManager(self) 25 25 -
src/sas/qtgui/Perspectives/Fitting/FitThread.py
ree18d33 rb0b09b9 14 14 15 15 def map_apply(arguments): 16 return a pply(arguments[0],arguments[1:])16 return arguments[0](*arguments[1:]) 17 17 18 18 class FitThread(CalcThread): … … 55 55 except KeyboardInterrupt: 56 56 msg = "Fitting: terminated by the user." 57 raise KeyboardInterrupt , msg57 raise KeyboardInterrupt(msg) 58 58 59 59 def compute(self): … … 71 71 list_q = [None]*fitter_size 72 72 73 inputs = zip(list_map_get_attr, self.fitter, list_fit_function,73 inputs = list(zip(list_map_get_attr, self.fitter, list_fit_function, 74 74 list_q, list_q, list_handler, list_curr_thread, 75 list_reset_flag) 76 result = map(map_apply, inputs)75 list_reset_flag)) 76 result = list(map(map_apply, inputs)) 77 77 results = (result, time.time()-self.starttime) 78 78 if self.handler: … … 81 81 return (results) 82 82 83 except KeyboardInterrupt ,msg:83 except KeyboardInterrupt as msg: 84 84 # Thread was interrupted, just proceed and re-raise. 85 85 # Real code should not print, but this is an example... -
src/sas/qtgui/Perspectives/Fitting/FittingLogic.py
ree18d33 rb0b09b9 196 196 msg = "Unable to find min/max/length of \n data named %s" % \ 197 197 self.data.filename 198 raise ValueError , msg198 raise ValueError(msg) 199 199 200 200 else: … … 206 206 msg = "Unable to find min/max of \n data named %s" % \ 207 207 self.data.filename 208 raise ValueError , msg208 raise ValueError(msg) 209 209 qmax = np.sqrt(x * x + y * y) 210 210 npts = len(data.data) -
src/sas/qtgui/Perspectives/Fitting/FittingOptions.py
r377ade1 rb0b09b9 80 80 Use options.FIT_FIELDS to assert which line edit gets what validator 81 81 """ 82 for option in bumps.options.FIT_FIELDS. iterkeys():82 for option in bumps.options.FIT_FIELDS.keys(): 83 83 (f_name, f_type) = bumps.options.FIT_FIELDS[option] 84 84 validator = None … … 86 86 validator = QtGui.QIntValidator() 87 87 validator.setBottom(0) 88 elif f_type == types.FloatType:88 elif f_type == float: 89 89 validator = QtGui.QDoubleValidator() 90 90 validator.setBottom(0) … … 153 153 154 154 # Update the BUMPS singleton 155 [bumpsUpdate(o) for o in self.config.values[self.current_fitter_id]. iterkeys()]155 [bumpsUpdate(o) for o in self.config.values[self.current_fitter_id].keys()] 156 156 157 157 def onHelp(self): … … 175 175 if current_fitter is None: 176 176 current_fitter = self.current_fitter_id 177 if option_id not in bumps.options.FIT_FIELDS.keys(): return None177 if option_id not in list(bumps.options.FIT_FIELDS.keys()): return None 178 178 option = option_id + '_' + current_fitter 179 179 if not hasattr(self, option): return None … … 193 193 """ 194 194 options = self.config.values[fitter_id] 195 for option in options. iterkeys():195 for option in options.keys(): 196 196 # Find the widget name of the option 197 197 # e.g. 'samples' for 'dream' is 'self.samples_dream' -
src/sas/qtgui/Perspectives/Fitting/FittingPerspective.py
- Property mode changed from 100644 to 100755
r377ade1 rb0b09b9 11 11 from sas.qtgui.Perspectives.Fitting.FittingWidget import FittingWidget 12 12 from sas.qtgui.Perspectives.Fitting.FittingOptions import FittingOptions 13 from sas.qtgui.Perspectives.Fitting import ModelUtilities13 #from sas.qtgui.Perspectives.Fitting import ModelUtilities 14 14 15 15 class FittingWindow(QtGui.QTabWidget): … … 61 61 self.fit_options_widget.fit_option_changed.connect(self.onFittingOptionsChange) 62 62 63 self.menu_manager = ModelUtilities.ModelManager()64 # TODO: reuse these in FittingWidget properly65 self.model_list_box = self.menu_manager.get_model_list()66 self.model_dictionary = self.menu_manager.get_model_dictionary()63 #self.menu_manager = ModelUtilities.ModelManager() 64 ## TODO: reuse these in FittingWidget properly 65 #self.model_list_box = self.menu_manager.get_model_list() 66 #self.model_dictionary = self.menu_manager.get_model_dictionary() 67 67 68 68 #self.setWindowTitle('Fit panel - Active Fitting Optimizer: %s' % self.optimizer) … … 120 120 Create a list if none exists and append if there's already a list 121 121 """ 122 if item_key in self.dataToFitTab.keys(): 123 self.dataToFitTab[item_key].append(tab_name) 122 item_key_str = str(item_key) 123 if item_key_str in list(self.dataToFitTab.keys()): 124 self.dataToFitTab[item_key_str].append(tab_name) 124 125 else: 125 self.dataToFitTab[item_key ] = [tab_name]126 self.dataToFitTab[item_key_str] = [tab_name] 126 127 127 128 #print "CURRENT dict: ", self.dataToFitTab … … 169 170 Given name of the fitting tab - close it 170 171 """ 171 for tab_index in xrange(len(self.tabs)):172 for tab_index in range(len(self.tabs)): 172 173 if self.tabText(tab_index) == tab_name: 173 174 self.tabCloses(tab_index) … … 181 182 return 182 183 for index_to_delete in index_list: 183 if index_to_delete in self.dataToFitTab.keys(): 184 for tab_name in self.dataToFitTab[index_to_delete]: 184 index_to_delete_str = str(index_to_delete) 185 if index_to_delete_str in list(self.dataToFitTab.keys()): 186 for tab_name in self.dataToFitTab[index_to_delete_str]: 185 187 # delete tab #index after corresponding data got removed 186 188 self.closeTabByName(tab_name) 187 self.dataToFitTab.pop(index_to_delete )189 self.dataToFitTab.pop(index_to_delete_str) 188 190 189 191 #print "CURRENT dict: ", self.dataToFitTab … … 205 207 if not isinstance(data_item, list): 206 208 msg = "Incorrect type passed to the Fitting Perspective" 207 raise AttributeError , msg209 raise AttributeError(msg) 208 210 209 211 if not isinstance(data_item[0], QtGui.QStandardItem): 210 212 msg = "Incorrect type passed to the Fitting Perspective" 211 raise AttributeError , msg213 raise AttributeError(msg) 212 214 213 215 items = [data_item] if is_batch else data_item … … 216 218 # Find the first unassigned tab. 217 219 # If none, open a new tab. 218 available_tabs = list( map(lambda tab: tab.acceptsData(), self.tabs))220 available_tabs = list([tab.acceptsData() for tab in self.tabs]) 219 221 220 222 if numpy.any(available_tabs): -
src/sas/qtgui/Perspectives/Fitting/FittingUtilities.py
- Property mode changed from 100644 to 100755
rd0dfcb2 rb0b09b9 44 44 Returns a list of all multi-shell parameters in 'model' 45 45 """ 46 return list( filter(lambda par: "[" in par.name, model.iq_parameters))46 return list([par for par in model.iq_parameters if "[" in par.name]) 47 47 48 48 def getMultiplicity(model): … … 156 156 """ 157 157 for i, item in enumerate(model_header_captions): 158 model.setHeaderData(i, QtCore.Qt.Horizontal, QtCore.QVariant(item)) 158 #model.setHeaderData(i, QtCore.Qt.Horizontal, QtCore.QVariant(item)) 159 model.setHeaderData(i, QtCore.Qt.Horizontal, item) 159 160 160 161 model.header_tooltips = model_header_tooltips … … 167 168 model_header_error_captions.insert(2, header_error_caption) 168 169 for i, item in enumerate(model_header_error_captions): 169 model.setHeaderData(i, QtCore.Qt.Horizontal, QtCore.QVariant(item))170 model.setHeaderData(i, QtCore.Qt.Horizontal, item) 170 171 171 172 model_header_error_tooltips = model_header_tooltips … … 178 179 """ 179 180 for i, item in enumerate(poly_header_captions): 180 model.setHeaderData(i, QtCore.Qt.Horizontal, QtCore.QVariant(item))181 model.setHeaderData(i, QtCore.Qt.Horizontal, item) 181 182 182 183 model.header_tooltips = poly_header_tooltips … … 190 191 poly_header_error_captions.insert(2, header_error_caption) 191 192 for i, item in enumerate(poly_header_error_captions): 192 model.setHeaderData(i, QtCore.Qt.Horizontal, QtCore.QVariant(item))193 model.setHeaderData(i, QtCore.Qt.Horizontal, item) 193 194 194 195 poly_header_error_tooltips = poly_header_tooltips … … 202 203 multishell_parameters = getIterParams(parameters) 203 204 204 for i in xrange(index):205 for i in range(index): 205 206 for par in multishell_parameters: 206 207 # Create the name: <param>[<i>], e.g. "sld1" for parameter "sld[n]" … … 396 397 397 398 def binary_encode(i, digits): 398 return [i >> d & 1 for d in xrange(digits)]399 return [i >> d & 1 for d in range(digits)] 399 400 400 401 def getWeight(data, is2d, flag=None): -
src/sas/qtgui/Perspectives/Fitting/FittingWidget.py
- Property mode changed from 100644 to 100755
rdef64a0 rb0b09b9 2 2 import os 3 3 from collections import defaultdict 4 from itertools import izip 4 5 5 6 6 import logging … … 69 69 if role == QtCore.Qt.ToolTipRole: 70 70 if orientation == QtCore.Qt.Horizontal: 71 return QtCore.QString(str(self.header_tooltips[section]))71 return str(self.header_tooltips[section]) 72 72 73 73 return QtGui.QStandardItemModel.headerData(self, section, orientation, role) … … 353 353 # Similarly on other tabs 354 354 self.options_widget.setEnablementOnDataLoad() 355 355 self.onSelectModel() 356 356 # Smearing tab 357 357 self.smearing_widget.updateSmearing(self.data) … … 473 473 model = str(self.cbModel.currentText()) 474 474 475 # empty combobox forced to be read 476 if not model: 477 return 475 478 # Reset structure factor 476 479 self.cbStructureFactor.setCurrentIndex(0) … … 763 766 """ 764 767 """ 765 print "UPDATE FIT"768 print("UPDATE FIT") 766 769 pass 767 770 … … 769 772 """ 770 773 """ 771 print "FIT FAILED: ", reason774 print("FIT FAILED: ", reason) 772 775 pass 773 776 … … 814 817 param_values = res.pvec # array([ 0.36221662, 0.0146783 ]) 815 818 param_stderr = res.stderr # array([ 1.71293015, 1.71294233]) 816 params_and_errors = zip(param_values, param_stderr)817 param_dict = dict( izip(param_list, params_and_errors))819 params_and_errors = list(zip(param_values, param_stderr)) 820 param_dict = dict(zip(param_list, params_and_errors)) 818 821 819 822 # Dictionary of fitted parameter: value, error … … 836 839 Take func and throw it inside the model row loop 837 840 """ 838 for row_i in xrange(self._model_model.rowCount()):841 for row_i in range(self._model_model.rowCount()): 839 842 func(row_i) 840 843 … … 851 854 # internal so can use closure for param_dict 852 855 param_name = str(self._model_model.item(row, 0).text()) 853 if param_name not in param_dict.keys():856 if param_name not in list(param_dict.keys()): 854 857 return 855 858 # modify the param value … … 863 866 # Utility function for updateof polydispersity part of the main model 864 867 param_name = str(self._model_model.item(row, 0).text())+'.width' 865 if param_name not in param_dict.keys():868 if param_name not in list(param_dict.keys()): 866 869 return 867 870 # modify the param value … … 878 881 return str(self._model_model.item(row, 0).text()) 879 882 880 [createItem(param_name) for param_name in param_dict.keys() if curr_param() == param_name]883 [createItem(param_name) for param_name in list(param_dict.keys()) if curr_param() == param_name] 881 884 882 885 error_column.append(item) … … 922 925 Take func and throw it inside the poly model row loop 923 926 """ 924 for row_i in xrange(self._poly_model.rowCount()):927 for row_i in range(self._poly_model.rowCount()): 925 928 func(row_i) 926 929 … … 931 934 return 932 935 param_name = str(self._poly_model.item(row_i, 0).text()).rsplit()[-1] + '.width' 933 if param_name not in param_dict.keys():936 if param_name not in list(param_dict.keys()): 934 937 return 935 938 # modify the param value … … 954 957 return str(self._poly_model.item(row_i, 0).text()).rsplit()[-1] + '.width' 955 958 956 [createItem(param_name) for param_name in param_dict.keys() if poly_param() == param_name]959 [createItem(param_name) for param_name in list(param_dict.keys()) if poly_param() == param_name] 957 960 958 961 error_column.append(item) … … 991 994 Take func and throw it inside the magnet model row loop 992 995 """ 993 for row_i in xrange(self._model_model.rowCount()):996 for row_i in range(self._model_model.rowCount()): 994 997 func(row_i) 995 998 … … 998 1001 # internal so can use closure for param_dict 999 1002 param_name = str(self._magnet_model.item(row, 0).text()) 1000 if param_name not in param_dict.keys():1003 if param_name not in list(param_dict.keys()): 1001 1004 return 1002 1005 # modify the param value … … 1016 1019 return str(self._magnet_model.item(row, 0).text()) 1017 1020 1018 [createItem(param_name) for param_name in param_dict.keys() if curr_param() == param_name]1021 [createItem(param_name) for param_name in list(param_dict.keys()) if curr_param() == param_name] 1019 1022 1020 1023 error_column.append(item) … … 1291 1294 # Unparsable field 1292 1295 return 1293 parameter_name = str(self._model_model.data(name_index) .toPyObject()) # sld, background etc.1296 parameter_name = str(self._model_model.data(name_index)) #.toPyObject()) # sld, background etc. 1294 1297 1295 1298 # Update the parameter value - note: this supports +/-inf as well … … 1357 1360 1358 1361 return [str(model.item(row_index, 0).text()) 1359 for row_index in xrange(model.rowCount())1362 for row_index in range(model.rowCount()) 1360 1363 if isChecked(row_index)] 1361 1364 … … 1398 1401 fitted_data.symbol = 'Line' 1399 1402 # Notify the GUI manager so it can update the main model in DataExplorer 1400 GuiUtils.updateModelItemWithPlot(self._index, QtCore.QVariant(fitted_data), name)1403 GuiUtils.updateModelItemWithPlot(self._index, fitted_data, name) 1401 1404 1402 1405 def createTheoryIndex(self, fitted_data): … … 1406 1409 name = self.nameFromData(fitted_data) 1407 1410 # Notify the GUI manager so it can create the theory model in DataExplorer 1408 new_item = GuiUtils.createModelItemWithPlot( QtCore.QVariant(fitted_data), name=name)1411 new_item = GuiUtils.createModelItemWithPlot(fitted_data, name=name) 1409 1412 self.communicate.updateTheoryFromPerspectiveSignal.emit(new_item) 1410 1413 … … 1460 1463 Thread returned error 1461 1464 """ 1462 print "Calculate Data failed with ", reason1465 print("Calculate Data failed with ", reason) 1463 1466 1464 1467 def complete1D(self, return_data): … … 1557 1560 else: 1558 1561 # Create as many entries as current shells 1559 for ishell in xrange(1, self.current_shell_displayed+1):1562 for ishell in range(1, self.current_shell_displayed+1): 1560 1563 # Remove [n] and add the shell numeral 1561 1564 name = param_name[0:param_name.index('[')] + str(ishell) … … 1585 1588 # All possible polydisp. functions as strings in combobox 1586 1589 func = QtGui.QComboBox() 1587 func.addItems([str(name_disp) for name_disp in POLYDISPERSITY_MODELS. iterkeys()])1590 func.addItems([str(name_disp) for name_disp in POLYDISPERSITY_MODELS.keys()]) 1588 1591 # Set the default index 1589 1592 func.setCurrentIndex(func.findText(DEFAULT_POLYDISP_FUNCTION)) … … 1636 1639 lo = self.lstPoly.itemDelegate().poly_pd 1637 1640 hi = self.lstPoly.itemDelegate().poly_function 1638 [self._poly_model.item(row_index, i).setEnabled(False) for i in xrange(lo, hi)]1641 [self._poly_model.item(row_index, i).setEnabled(False) for i in range(lo, hi)] 1639 1642 return 1640 1643 except IOError: … … 1646 1649 self._poly_model.blockSignals(True) 1647 1650 max_range = self.lstPoly.itemDelegate().poly_filename 1648 [self._poly_model.item(row_index, i).setEnabled(True) for i in xrange(7)]1651 [self._poly_model.item(row_index, i).setEnabled(True) for i in range(7)] 1649 1652 file_index = self._poly_model.index(row_index, self.lstPoly.itemDelegate().poly_filename) 1650 self._poly_model.setData(file_index, QtCore.QVariant(""))1653 self._poly_model.setData(file_index, "") 1651 1654 self._poly_model.blockSignals(False) 1652 1655 … … 1657 1660 nsigs = POLYDISPERSITY_MODELS[str(combo_string)].default['nsigmas'] 1658 1661 1659 self._poly_model.setData(npts_index, QtCore.QVariant(npts))1660 self._poly_model.setData(nsigs_index, QtCore.QVariant(nsigs))1662 self._poly_model.setData(npts_index, npts) 1663 self._poly_model.setData(nsigs_index, nsigs) 1661 1664 1662 1665 self.iterateOverModel(updateFunctionCaption) … … 1669 1672 datafile = QtGui.QFileDialog.getOpenFileName( 1670 1673 self, "Choose a weight file", "", "All files (*.*)", 1671 None,QtGui.QFileDialog.DontUseNativeDialog)1674 QtGui.QFileDialog.DontUseNativeDialog) 1672 1675 1673 1676 if datafile is None or str(datafile)=='': … … 1698 1701 fname = os.path.basename(str(datafile)) 1699 1702 fname_index = self._poly_model.index(row_index, self.lstPoly.itemDelegate().poly_filename) 1700 self._poly_model.setData(fname_index, QtCore.QVariant(fname))1703 self._poly_model.setData(fname_index, fname) 1701 1704 1702 1705 def setMagneticModel(self): … … 1720 1723 top_index = self.kernel_module.multiplicity_info.number 1721 1724 shell_names = [] 1722 for i in xrange(1, top_index+1):1725 for i in range(1, top_index+1): 1723 1726 for name in multi_names: 1724 1727 shell_names.append(name+str(i)) … … 1770 1773 func = QtGui.QComboBox() 1771 1774 # Available range of shells displayed in the combobox 1772 func.addItems([str(i) for i in xrange(param_length+1)])1775 func.addItems([str(i) for i in range(param_length+1)]) 1773 1776 1774 1777 # Respond to index change -
src/sas/qtgui/Perspectives/Fitting/ModelThread.py
r6964d44 rb0b09b9 65 65 if self.data is None: 66 66 msg = "Compute Calc2D receive data = %s.\n" % str(self.data) 67 raise ValueError , msg67 raise ValueError(msg) 68 68 69 69 # Define matrix where data will be plotted -
src/sas/qtgui/Perspectives/Fitting/ModelUtilities.py
r125c4be rb0b09b9 2 2 Utilities to manage models 3 3 """ 4 from __future__ import print_function 4 5 5 6 6 import traceback … … 68 68 except: 69 69 msg = "Plugin %s error in __init__ \n\t: %s %s\n" % (str(name), 70 str(sys.exc_ type),70 str(sys.exc_info()[0]), 71 71 sys.exc_info()[1]) 72 72 plugin_log(msg) … … 78 78 except: 79 79 msg = "Plugin %s: error writing function \n\t :%s %s\n " % \ 80 (str(name), str(sys.exc_ type), sys.exc_info()[1])80 (str(name), str(sys.exc_info()[0]), sys.exc_info()[1]) 81 81 plugin_log(msg) 82 82 return None … … 138 138 Class to check for problems with specific values 139 139 """ 140 def __ nonzero__(self):140 def __bool__(self): 141 141 type, value, tb = sys.exc_info() 142 142 if type is not None and issubclass(type, py_compile.PyCompileError): 143 143 print("Problem with", repr(value)) 144 raise type , value, tb144 raise type(value).with_traceback(tb) 145 145 return 1 146 146 … … 211 211 212 212 """ 213 if name not in self.mydict.keys():213 if name not in list(self.mydict.keys()): 214 214 self.reset_list(name, mylist) 215 215 … … 292 292 #Looking for plugins 293 293 self.stored_plugins = self.findModels() 294 self.plugins = self.stored_plugins.values()295 for name, plug in self.stored_plugins.ite ritems():294 self.plugins = list(self.stored_plugins.values()) 295 for name, plug in self.stored_plugins.items(): 296 296 self.model_dictionary[name] = plug 297 297 … … 322 322 new_plugins = self.findModels() 323 323 if len(new_plugins) > 0: 324 for name, plug in new_plugins.ite ritems():325 if name not in self.stored_plugins.keys():324 for name, plug in new_plugins.items(): 325 if name not in list(self.stored_plugins.keys()): 326 326 self.stored_plugins[name] = plug 327 327 self.plugins.append(plug) … … 338 338 self.plugins = [] 339 339 new_plugins = _find_models() 340 for name, plug in new_plugins.ite ritems():341 for stored_name, stored_plug in self.stored_plugins.ite ritems():340 for name, plug in new_plugins.items(): 341 for stored_name, stored_plug in self.stored_plugins.items(): 342 342 if name == stored_name: 343 343 del self.stored_plugins[name] … … 358 358 359 359 """ 360 if int(evt.GetId()) in self.form_factor_dict.keys():360 if int(evt.GetId()) in list(self.form_factor_dict.keys()): 361 361 from sasmodels.sasview_model import MultiplicationModel 362 362 self.model_dictionary[MultiplicationModel.__name__] = MultiplicationModel … … 417 417 __modelmanager = ModelManagerBase() 418 418 cat_model_list = [__modelmanager.model_dictionary[model_name] for model_name \ 419 in __modelmanager.model_dictionary.keys() \420 if model_name not in __modelmanager.stored_plugins.keys()]419 in list(__modelmanager.model_dictionary.keys()) \ 420 if model_name not in list(__modelmanager.stored_plugins.keys())] 421 421 422 422 CategoryInstaller.check_install(model_list=cat_model_list) -
src/sas/qtgui/Perspectives/Fitting/OptionsWidget.py
r457d961 rb0b09b9 96 96 """ 97 97 self.model = QtGui.QStandardItemModel() 98 for model_item in xrange(len(MODEL)):98 for model_item in range(len(MODEL)): 99 99 self.model.setItem(model_item, QtGui.QStandardItem()) 100 100 # Attach slot -
src/sas/qtgui/Perspectives/Fitting/SmearingWidget.py
- Property mode changed from 100644 to 100755
rdc5ef15 rb0b09b9 65 65 """ 66 66 self.model = QtGui.QStandardItemModel() 67 for model_item in xrange(len(MODEL)):67 for model_item in range(len(MODEL)): 68 68 self.model.setItem(model_item, QtGui.QStandardItem()) 69 69 # Attach slot -
src/sas/qtgui/Perspectives/Invariant/InvariantDetails.py
- Property mode changed from 100644 to 100755
r28cda69 rb0b09b9 5 5 6 6 # local 7 from UI.InvariantDetailsUI import Ui_Dialog8 from InvariantUtils import WIDGETS7 from .UI.InvariantDetailsUI import Ui_Dialog 8 from .InvariantUtils import WIDGETS 9 9 10 10 class DetailsDialog(QtGui.QDialog, Ui_Dialog): -
src/sas/qtgui/Perspectives/Invariant/InvariantPerspective.py
- Property mode changed from 100644 to 100755
r457d961 rb0b09b9 15 15 16 16 # local 17 from UI.TabbedInvariantUI import Ui_tabbedInvariantUI18 from InvariantDetails import DetailsDialog19 from InvariantUtils import WIDGETS17 from .UI.TabbedInvariantUI import Ui_tabbedInvariantUI 18 from .InvariantDetails import DetailsDialog 19 from .InvariantUtils import WIDGETS 20 20 21 21 # The minimum q-value to be used when extrapolating … … 551 551 if not isinstance(data_item, list): 552 552 msg = "Incorrect type passed to the Invariant Perspective" 553 raise AttributeError , msg553 raise AttributeError(msg) 554 554 555 555 if not isinstance(data_item[0], QtGui.QStandardItem): 556 556 msg = "Incorrect type passed to the Invariant Perspective" 557 raise AttributeError , msg557 raise AttributeError(msg) 558 558 559 559 self._model_item = data_item[0] … … 631 631 self.calculateInvariant() 632 632 except: 633 msg = "Invariant Set_data: " + str(sys.exc_ value)633 msg = "Invariant Set_data: " + str(sys.exc_info()[1]) 634 634 #wx.PostEvent(self.parent, StatusEvent(status=msg, info="error")) 635 635 else: -
src/sas/qtgui/Perspectives/Invariant/InvariantUtils.py
rf721030 rb0b09b9 1 1 def enum(*sequential, **named): 2 enums = dict( zip(sequential, range(len(sequential))), **named)2 enums = dict(list(zip(sequential, list(range(len(sequential))))), **named) 3 3 return type('Enum', (), enums) 4 4 -
src/sas/qtgui/Perspectives/__init__.py
- Property mode changed from 100644 to 100755
r7adc2a8 rb0b09b9 2 2 # When adding a new perspective, this dictionary needs to be updated 3 3 4 from Fitting.FittingPerspective import FittingWindow5 from Invariant.InvariantPerspective import InvariantWindow4 from .Fitting.FittingPerspective import FittingWindow 5 from .Invariant.InvariantPerspective import InvariantWindow 6 6 7 7 PERSPECTIVES = { -
src/sas/qtgui/Plotting/Arrow3D.py
rfef38e8 rb0b09b9 59 59 return 60 60 xs3d, ys3d, zs3d = self._verts3d 61 for i in xrange(len(xs3d)):61 for i in range(len(xs3d)): 62 62 xs, ys, _ = proj3d.proj_transform(xs3d[i], ys3d[i], zs3d[i], renderer.M) 63 63 self.set_positions((xs[0], ys[0]), (xs[1], ys[1])) -
src/sas/qtgui/Plotting/Binder.py
rdc5ef15 rb0b09b9 24 24 return self.artist is not other.artist 25 25 26 def __ nonzero__(self):26 def __bool__(self): 27 27 return self.artist is not None 28 28 … … 61 61 ] 62 62 except: 63 print "bypassing scroll_event: wrong matplotlib version"63 print("bypassing scroll_event: wrong matplotlib version") 64 64 self._connections = [ 65 65 canvas.mpl_connect('motion_notify_event', self._onMotion), … … 121 121 for cid in self._connections: self.canvas.mpl_disconnect(cid) 122 122 except: 123 logging.error("Error disconnection canvas: %s" % sys.exc_ value)123 logging.error("Error disconnection canvas: %s" % sys.exc_info()[1]) 124 124 self._connections = [] 125 125 … … 185 185 # Check that the trigger is valid 186 186 if trigger not in self._actions: 187 raise ValueError ,"%s invalid --- valid triggers are %s"\188 % (trigger, ", ".join(self.events)) 187 raise ValueError("%s invalid --- valid triggers are %s"\ 188 % (trigger, ", ".join(self.events))) 189 189 190 190 # Register the trigger callback … … 201 201 """ 202 202 if action not in self.events: 203 raise ValueError , "Trigger expects " + ", ".join(self.events)203 raise ValueError("Trigger expects " + ", ".join(self.events)) 204 204 205 205 # Tag the event with modifiers -
src/sas/qtgui/Plotting/ColorMap.py
- Property mode changed from 100644 to 100755
rdc5ef15 rb0b09b9 13 13 from sas.qtgui.Plotting.PlotterData import Data2D 14 14 from sas.qtgui.Utilities.GuiUtils import formatNumber 15 from rangeSlider import RangeSlider15 from .rangeSlider import RangeSlider 16 16 17 17 DEFAULT_MAP = 'jet' -
src/sas/qtgui/Plotting/ConvertUnits.py
rdc5ef15 rb0b09b9 42 42 unit = toks[0] + "^{" + str(powerer) + "}" 43 43 else: 44 raise ValueError , "missing } in unit expression"44 raise ValueError("missing } in unit expression") 45 45 else: # no powerer 46 46 if power != 1: 47 47 unit = "(" + unit + ")" + "^{" + str(power) + "}" 48 48 else: 49 raise ValueError , "empty unit ,enter a powerer different from zero"49 raise ValueError("empty unit ,enter a powerer different from zero") 50 50 return unit 51 51 … … 68 68 unit8 = "m/s^{4}" # x^2 (m/s^{4})^{2} 69 69 70 print "this unit1 %s ,its powerer %s , and value %s" % (unit1, 1, convert_unit(1, unit1))71 print "this unit2 %s ,its powerer %s , and value %s" % (unit2, 1, convert_unit(1, unit2))72 print "this unit3 %s ,its powerer %s , and value %s" % (unit3, 2, convert_unit(2, unit3))73 print "this unit4 %s ,its powerer %s , and value %s" % (unit4, -1, convert_unit(-1, unit4))74 print "this unit5 %s ,its powerer %s , and value %s" % (unit5, 2, convert_unit(2, unit5))75 print "this unit6 %s ,its powerer %s , and value %s" % (unit6, 2, convert_unit(2, unit6))76 print "this unit7 %s ,its powerer %s , and value %s" % (unit7, -1, convert_unit(-1, unit7))77 print "this unit8 %s ,its powerer %s , and value %s" % (unit8, 2, convert_unit(2, unit8))78 print "this unit9 %s ,its powerer %s , and value %s" % (unit9, 2, convert_unit(2, unit9))70 print("this unit1 %s ,its powerer %s , and value %s" % (unit1, 1, convert_unit(1, unit1))) 71 print("this unit2 %s ,its powerer %s , and value %s" % (unit2, 1, convert_unit(1, unit2))) 72 print("this unit3 %s ,its powerer %s , and value %s" % (unit3, 2, convert_unit(2, unit3))) 73 print("this unit4 %s ,its powerer %s , and value %s" % (unit4, -1, convert_unit(-1, unit4))) 74 print("this unit5 %s ,its powerer %s , and value %s" % (unit5, 2, convert_unit(2, unit5))) 75 print("this unit6 %s ,its powerer %s , and value %s" % (unit6, 2, convert_unit(2, unit6))) 76 print("this unit7 %s ,its powerer %s , and value %s" % (unit7, -1, convert_unit(-1, unit7))) 77 print("this unit8 %s ,its powerer %s , and value %s" % (unit8, 2, convert_unit(2, unit8))) 78 print("this unit9 %s ,its powerer %s , and value %s" % (unit9, 2, convert_unit(2, unit9))) 79 79 80 80 -
src/sas/qtgui/Plotting/DataTransform.py
rdc5ef15 rb0b09b9 24 24 """ 25 25 if not x > 0: 26 raise ValueError , "Transformation only accepts positive values."26 raise ValueError("Transformation only accepts positive values.") 27 27 else: 28 28 return x … … 50 50 """ 51 51 if not x >= 0: 52 raise ValueError , "square root of a negative value "52 raise ValueError("square root of a negative value ") 53 53 else: 54 54 return math.sqrt(x) … … 76 76 """ 77 77 if not x >= 0: 78 raise ValueError , "double square root of a negative value "78 raise ValueError("double square root of a negative value ") 79 79 else: 80 80 return math.sqrt(math.sqrt(x)) … … 90 90 """ 91 91 if not x > 0: 92 raise ValueError , "Log(x)of a negative value "92 raise ValueError("Log(x)of a negative value ") 93 93 else: 94 94 return math.log(x) … … 100 100 return 1 / x 101 101 else: 102 raise ValueError , "cannot divide by zero"102 raise ValueError("cannot divide by zero") 103 103 104 104 … … 109 109 return 1 / math.sqrt(y) 110 110 else: 111 raise ValueError , "transform.toOneOverSqrtX: cannot be computed"111 raise ValueError("transform.toOneOverSqrtX: cannot be computed") 112 112 113 113 … … 118 118 return math.log(y * (x ** 2)) 119 119 else: 120 raise ValueError , "transform.toLogYX2: cannot be computed"120 raise ValueError("transform.toLogYX2: cannot be computed") 121 121 122 122 … … 127 127 return math.log(math.pow(x, 4) * y) 128 128 else: 129 raise ValueError , "transform.toLogYX4: input error"129 raise ValueError("transform.toLogYX4: input error") 130 130 131 131 … … 149 149 """ 150 150 if not (x * y) > 0: 151 raise ValueError , "Log(X*Y)of a negative value "151 raise ValueError("Log(X*Y)of a negative value ") 152 152 else: 153 153 return math.log(x * y) … … 211 211 else: 212 212 msg = "transform.errFromX2: can't compute error of negative x" 213 raise ValueError , msg213 raise ValueError(msg) 214 214 215 215 … … 245 245 else: 246 246 msg = "transform.errFromX4: can't compute error of negative x" 247 raise ValueError , msg247 raise ValueError(msg) 248 248 249 249 … … 264 264 msg = "Transformation does not accept" 265 265 msg += " point that are consistent with zero." 266 raise ValueError , msg266 raise ValueError(msg) 267 267 if x != 0: 268 268 dx = dx / (x * math.log(10)) 269 269 else: 270 raise ValueError , "errToLogX: divide by zero"270 raise ValueError("errToLogX: divide by zero") 271 271 return dx 272 272 … … 287 287 dx = dx / x 288 288 else: 289 raise ValueError , "errToLogX: divide by zero"289 raise ValueError("errToLogX: divide by zero") 290 290 return dx 291 291 … … 312 312 msg = "Transformation does not accept point " 313 313 msg += " that are consistent with zero." 314 raise ValueError , msg314 raise ValueError(msg) 315 315 if x != 0 and y != 0: 316 316 if dx == None: … … 320 320 err = (dx / x) ** 2 + (dy / y) ** 2 321 321 else: 322 raise ValueError , "cannot compute this error"322 raise ValueError("cannot compute this error") 323 323 324 324 return math.sqrt(math.fabs(err)) … … 335 335 msg = "Transformation does not accept point" 336 336 msg += " that are consistent with zero." 337 raise ValueError , msg337 raise ValueError(msg) 338 338 if x > 0 and y > 0: 339 339 if dx == None: … … 343 343 err = (2.0 * dx / x) ** 2 + (dy / y) ** 2 344 344 else: 345 raise ValueError , "cannot compute this error"345 raise ValueError("cannot compute this error") 346 346 return math.sqrt(math.fabs(err)) 347 347 … … 357 357 err = dx / x ** 2 358 358 else: 359 raise ValueError , "Cannot compute this error"359 raise ValueError("Cannot compute this error") 360 360 return math.fabs(err) 361 361 … … 371 371 err = -1 / 2 * math.pow(x, -3.0 / 2.0) * dx 372 372 else: 373 raise ValueError , "Cannot compute this error"373 raise ValueError("Cannot compute this error") 374 374 return math.fabs(err) 375 375 … … 387 387 msg = "Transformation does not accept point " 388 388 msg += " that are consistent with zero." 389 raise ValueError , msg389 raise ValueError(msg) 390 390 if dx == None: 391 391 dx = 0 -
src/sas/qtgui/Plotting/Fittings.py
- Property mode changed from 100644 to 100755
radc49fc rb0b09b9 97 97 # Testing implementation 98 98 # Fit a Line model 99 from LineModel import LineModel99 from .LineModel import LineModel 100 100 line = LineModel() 101 101 cstA = Parameter(line, 'A', event.cstA) … … 104 104 chisqr, out, cov = sasfit(line, [cstA, cstB], event.x, y, 0) 105 105 # print "Output parameters:", out 106 print "The right answer is [70.0, 1.0]"107 print chisqr, out, cov106 print("The right answer is [70.0, 1.0]") 107 print(chisqr, out, cov) 108 108 -
src/sas/qtgui/Plotting/LineModel.py
rdc5ef15 rb0b09b9 81 81 elif x.__class__.__name__ == 'tuple': 82 82 msg = "Tuples are not allowed as input to BaseComponent models" 83 raise ValueError , msg83 raise ValueError(msg) 84 84 else: 85 85 return self._line(x) … … 103 103 elif x.__class__.__name__ == 'tuple': 104 104 msg = "Tuples are not allowed as input to BaseComponent models" 105 raise ValueError , msg105 raise ValueError(msg) 106 106 else: 107 107 return self._line(x) -
src/sas/qtgui/Plotting/LinearFit.py
- Property mode changed from 100644 to 100755
rdc5ef15 rb0b09b9 79 79 Overwrite default fit range label to correspond to actual unit 80 80 """ 81 assert(isinstance(label, basestring))81 assert(isinstance(label, str)) 82 82 self.lblRange.setText(label) 83 83 … … 195 195 for i in range(len(x)) if x[i] >= xmin_check] 196 196 else: 197 tempy = map(numpy.log10, y)198 tempdy = map(lambda t1,t2:DataTransform.errToLogX(t1,0,t2,0),y,dy)197 tempy = list(map(numpy.log10, y)) 198 tempdy = list(map(lambda t1,t2:DataTransform.errToLogX(t1,0,t2,0),y,dy)) 199 199 else: 200 200 tempy = y -
src/sas/qtgui/Plotting/PlotHelper.py
- Property mode changed from 100644 to 100755
r83eb5208 rb0b09b9 35 35 Returns a list of IDs for all currently active plots 36 36 """ 37 return this._plots.keys()37 return list(this._plots.keys()) 38 38 39 39 def plotById(plot_id): … … 48 48 """ 49 49 plot_id = None 50 for key in this._plots.keys():50 for key in list(this._plots.keys()): 51 51 if this._plots[key] == plot: 52 52 plot_id = key -
src/sas/qtgui/Plotting/PlotProperties.py
- Property mode changed from 100644 to 100755
rcd2cc745 rb0b09b9 26 26 27 27 # Fill out the color combobox 28 self.cbColor.addItems( COLORS.keys()[:-1])28 self.cbColor.addItems(list(COLORS.keys())[:-1]) 29 29 # data1d.custom_color can now be a simple integer, 30 30 # specifying COLORS dict index or a string containing … … 34 34 else: 35 35 # Need the Custom entry here. "Custom" is always last. 36 self.cbColor.addItems([ COLORS.keys()[-1]])37 self.cbColor.setCurrentIndex( COLORS.keys().index("Custom"))36 self.cbColor.addItems([list(COLORS.keys())[-1]]) 37 self.cbColor.setCurrentIndex(list(COLORS.keys()).index("Custom")) 38 38 39 39 # Fill out the marker combobox 40 self.cbShape.addItems( SHAPES.keys())40 self.cbShape.addItems(list(SHAPES.keys())) 41 41 try: 42 42 self.cbShape.setCurrentIndex(self._marker) … … 83 83 # Add Custom to the color combo box 84 84 self.cbColor.addItems(["Custom"]) 85 self.cbColor.setCurrentIndex( COLORS.keys().index("Custom"))85 self.cbColor.setCurrentIndex(list(COLORS.keys()).index("Custom")) 86 86 # unblock currentIndexChanged 87 87 self.cbColor.blockSignals(False) -
src/sas/qtgui/Plotting/PlotUtilities.py
- Property mode changed from 100644 to 100755
r83eb5208 rb0b09b9 273 273 # Check if it's within the range 274 274 if 0 <= color <=6: 275 color = COLORS.values()[color]275 color = list(COLORS.values())[color] 276 276 # Check if it's an RGB string 277 277 elif isinstance(color, str): -
src/sas/qtgui/Plotting/Plottables.py
rdc5ef15 rb0b09b9 239 239 selected_color = None 240 240 selected_plottable = None 241 for p in self.plottables.keys():241 for p in list(self.plottables.keys()): 242 242 if plottable.id == p.id: 243 243 selected_plottable = p … … 384 384 385 385 """ 386 raise NotImplemented , "Not a valid transform"386 raise NotImplemented("Not a valid transform") 387 387 388 388 # Related issues … … 512 512 label_dict[collection[0]] = basename 513 513 else: 514 for i in xrange(len(collection)):514 for i in range(len(collection)): 515 515 label_dict[collection[i]] = "%s %d" % (basename, i) 516 516 return label_dict … … 684 684 msg = "Plottable.View: Given x and dx are not" 685 685 msg += " of the same length" 686 raise ValueError , msg686 raise ValueError(msg) 687 687 # Check length of y array 688 688 if not len(y) == len(x): 689 689 msg = "Plottable.View: Given y " 690 690 msg += "and x are not of the same length" 691 raise ValueError , msg691 raise ValueError(msg) 692 692 693 693 if not dy is None and not len(dy) == 0 and not len(y) == len(dy): 694 694 msg = "Plottable.View: Given y and dy are not of the same " 695 695 msg += "length: len(y)=%s, len(dy)=%s" % (len(y), len(dy)) 696 raise ValueError , msg696 raise ValueError(msg) 697 697 self.x = [] 698 698 self.y = [] … … 729 729 msg = "Plottable.View: transformed x " 730 730 msg += "and y are not of the same length" 731 raise ValueError , msg731 raise ValueError(msg) 732 732 if has_err_x and not (len(self.x) == len(self.dx)): 733 733 msg = "Plottable.View: transformed x and dx" 734 734 msg += " are not of the same length" 735 raise ValueError , msg735 raise ValueError(msg) 736 736 if has_err_y and not (len(self.y) == len(self.dy)): 737 737 msg = "Plottable.View: transformed y" 738 738 msg += " and dy are not of the same length" 739 raise ValueError , msg739 raise ValueError(msg) 740 740 # Check that negative values are not plot on x and y axis for 741 741 # log10 transformation … … 809 809 except: 810 810 logging.error("check_data_logX: skipping point x %g", self.x[i]) 811 logging.error(sys.exc_ value)811 logging.error(sys.exc_info()[1]) 812 812 self.x = tempx 813 813 self.y = tempy … … 839 839 except: 840 840 logging.error("check_data_logY: skipping point %g", self.y[i]) 841 logging.error(sys.exc_ value)841 logging.error(sys.exc_info()[1]) 842 842 843 843 self.x = tempx … … 1101 1101 Plottable.__init__(self) 1102 1102 msg = "Theory1D is no longer supported, please use Data1D and change symbol.\n" 1103 raise DeprecationWarning , msg1103 raise DeprecationWarning(msg) 1104 1104 1105 1105 class PlottableFit1D(Plottable): -
src/sas/qtgui/Plotting/Plotter.py
- Property mode changed from 100644 to 100755
rf0bb711 rb0b09b9 87 87 marker = PlotUtilities.SHAPES[marker] 88 88 except KeyError: 89 marker = PlotUtilities.SHAPES.values()[marker]89 marker = list(PlotUtilities.SHAPES.values())[marker] 90 90 91 91 assert marker is not None … … 203 203 Adds operations on all plotted sets of data to the context menu 204 204 """ 205 for id in self.plot_dict.keys():205 for id in list(self.plot_dict.keys()): 206 206 plot = self.plot_dict[id] 207 207 … … 388 388 Deletes the selected plot from the chart 389 389 """ 390 if id not in self.plot_dict.keys():390 if id not in list(self.plot_dict.keys()): 391 391 return 392 392 … … 479 479 """ 480 480 # Transform all the plots on the chart 481 for id in self.plot_dict.keys():481 for id in list(self.plot_dict.keys()): 482 482 current_plot = self.plot_dict[id] 483 483 if current_plot.id == "fit": -
src/sas/qtgui/Plotting/SlicerModel.py
- Property mode changed from 100644 to 100755
r83eb5208 rb0b09b9 19 19 self._model.removeRows( 0, self._model.rowCount() ) 20 20 # Crete/overwrite model items 21 for parameter in parameters.keys():21 for parameter in list(parameters.keys()): 22 22 item1 = QtGui.QStandardItem(parameter) 23 23 item2 = QtGui.QStandardItem(GuiUtils.formatNumber(parameters[parameter])) -
src/sas/qtgui/Plotting/Slicers/AnnulusSlicer.py
rdc5ef15 rb0b09b9 4 4 5 5 import sas.qtgui.Utilities.GuiUtils as GuiUtils 6 from BaseInteractor import BaseInteractor6 from .BaseInteractor import BaseInteractor 7 7 from sas.qtgui.Plotting.PlotterData import Data1D 8 8 from sas.qtgui.Utilities.GuiUtils import formatNumber -
src/sas/qtgui/Plotting/Slicers/Arc.py
rdc5ef15 rb0b09b9 4 4 import math 5 5 6 from BaseInteractor import BaseInteractor6 from .BaseInteractor import BaseInteractor 7 7 8 8 class ArcInteractor(BaseInteractor): -
src/sas/qtgui/Plotting/Slicers/AzimutSlicer.py
rdc5ef15 rb0b09b9 5 5 # 6 6 import math 7 from BaseInteractor import BaseInteractor7 from .BaseInteractor import BaseInteractor 8 8 9 9 class SectorInteractor(BaseInteractor): … … 26 26 27 27 # Inner circle 28 from Arc import ArcInteractor28 from .Arc import ArcInteractor 29 29 self.inner_circle = ArcInteractor(self, self.base.subplot, 30 30 zorder=zorder, -
src/sas/qtgui/Plotting/Slicers/BoxSlicer.py
rdc5ef15 rb0b09b9 3 3 from PyQt4 import QtCore 4 4 5 from BaseInteractor import BaseInteractor5 from .BaseInteractor import BaseInteractor 6 6 from sas.qtgui.Plotting.PlotterData import Data1D 7 7 import sas.qtgui.Utilities.GuiUtils as GuiUtils … … 136 136 if new_slab is None: 137 137 msg = "post data:cannot average , averager is empty" 138 raise ValueError , msg138 raise ValueError(msg) 139 139 self.averager = new_slab 140 140 if self.direction == "X": … … 152 152 else: 153 153 msg = "post data:no Box Average direction was supplied" 154 raise ValueError , msg154 raise ValueError(msg) 155 155 # # Average data2D given Qx or Qy 156 156 box = self.averager(x_min=x_min, x_max=x_max, y_min=y_min, y_max=y_max, -
src/sas/qtgui/Plotting/Slicers/BoxSum.py
rdc5ef15 rb0b09b9 8 8 from sas.qtgui.Utilities.GuiUtils import formatNumber 9 9 10 from BaseInteractor import BaseInteractor10 from .BaseInteractor import BaseInteractor 11 11 from sas.sascalc.dataloader.manipulations import Boxavg 12 12 from sas.sascalc.dataloader.manipulations import Boxsum -
src/sas/qtgui/Plotting/Slicers/SectorSlicer.py
rdc5ef15 rb0b09b9 6 6 from PyQt4 import QtCore 7 7 8 from BaseInteractor import BaseInteractor8 from .BaseInteractor import BaseInteractor 9 9 from sas.qtgui.Plotting.PlotterData import Data1D 10 10 import sas.qtgui.Utilities.GuiUtils as GuiUtils … … 230 230 msg = "Phi left and phi right are different" 231 231 msg += " %f, %f" % (self.left_line.phi, self.right_line.phi) 232 raise ValueError , msg232 raise ValueError(msg) 233 233 params["Phi [deg]"] = self.main_line.theta * 180 / numpy.pi 234 234 params["Delta_Phi [deg]"] = numpy.fabs(self.left_line.phi * 180 / numpy.pi) -
src/sas/qtgui/Utilities/CategoryInstaller.py
r125c4be rb0b09b9 103 103 master_category_dict[category].append(\ 104 104 (model, model_enabled_dict[model])) 105 return OrderedDict(sorted( master_category_dict.items(), key=lambda t: t[0]))105 return OrderedDict(sorted(list(master_category_dict.items()), key=lambda t: t[0])) 106 106 107 107 @staticmethod … … 126 126 """ 127 127 _model_dict = { model.name: model for model in model_list} 128 _model_list = _model_dict.keys()128 _model_list = list(_model_dict.keys()) 129 129 130 130 serialized_file = None … … 143 143 add_list = _model_list 144 144 del_name = False 145 for cat in master_category_dict.keys():145 for cat in list(master_category_dict.keys()): 146 146 for ind in range(len(master_category_dict[cat])): 147 147 model_name, enabled = master_category_dict[cat][ind] … … 152 152 model_enabled_dict.pop(model_name) 153 153 except: 154 logging.error("CategoryInstaller: %s", sys.exc_ value)154 logging.error("CategoryInstaller: %s", sys.exc_info()[1]) 155 155 else: 156 156 add_list.remove(model_name) -
src/sas/qtgui/Utilities/ConnectionProxy.py
rdc5ef15 rb0b09b9 1 1 #!/usr/bin/env python 2 2 # -*- coding: utf-8 -*- 3 import urllib 23 import urllib.request, urllib.error, urllib.parse 4 4 import sys 5 5 import json … … 33 33 if sys.platform == 'win32': 34 34 try: 35 import _winreg as winreg # used from python 2.0-2.635 import winreg as winreg # used from python 2.0-2.6 36 36 except: 37 37 import winreg # used from python 2.7 onwards … … 45 45 this_name, this_val, this_type = winreg.EnumValue(net, i) 46 46 subkeys[this_name] = this_val 47 if 'AutoConfigURL' in subkeys.keys() and len(subkeys['AutoConfigURL']) > 0:47 if 'AutoConfigURL' in list(subkeys.keys()) and len(subkeys['AutoConfigURL']) > 0: 48 48 pac_files.append(subkeys['AutoConfigURL']) 49 49 elif sys.platform == 'darwin': … … 53 53 networks = sys_prefs['NetworkServices'] 54 54 # loop through each possible network (e.g. Ethernet, Airport...) 55 for network in networks.items():55 for network in list(networks.items()): 56 56 # the first part is a long identifier 57 57 net_key, network = network 58 if 'ProxyAutoConfigURLString' in network['Proxies'].keys():58 if 'ProxyAutoConfigURLString' in list(network['Proxies'].keys()): 59 59 pac_files.append( 60 60 network['Proxies']['ProxyAutoConfigURLString']) … … 73 73 logging.debug('Trying pac file (%s)...' % this_pac_url) 74 74 try: 75 response = urllib 2.urlopen(75 response = urllib.request.urlopen( 76 76 this_pac_url, timeout=self.timeout) 77 77 logging.debug('Succeeded (%s)...' % this_pac_url) … … 101 101 # information is retrieved from the OS X System Configuration 102 102 # Framework. 103 proxy = urllib 2.ProxyHandler()103 proxy = urllib.request.ProxyHandler() 104 104 else: 105 105 # If proxies is given, it must be a dictionary mapping protocol names to 106 106 # URLs of proxies. 107 proxy = urllib 2.ProxyHandler(proxy_dic)108 opener = urllib 2.build_opener(proxy)109 urllib 2.install_opener(opener)107 proxy = urllib.request.ProxyHandler(proxy_dic) 108 opener = urllib.request.build_opener(proxy) 109 urllib.request.install_opener(opener) 110 110 111 111 def connect(self): … … 114 114 @return: response object from urllib2.urlopen 115 115 ''' 116 req = urllib 2.Request(self.url)116 req = urllib.request.Request(self.url) 117 117 response = None 118 118 try: 119 119 logging.debug("Trying Direct connection to %s..."%self.url) 120 response = urllib 2.urlopen(req, timeout=self.timeout)121 except Exception ,e:120 response = urllib.request.urlopen(req, timeout=self.timeout) 121 except Exception as e: 122 122 logging.debug("Failed!") 123 123 logging.debug(e) … … 125 125 logging.debug("Trying to use system proxy if it exists...") 126 126 self._set_proxy() 127 response = urllib 2.urlopen(req, timeout=self.timeout)128 except Exception ,e:127 response = urllib.request.urlopen(req, timeout=self.timeout) 128 except Exception as e: 129 129 logging.debug("Failed!") 130 130 logging.debug(e) … … 135 135 logging.debug("Trying to use the proxy %s found in proxy.pac configuration"%proxy) 136 136 self._set_proxy(proxy) 137 response = urllib 2.urlopen(req, timeout=self.timeout)138 except Exception ,e:137 response = urllib.request.urlopen(req, timeout=self.timeout) 138 except Exception as e: 139 139 logging.debug("Failed!") 140 140 logging.debug(e) … … 151 151 response = c.connect() 152 152 if response is not None: 153 print 50 * '-'153 print(50 * '-') 154 154 content = json.loads(response.read().strip()) 155 155 pprint(content) -
src/sas/qtgui/Utilities/GuiUtils.py
- Property mode changed from 100644 to 100755
r88e1f57 rb0b09b9 9 9 import warnings 10 10 import webbrowser 11 import url parse11 import urllib.parse 12 12 13 13 warnings.simplefilter("ignore") … … 86 86 #logging.error("Error loading %s/%s: %s" % (path, confg_file, sys.exc_value)) 87 87 except ValueError: 88 print "Value error"88 print("Value error") 89 89 pass 90 90 finally: … … 242 242 """ 243 243 assert isinstance(item, QtGui.QStandardItem) 244 assert isinstance(update_data, QtCore.QVariant) 245 py_update_data = update_data.toPyObject() 244 #assert isinstance(update_data, QtCore.QVariant) 245 #py_update_data = update_data.toPyObject() 246 py_update_data = update_data 246 247 247 248 # Check if data with the same ID is already present … … 249 250 plot_item = item.child(index) 250 251 if plot_item.isCheckable(): 251 plot_data = plot_item.child(0).data() .toPyObject()252 plot_data = plot_item.child(0).data() #.toPyObject() 252 253 if plot_data.id is not None and plot_data.id == py_update_data.id: 253 254 # replace data section in item … … 270 271 Adds QVariant 'update_data' to that row. 271 272 """ 272 assert isinstance(update_data, QtCore.QVariant) 273 py_update_data = update_data.toPyObject() 273 #assert isinstance(update_data, QtCore.QVariant) 274 #py_update_data = update_data.toPyObject() 275 py_update_data = update_data 274 276 275 277 checkbox_item = QtGui.QStandardItem() … … 309 311 object_item = QtGui.QStandardItem() 310 312 object_item.setText(name) 311 object_item.setData(QtCore.QVariant(update_data)) 313 #object_item.setData(QtCore.QVariant(update_data)) 314 object_item.setData(update_data) 312 315 313 316 # Append the new row to the main item … … 319 322 """ 320 323 assert isinstance(model_item, QtGui.QStandardItemModel) 321 assert isinstance(filename, basestring)324 assert isinstance(filename, str) 322 325 323 326 # Iterate over model looking for named items 324 item = list(filter(lambda i: str(i.text()) == filename, 325 [model_item.item(index) for index in range(model_item.rowCount())])) 327 item = list([i for i in [model_item.item(index) for index in range(model_item.rowCount())] if str(i.text()) == filename]) 326 328 return item[0] if len(item)>0 else None 327 329 … … 331 333 """ 332 334 assert isinstance(model_item, QtGui.QStandardItemModel) 333 assert isinstance(filename, basestring)335 assert isinstance(filename, str) 334 336 335 337 plot_data = [] … … 339 341 if str(item.text()) == filename: 340 342 # TODO: assure item type is correct (either data1/2D or Plotter) 341 plot_data.append(item.child(0).data() .toPyObject())343 plot_data.append(item.child(0).data()) #.toPyObject()) 342 344 # Going 1 level deeper only 343 345 for index_2 in range(item.rowCount()): … … 345 347 if item_2 and item_2.isCheckable(): 346 348 # TODO: assure item type is correct (either data1/2D or Plotter) 347 plot_data.append(item_2.child(0).data() .toPyObject())349 plot_data.append(item_2.child(0).data()) #.toPyObject()) 348 350 349 351 return plot_data … … 361 363 if item.isCheckable() and item.checkState() == QtCore.Qt.Checked: 362 364 # TODO: assure item type is correct (either data1/2D or Plotter) 363 plot_data.append((item, item.child(0).data() .toPyObject()))365 plot_data.append((item, item.child(0).data())) #.toPyObject())) 364 366 # Going 1 level deeper only 365 367 for index_2 in range(item.rowCount()): … … 367 369 if item_2 and item_2.isCheckable() and item_2.checkState() == QtCore.Qt.Checked: 368 370 # TODO: assure item type is correct (either data1/2D or Plotter) 369 plot_data.append((item_2, item_2.child(0).data() .toPyObject()))371 plot_data.append((item_2, item_2.child(0).data())) #.toPyObject())) 370 372 371 373 return plot_data … … 419 421 Check the URL first, though. 420 422 """ 421 parsed_url = url parse.urlparse(url)423 parsed_url = urllib.parse.urlparse(url) 422 424 if parsed_url.scheme: 423 425 webbrowser.open(url) 424 426 else: 425 427 msg = "Attempt at opening an invalid URL" 426 raise AttributeError , msg428 raise AttributeError(msg) 427 429 428 430 def retrieveData1d(data): … … 433 435 if not isinstance(data, Data1D): 434 436 msg = "Incorrect type passed to retrieveData1d" 435 raise AttributeError , msg437 raise AttributeError(msg) 436 438 try: 437 439 xmin = min(data.x) … … 441 443 data.filename 442 444 #logging.error(msg) 443 raise ValueError , msg445 raise ValueError(msg) 444 446 445 447 text = data.__str__() … … 485 487 if not isinstance(data, Data2D): 486 488 msg = "Incorrect type passed to retrieveData2d" 487 raise AttributeError , msg489 raise AttributeError(msg) 488 490 489 491 text = data.__str__() … … 499 501 dy_val = 0.0 500 502 len_data = len(data.qx_data) 501 for index in xrange(0, len_data):503 for index in range(0, len_data): 502 504 x_val = data.qx_data[index] 503 505 y_val = data.qy_data[index] … … 756 758 The assumption - data stored in SasView standard, in child 0 757 759 """ 758 return item.child(0).data() .toPyObject()760 return item.child(0).data() #.toPyObject() 759 761 760 762 def formatNumber(value, high=False): -
src/sas/qtgui/Utilities/LocalConfig.py
- Property mode changed from 100644 to 100755
rdc5ef15 rb0b09b9 139 139 """ 140 140 if __EVT_DEBUG__: 141 print "%g: %s" % (time.clock(), message)141 print("%g: %s" % (time.clock(), message)) 142 142 143 143 if __EVT_DEBUG_2_FILE__: -
src/sas/qtgui/Utilities/ObjectLibrary.py
r61a92d4 rb0b09b9 9 9 10 10 def deleteObjectByRef(obj): 11 for name, object in this._objects.ite ritems():11 for name, object in this._objects.items(): 12 12 if object == obj: 13 13 del this._objects[name] … … 22 22 23 23 def listObjects(): 24 return this._objects.keys()24 return list(this._objects.keys()) 25 25 26 26 -
src/sas/qtgui/Utilities/SasviewLogger.py
- Property mode changed from 100644 to 100755
r83eb5208 rb0b09b9 19 19 def write(self, msg): 20 20 if(not self.signalsBlocked()): 21 self.messageWritten.emit( unicode(msg))21 self.messageWritten.emit(str(msg)) 22 22 23 23 @staticmethod -
src/sas/qtgui/convertUI.py
rcd2cc745 rb0b09b9 8 8 9 9 def pyuic(in_file, out_file): 10 """ Run the pyuic 4script"""10 """ Run the pyuic5 script""" 11 11 execute = 'pyuic4 -o %s %s' % (out_file, in_file) 12 12 os.system(execute) -
src/sas/sascalc/fit/expression.py
r574adc7 rb0b09b9 210 210 211 211 #print("Function: "+functiondef) 212 exec functiondef in globals,locals212 exec (functiondef in globals,locals) 213 213 retfn = locals['eval_expressions'] 214 214
Note: See TracChangeset
for help on using the changeset viewer.