当前位置: 首页>>代码示例>>Python>>正文


Python Logger.get方法代码示例

本文整理汇总了Python中mantid.kernel.Logger.get方法的典型用法代码示例。如果您正苦于以下问题:Python Logger.get方法的具体用法?Python Logger.get怎么用?Python Logger.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mantid.kernel.Logger的用法示例。


在下文中一共展示了Logger.get方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: SaveIqAscii

# 需要导入模块: from mantid.kernel import Logger [as 别名]
# 或者: from mantid.kernel.Logger import get [as 别名]
def SaveIqAscii(reducer=None, process=''):
    """ Old command for backward compatibility """
    output_dir = os.path.expanduser('~')
    msg = "SaveIqAscii is not longer used:\n  "
    msg += "Please use 'SaveIq' instead\n  "
    msg += "Your output files are currently in %s" % output_dir
    Logger.get("CommandInterface").warning(msg)
    ReductionSingleton().reduction_properties["OutputDirectory"] = output_dir
    ReductionSingleton().reduction_properties["ProcessInfo"] = str(process)
开发者ID:trnielsen,项目名称:mantid,代码行数:11,代码来源:hfir_command_interface.py

示例2: find_data

# 需要导入模块: from mantid.kernel import Logger [as 别名]
# 或者: from mantid.kernel.Logger import get [as 别名]
def find_data(file, instrument='', allow_multiple=False):
    """
        Finds a file path for the specified data set, which can either be:
            - a run number
            - an absolute path
            - a file name
        @param file: file name or part of a file name
        @param instrument: if supplied, FindNeXus will be tried as a last resort
    """
    # First, assume a file name
    file = str(file).strip()
    
    # If we allow multiple files, users may use ; as a separator,
    # which is incompatible with the FileFinder
    n_files = 1
    if allow_multiple:
        file=file.replace(';',',')
        toks = file.split(',')
        n_files = len(toks)
    
    instrument = str(instrument)
    file_path = FileFinder.getFullPath(file)
    if os.path.isfile(file_path):
        return file_path

    # Second, assume a run number and pass the instrument name as a hint
    try:
        # FileFinder doesn't like dashes...
        instrument=instrument.replace('-','')        
        f = FileFinder.findRuns(instrument+file)
        if os.path.isfile(f[0]): 
            if allow_multiple:
                # Mantid returns its own list object type, so make a real list out if it
                if len(f)==n_files:
                    return [i for i in f] 
            else: return f[0]
    except:
        # FileFinder couldn't make sense of the the supplied information
        pass

    # Third, assume a run number, without instrument name to take care of list of full paths
    try:
        f = FileFinder.findRuns(file)
        if os.path.isfile(f[0]): 
            if allow_multiple:
                # Mantid returns its own list object type, so make a real list out if it   
                if len(f)==n_files:         
                    return [i for i in f] 
            else: return f[0]
    except:
        # FileFinder couldn't make sense of the the supplied information
        pass

    # If we didn't find anything, raise an exception
    Logger.get('find_data').error("\n\nCould not find a file for %s: check your reduction parameters\n\n" % str(file))
    raise RuntimeError, "Could not find a file for %s" % str(file)
开发者ID:trnielsen,项目名称:mantid,代码行数:58,代码来源:find_data.py

示例3: __init__

# 需要导入模块: from mantid.kernel import Logger [as 别名]
# 或者: from mantid.kernel.Logger import get [as 别名]
 def __init__(self, name="", facility=""):
     self.instrument_name = name
     self.facility_name = facility
     self._observers = []
     self._output_directory = os.path.expanduser('~')
     if HAS_MANTID:
         config = ConfigService.Instance()
         try:
             head, tail = os.path.split(config.getUserFilename())
             if os.path.isdir(head):
                 self._output_directory = head
         except:
             Logger.get("scripter").debug("Could not get user filename")
开发者ID:trnielsen,项目名称:mantid,代码行数:15,代码来源:scripter.py

示例4: __init__

# 需要导入模块: from mantid.kernel import Logger [as 别名]
# 或者: from mantid.kernel.Logger import get [as 别名]
 def __init__(self, filepath):
     if not _os.path.isfile(filepath):
         raise ValueError("PluginLoader expects a single filename. '%s' does not point to an existing file" % filepath)
     if not filepath.endswith(self.extension):
         raise ValueError("PluginLoader expects a filename ending with .py. '%s' does not have a .py extension" % filepath)
     self._filepath = filepath
     self._logger = Logger.get("PluginLoader")
开发者ID:trnielsen,项目名称:mantid,代码行数:9,代码来源:plugins.py

示例5: test_logger_creation_does_not_raise_an_error

# 需要导入模块: from mantid.kernel import Logger [as 别名]
# 或者: from mantid.kernel.Logger import get [as 别名]
 def test_logger_creation_does_not_raise_an_error(self):
     logger = Logger.get("LoggerTest")
     self.assertTrue(isinstance(logger, Logger))
     attrs = ['fatal', 'error','warning','notice', 'information', 'debug']
     for att in attrs:
         if not hasattr(logger, att):
             self.fail("Logger object does not have the required attribute '%s'" % att)
开发者ID:trnielsen,项目名称:mantid,代码行数:9,代码来源:LoggerTest.py

示例6: __init__

