本文整理汇总了Python中mantid.kernel.ConfigService类的典型用法代码示例。如果您正苦于以下问题:Python ConfigService类的具体用法?Python ConfigService怎么用?Python ConfigService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ConfigService类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, multifileinterpreter, main_window=None, globalfiguremanager=None):
"""
Project Recovery class is aimed at allowing you to recovery your workbench project should you crash for whatever
reason
:param multifileinterpreter: MultiPythonFileInterpreter; An object that is used in workbench to represent the
python script editor
:param main_window: A reference to the main window object to be used as a parent to the project recovery GUIs
:param globalfiguremanager: Based on the globalfiguremanager object expects an object with a dictionary on
cls/self.figs for the object passed here which contains all of the plots open/needed to be saved
"""
self._recovery_directory = os.path.join(ConfigService.getAppDataDirectory(),
self.recovery_workbench_recovery_name)
self._recovery_directory_hostname = os.path.join(self.recovery_directory, socket.gethostname())
self._recovery_directory_pid = os.path.join(self.recovery_directory_hostname, str(os.getpid()))
self._recovery_order_workspace_history_file = os.path.join(ConfigService.getAppDataDirectory(),
self.recovery_ordered_recovery_file_name)
self.recovery_enabled = ("true" == ConfigService[RECOVERY_ENABLED_KEY].lower())
self.maximum_num_checkpoints = int(ConfigService[NO_OF_CHECKPOINTS_KEY])
self.time_between_saves = int(ConfigService[SAVING_TIME_KEY]) # seconds
# The recovery GUI's presenter is set when needed
self.recovery_presenter = None
self.thread_on = False
# Set to true by workbench on close to kill the thread on completion of project save
self.closing_workbench = False
# Recovery loader and saver
self.loader = ProjectRecoveryLoader(self, multi_file_interpreter=multifileinterpreter, main_window=main_window)
self.saver = ProjectRecoverySaver(self, globalfiguremanager)
开发者ID:mantidproject,项目名称:mantid,代码行数:33,代码来源:projectrecovery.py
示例2: test_update_and_set_facility
def test_update_and_set_facility(self):
self.assertFalse("TEST" in config.getFacilityNames())
ConfigService.updateFacilities(
os.path.join(ConfigService.getInstrumentDirectory(), "IDFs_for_UNIT_TESTING/UnitTestFacilities.xml")
)
ConfigService.setFacility("TEST")
self.assertEquals(config.getFacility().name(), "TEST")
self.assertRaises(RuntimeError, config.getFacility, "SNS")
开发者ID:rosswhitfield,项目名称:mantid,代码行数:8,代码来源:ConfigServiceTest.py
示例3: action_facility_changed
def action_facility_changed(self, new_facility):
"""
When the facility is changed, refreshes all available instruments that can be selected in the dropdown.
:param new_facility: The name of the new facility that was selected
"""
ConfigService.setFacility(new_facility)
# refresh the instrument selection to contain instruments about the selected facility only
self.view.instrument.clear()
self.view.instrument.addItems(
[instr.name() for instr in ConfigService.getFacility(new_facility).instruments()])
开发者ID:mantidproject,项目名称:mantid,代码行数:10,代码来源:presenter.py
示例4: load_current_setting_values
def load_current_setting_values(self):
self.view.prompt_save_on_close.setChecked(CONF.get(self.PROMPT_SAVE_ON_CLOSE))
self.view.prompt_save_editor_modified.setChecked(CONF.get(self.PROMPT_SAVE_EDITOR_MODIFIED))
# compare lower-case, because MantidPlot will save it as lower case,
# but Python will have the bool's first letter capitalised
pr_enabled = ("true" == ConfigService.getString(self.PR_RECOVERY_ENABLED).lower())
pr_time_between_recovery = int(ConfigService.getString(self.PR_TIME_BETWEEN_RECOVERY))
pr_number_checkpoints = int(ConfigService.getString(self.PR_NUMBER_OF_CHECKPOINTS))
self.view.project_recovery_enabled.setChecked(pr_enabled)
self.view.time_between_recovery.setValue(pr_time_between_recovery)
self.view.total_number_checkpoints.setValue(pr_number_checkpoints)
开发者ID:mantidproject,项目名称:mantid,代码行数:13,代码来源:presenter.py
示例5: setup_facilities_group
def setup_facilities_group(self):
facilities = ConfigService.getFacilityNames()
self.view.facility.addItems(facilities)
default_facility = ConfigService.getFacility().name()
self.view.facility.setCurrentIndex(self.view.facility.findText(default_facility))
self.action_facility_changed(default_facility)
self.view.facility.currentTextChanged.connect(self.action_facility_changed)
default_instrument = ConfigService.getInstrument().name()
self.view.instrument.setCurrentIndex(self.view.instrument.findText(default_instrument))
self.action_instrument_changed(default_instrument)
self.view.instrument.currentTextChanged.connect(self.action_instrument_changed)
开发者ID:mantidproject,项目名称:mantid,代码行数:13,代码来源:presenter.py
示例6: test_constructor_settings_are_set
def test_constructor_settings_are_set(self):
# Test the paths set in the constructor that are generated.
self.assertEqual(self.pr.recovery_directory,
os.path.join(ConfigService.getAppDataDirectory(), "workbench-recovery"))
self.assertEqual(self.pr.recovery_directory_hostname,
os.path.join(ConfigService.getAppDataDirectory(), "workbench-recovery", socket.gethostname()))
self.assertEqual(self.pr.recovery_directory_pid,
os.path.join(ConfigService.getAppDataDirectory(), "workbench-recovery", socket.gethostname(),
str(os.getpid())))
self.assertEqual(self.pr.recovery_order_workspace_history_file,
os.path.join(ConfigService.getAppDataDirectory(), "ordered_recovery.py"))
# Test config service values
self.assertEqual(self.pr.time_between_saves, int(ConfigService[SAVING_TIME_KEY]))
self.assertEqual(self.pr.maximum_num_checkpoints, int(ConfigService[NO_OF_CHECKPOINTS_KEY]))
self.assertEqual(self.pr.recovery_enabled, ("true" == ConfigService[RECOVERY_ENABLED_KEY].lower()))
开发者ID:mantidproject,项目名称:mantid,代码行数:16,代码来源:test_projectrecovery.py
示例7: remove_output_files
def remove_output_files(list_of_names=None):
"""Removes output files created during a test."""
# import ConfigService here to avoid:
# RuntimeError: Pickling of "mantid.kernel._kernel.ConfigServiceImpl"
# instances is not enabled (http://www.boost.org/libs/python/doc/v2/pickle.html)
from mantid.kernel import ConfigService
if not isinstance(list_of_names, list):
raise ValueError("List of names is expected.")
if not all(isinstance(i, str) for i in list_of_names):
raise ValueError("Each name should be a string.")
save_dir_path = ConfigService.getString("defaultsave.directory")
if save_dir_path != "": # default save directory set
all_files = os.listdir(save_dir_path)
else:
all_files = os.listdir(os.getcwd())
for filename in all_files:
for name in list_of_names:
if name in filename:
full_path = os.path.join(save_dir_path, filename)
if os.path.isfile(full_path):
os.remove(full_path)
break
开发者ID:mantidproject,项目名称:mantid,代码行数:27,代码来源:AbinsTestHelpers.py
示例8: setup_checkbox_signals
def setup_checkbox_signals(self):
self.view.show_invisible_workspaces.setChecked(
"true" == ConfigService.getString(self.SHOW_INVISIBLE_WORKSPACES).lower())
self.view.show_invisible_workspaces.stateChanged.connect(self.action_show_invisible_workspaces)
self.view.project_recovery_enabled.stateChanged.connect(self.action_project_recovery_enabled)
self.view.time_between_recovery.valueChanged.connect(self.action_time_between_recovery)
self.view.total_number_checkpoints.valueChanged.connect(self.action_total_number_checkpoints)
开发者ID:mantidproject,项目名称:mantid,代码行数:8,代码来源:presenter.py
示例9: test_timezones
def test_timezones(self):
# verify that all of the timezones can get converted by pytz
for facility in ConfigService.getFacilities():
if len(facility.timezone()) == 0:
continue # don't test empty strings
tz = pytz.timezone(facility.timezone())
print(facility.name(), tz)
self.assertEquals(str(tz), facility.timezone())
开发者ID:mantidproject,项目名称:mantid,代码行数:8,代码来源:FacilityInfoTest.py
示例10: getValidInstruments
def getValidInstruments(self):
instruments = ['']
for name in ['SNS', 'HFIR']:
facility = ConfigService.getFacility(name)
facilityInstruments = sorted([item.shortName()
for item in facility.instruments()
if item != 'DAS'])
instruments.extend(facilityInstruments)
return instruments
开发者ID:rosswhitfield,项目名称:mantid,代码行数:11,代码来源:GetIPTS.py
示例11: get_number_of_checkpoints
def get_number_of_checkpoints():
"""
:return: int; The maximum number of checkpoints project recovery should allow
"""
try:
return int(ConfigService.getString("projectRecovery.numberOfCheckpoints"))
except Exception as e:
if isinstance(e, KeyboardInterrupt):
raise
# Fail silently and return 5 (the default)
return DEFAULT_NUM_CHECKPOINTS
开发者ID:mantidproject,项目名称:mantid,代码行数:11,代码来源:projectrecoverymodel.py
示例12: get_default_grouping
def get_default_grouping(instrument, main_field_direction):
parameter_name = "Default grouping file"
if instrument == "MUSR":
parameter_name += " - " + main_field_direction
try:
grouping_file = ConfigService.getInstrument(instrument).getStringParameter(parameter_name)[0]
except IndexError:
return [], []
instrument_directory = ConfigServiceImpl.Instance().getInstrumentDirectory()
filename = instrument_directory + grouping_file
new_groups, new_pairs = load_utils.load_grouping_from_XML(filename)
return new_groups, new_pairs
开发者ID:samueljackson92,项目名称:mantid,代码行数:12,代码来源:muon_data_context.py
示例13: closeEvent
def closeEvent(self, event):
# Check whether or not to save project
if not self.project.saved:
# Offer save
if self.project.offer_save(self):
# Cancel has been clicked
event.ignore()
return
# Close editors
if self.editor.app_closing():
# write out any changes to the mantid config file
ConfigService.saveConfig(ConfigService.getUserFilename())
# write current window information to global settings object
self.writeSettings(CONF)
# Close all open plots
# We don't want this at module scope here
import matplotlib.pyplot as plt # noqa
plt.close('all')
app = QApplication.instance()
if app is not None:
app.closeAllWindows()
# Kill the project recovery thread and don't restart should a save be in progress and clear out current
# recovery checkpoint as it is closing properly
self.project_recovery.stop_recovery_thread()
self.project_recovery.closing_workbench = True
self.project_recovery.remove_current_pid_folder()
self.interface_manager.closeHelpWindow()
event.accept()
else:
# Cancel was pressed when closing an editor
event.ignore()
开发者ID:mantidproject,项目名称:mantid,代码行数:36,代码来源:mainwindow.py
示例14: __init__
def __init__(self, input_filename=None, group_name=None):
if isinstance(input_filename, str):
self._input_filename = input_filename
try:
self._hash_input_filename = self.calculate_ab_initio_file_hash()
except IOError as err:
logger.error(str(err))
except ValueError as err:
logger.error(str(err))
# extract name of file from the full path in the platform independent way
filename = os.path.basename(self._input_filename)
if filename.strip() == "":
raise ValueError("Name of the file cannot be an empty string.")
else:
raise ValueError("Invalid name of input file. String was expected.")
if isinstance(group_name, str):
self._group_name = group_name
else:
raise ValueError("Invalid name of the group. String was expected.")
core_name = filename[0:filename.rfind(".")]
save_dir_path = ConfigService.getString("defaultsave.directory")
self._hdf_filename = os.path.join(save_dir_path, core_name + ".hdf5") # name of hdf file
try:
self._advanced_parameters = self._get_advanced_parameters()
except IOError as err:
logger.error(str(err))
except ValueError as err:
logger.error(str(err))
self._attributes = {} # attributes for group
# data for group; they are expected to be numpy arrays or
# complex data sets which have the form of Python dictionaries or list of Python
# dictionaries
self._data = {}
开发者ID:DanNixon,项目名称:mantid,代码行数:43,代码来源:IOmodule.py
示例15: __updateAlignAndFocusArgs
def __updateAlignAndFocusArgs(self, wkspname):
self.log().debug('__updateAlignAndFocusArgs(%s)' % wkspname)
# if the files are missing, there is nothing to do
if (CAL_FILE not in self.kwargs) and (GROUP_FILE not in self.kwargs):
self.log().debug('--> Nothing to do')
return
self.log().debug('--> Updating')
# delete the files from the list of kwargs
if CAL_FILE in self.kwargs:
del self.kwargs[CAL_FILE]
if CAL_FILE in self.kwargs:
del self.kwargs[GROUP_FILE]
# get the instrument name
instr = mtd[wkspname].getInstrument().getName()
instr = ConfigService.getInstrument(instr).shortName()
# use the canonical names if they weren't specifed
for key, ext in zip((CAL_WKSP, GRP_WKSP, MASK_WKSP),
('_cal', '_group', '_mask')):
if key not in self.kwargs:
self.kwargs[key] = instr + ext
开发者ID:samueljackson92,项目名称:mantid,代码行数:23,代码来源:AlignAndFocusPowderFromFiles.py
示例16: __init__
def __init__(self, initial_type):
self._save_directory = ConfigService.getString('defaultsave.directory')
self._type_factory_dict = {BinningType.SaveAsEventData: SaveAsEventData(),
BinningType.Custom: CustomBinning(),
BinningType.FromMonitors: BinningFromMonitors()}
self._settings, self._type = self._settings_from_type(initial_type)
开发者ID:mantidproject,项目名称:mantid,代码行数:6,代码来源:summation_settings.py
示例17: _get_test_facility
def _get_test_facility(self):
return ConfigService.getFacility("ISIS")
开发者ID:mantidproject,项目名称:mantid,代码行数:2,代码来源:FacilityInfoTest.py
示例18: action_project_recovery_enabled
def action_project_recovery_enabled(self, state):
ConfigService.setString(self.PR_RECOVERY_ENABLED, str(bool(state)))
开发者ID:mantidproject,项目名称:mantid,代码行数:2,代码来源:presenter.py
示例19: __init__
def __init__(self, Ion, Symmetry, **kwargs):
"""
Constructor.
@param Ion: A rare earth ion. Possible values:
Ce, Pr, Nd, Pm, Sm, Eu, Gd, Tb, Dy, Ho, Er, Tm, Yb
@param Symmetry: Symmetry of the field. Possible values:
C1, Ci, C2, Cs, C2h, C2v, D2, D2h, C4, S4, C4h, D4, C4v, D2d, D4h, C3,
S6, D3, C3v, D3d, C6, C3h, C6h, D6, C6v, D3h, D6h, T, Td, Th, O, Oh
@param kwargs: Other field parameters and attributes. Acceptable values include:
ToleranceEnergy: energy tolerance,
ToleranceIntensity: intensity tolerance,
ResolutionModel: A resolution model.
FWHMVariation: Absolute value of allowed variation of a peak width during a fit.
FixAllPeaks: A boolean flag that fixes all parameters of the peaks.
Field parameters:
BmolX: The x-component of the molecular field,
BmolY: The y-component of the molecular field,
BmolZ: The z-component of the molecular field,
BextX: The x-component of the external field,
BextY: The y-component of the external field,
BextZ: The z-component of the external field,
B20: Real part of the B20 field parameter,
B21: Real part of the B21 field parameter,
B22: Real part of the B22 field parameter,
B40: Real part of the B40 field parameter,
B41: Real part of the B41 field parameter,
B42: Real part of the B42 field parameter,
B43: Real part of the B43 field parameter,
B44: Real part of the B44 field parameter,
B60: Real part of the B60 field parameter,
B61: Real part of the B61 field parameter,
B62: Real part of the B62 field parameter,
B63: Real part of the B63 field parameter,
B64: Real part of the B64 field parameter,
B65: Real part of the B65 field parameter,
B66: Real part of the B66 field parameter,
IB21: Imaginary part of the B21 field parameter,
IB22: Imaginary part of the B22 field parameter,
IB41: Imaginary part of the B41 field parameter,
IB42: Imaginary part of the B42 field parameter,
IB43: Imaginary part of the B43 field parameter,
IB44: Imaginary part of the B44 field parameter,
IB61: Imaginary part of the B61 field parameter,
IB62: Imaginary part of the B62 field parameter,
IB63: Imaginary part of the B63 field parameter,
IB64: Imaginary part of the B64 field parameter,
IB65: Imaginary part of the B65 field parameter,
IB66: Imaginary part of the B66 field parameter,
Each of the following parameters can be either a single float or an array of floats.
They are either all floats or all arrays of the same size.
IntensityScaling: A scaling factor for the intensity of each spectrum.
FWHM: A default value for the full width at half maximum of the peaks.
Temperature: A temperature "of the spectrum" in Kelvin
"""
# This is to make sure that Lorentzians get evaluated properly
ConfigService.setString('curvefitting.peakRadius', str(100))
from .function import PeaksFunction
self._ion = Ion
self._symmetry = Symmetry
self._toleranceEnergy = 1e-10
self._toleranceIntensity = 1e-1
self._fieldParameters = {}
self._fieldTies = {}
self._fieldConstraints = []
self._temperature = None
self._FWHM = None
self._intensityScaling = 1.0
self._resolutionModel = None
self._fwhmVariation = None
self._fixAllPeaks = False
for key in kwargs:
if key == 'ToleranceEnergy':
self._toleranceEnergy = kwargs[key]
elif key == 'ToleranceIntensity':
self._toleranceIntensity = kwargs[key]
elif key == 'IntensityScaling':
self._intensityScaling = kwargs[key]
elif key == 'FWHM':
self._FWHM = kwargs[key]
elif key == 'ResolutionModel':
self.ResolutionModel = kwargs[key]
elif key == 'Temperature':
self._temperature = kwargs[key]
elif key == 'FWHMVariation':
self._fwhmVariation = kwargs[key]
elif key == 'FixAllPeaks':
self._fixAllPeaks = kwargs[key]
else:
# Crystal field parameters
self._fieldParameters[key] = kwargs[key]
#.........这里部分代码省略.........
开发者ID:rosswhitfield,项目名称:mantid,代码行数:101,代码来源:fitting.py
示例20: action_time_between_recovery
def action_time_between_recovery(self, value):
ConfigService.setString(self.PR_TIME_BETWEEN_RECOVERY, str(value))
开发者ID:mantidproject,项目名称:mantid,代码行数:2,代码来源:presenter.py
注:本文中的mantid.kernel.ConfigService类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论