當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。