# 需要导入模块: from mantid.kernel import Logger [as 别名]
# 或者: from mantid.kernel.Logger import get [as 别名]
 def __init__(self, data_file, workspace_name=None):
     self.errors = []
     if HAS_MANTID:
         try:
             if workspace_name is None:
                 self.data_ws = "__raw_data_file"
             else:
                 self.data_ws = str(workspace_name)
             api.HFIRLoad(Filename=str(data_file), OutputWorkspace=self.data_ws)
             ws = AnalysisDataService.retrieve(self.data_ws)
             x = ws.dataX(0)
             self.wavelength = (x[0]+x[1])/2.0
             self.wavelength_spread = x[1]-x[0]
             self.sample_detector_distance = ws.getRun().getProperty("sample_detector_distance").value
             self.sample_thickness = ws.getRun().getProperty("sample-thickness").value
             self.beam_diameter = ws.getRun().getProperty("beam-diameter").value
             
             Logger.get("hfir_data_proxy").information("Loaded data file: %s" % data_file)
         except:
             Logger.get("hfir_data_proxy").error("Error loading data file:\n%s" % sys.exc_value)
             self.errors.append("Error loading data file:\n%s" % sys.exc_value)
开发者ID:trnielsen,项目名称:mantid,代码行数:23,代码来源:hfir_data_proxy.py

示例7: pre_process

# 需要导入模块: from mantid.kernel import Logger [as 别名]
# 或者: from mantid.kernel.Logger import get [as 别名]
 def pre_process(self):
     """
         Reduction steps that are meant to be executed only once per set
         of data files. After this is executed, all files will go through
         the list of reduction steps.
     """
     Logger.get("Reducer").information("Setting up reduction options")
     if self.setup_algorithm is not None:
         alg = AlgorithmManager.create(self.setup_algorithm)
         alg.initialize()
         props = [p.name for p in alg.getProperties()]
         for key in self.reduction_properties.keys():
             if key in props:
                 try:
                     alg.setProperty(key, self.reduction_properties[key])
                 except:
                     msg = "Error setting %s=%s" % (key, str(self.reduction_properties[key]))
                     msg += "\n  %s" % sys.exc_value
                     Logger.get("Reducer").error(msg)
             else:
                 Logger.get("Reducer").warning("Setup algorithm has no %s property" % key)
         
         if "ReductionProperties" in props:
             alg.setPropertyValue("ReductionProperties",
                                  self.get_reduction_table_name())
         alg.execute()
开发者ID:trnielsen,项目名称:mantid,代码行数:28,代码来源:reducer.py

示例8: reduce

# 需要导入模块: from mantid.kernel import Logger [as 别名]
# 或者: from mantid.kernel.Logger import get [as 别名]
    def reduce(self):
        """
            Go through the list of reduction steps
        """
        t_0 = time.time()
        self.output_workspaces = []
        
        # Log text
        self.log_text = "%s reduction - %s\n" % (self.instrument_name, time.ctime())
        self.log_text += "Mantid Python API v2\n"

        # Go through the list of steps that are common to all data files
        self.pre_process()

        if self.reduction_algorithm is None:
            Logger.get("Reducer").error("A reduction algorithm wasn't set: stopping")
            return
        
        for ws in self._data_files.keys():
            alg = AlgorithmManager.create(self.reduction_algorithm)
            alg.initialize()
            props = [p.name for p in alg.getProperties()]
            
            # Check whether the data is already available or needs to be loaded
            if self._data_files[ws] is not None:
                datafile = self._data_files[ws]
                if type(datafile)==list:
                    datafile=','.join(datafile)
                if "Filename" in props:
                    alg.setPropertyValue("Filename", datafile)
                else:
                    msg = "Can't set the Filename property on %s" % self.reduction_algorithm
                    Logger.get("Reducer").error(msg)
            else:
                if "InputWorkspace" in props:
                    alg.setPropertyValue("InputWorkspace", ws)
                else:
                    msg = "Can't set the InputWorkspace property on %s" % self.reduction_algorithm
                    Logger.get("Reducer").error(msg)
                
            if "ReductionProperties" in props:
                alg.setPropertyValue("ReductionProperties",
                                     self.get_reduction_table_name())
            
            if "OutputWorkspace" in props:
                alg.setPropertyValue("OutputWorkspace", ws)
            
            alg.execute()   
            if "OutputMessage" in props:
                self.log_text += alg.getProperty("OutputMessage").value+'\n'

        #any clean up, possibly removing workspaces 
        self.post_process()
    
        # Determine which directory to use
        output_dir = self._data_path
        if self._output_path is not None:
            if os.path.isdir(self._output_path):
                output_dir = self._output_path
            else:
                output_dir = os.path.expanduser('~')

        self.log_text += "Reduction completed in %g sec\n" % (time.time()-t_0)
        log_path = os.path.join(output_dir,"%s_reduction.log" % self.instrument_name)
        self.log_text += "Log saved to %s" % log_path
        
        # Write the log to file
        f = open(log_path, 'a')
        f.write("\n-------------------------------------------\n")
        f.write(self.log_text)
        f.close()
        return self.log_text
开发者ID:trnielsen,项目名称:mantid,代码行数:74,代码来源:reducer.py


注:本文中的mantid.kernel.Logger.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。