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


Python StatsPaths.setBasicPaths方法代码示例

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


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

示例1: main

# 需要导入模块: from pxStats.lib.StatsPaths import StatsPaths [as 别名]
# 或者: from pxStats.lib.StatsPaths.StatsPaths import setBasicPaths [as 别名]
def main():
    """
        @summary : Small test case scenario allows 
                   for unit-like testing of the LanguageTools
                   class. 
    """
    
    configParameters = StatsConfigParameters()
    configParameters.getAllParameters()
    language = configParameters.mainApplicationLanguage
    
    paths = StatsPaths()
    paths.setBasicPaths()
    
    print "Language set in config file : %s" %language
    
    print "Test1 : (Should show that the proper translation file will be used) "
    fileName =  LanguageTools.getTranslationFileName( language, paths.STATSLIB + 'StatsPlotter' )
    print "Translation file to be used : %s " %( fileName ) 
    
    print "Test2 : (Should translate the word into the specified language) "
    translator = LanguageTools.getTranslator( fileName )
    print "Translation for bytecount : %s" %( translator("bytecount") )
    
    print "Test3 : (Should be the same result as test 2) "
    translator = LanguageTools.getTranslatorForModule( paths.STATSLIB + 'StatsPlotter', language )
    print "Translation for bytecount : %s" %( translator("bytecount") )
    
    print "Test4 : Unless translation changes, this should print 'filecount' "
    print "Result : ", LanguageTools.translateTerm("nbreDeFichiers", "fr", "en", paths.STATSLIB + "StatsPlotter.py" )
开发者ID:hawkeye438,项目名称:metpx,代码行数:32,代码来源:LanguageTools.py

示例2: getGroupSettingsFromConfigurationFile

# 需要导入模块: from pxStats.lib.StatsPaths import StatsPaths [as 别名]
# 或者: from pxStats.lib.StatsPaths.StatsPaths import setBasicPaths [as 别名]
    def getGroupSettingsFromConfigurationFile( self ):
        """
            Reads all the group settings from 
            the configuration file.
        """
        
        groupParameters = GroupConfigParameters([], {}, {}, {},{} )
        
        machineParameters = MachineConfigParameters()        
        machineParameters.getParametersFromMachineConfigurationFile()
        
        paths = StatsPaths()
        paths.setBasicPaths()
        config = paths.STATSETC  + "config"
        fileHandle = open( config, "r" )
        
        line = fileHandle.readline()#read until groups section, or EOF
        while line != "" and "[specialGroups]" not in line: 
            
            line = fileHandle.readline()
            
            
        if line != "":#read until next section, or EOF     
            
            line = fileHandle.readline()            
            
            while line != ""  and "[" not in line:
                
                if line != '\n' and line[0] != '#' :
                    
                    splitLine = line.split()
                    if len( splitLine ) == 6:
                        groupName =  splitLine[0] 
                        if groupName not in (groupParameters.groups):
                            groupParameters.groups.append( groupName )
                            groupParameters.groupsMachines[groupName] = []
                            groupParameters.groupFileTypes[groupName] = []
                            groupParameters.groupsMembers[groupName] = []
                            groupParameters.groupsProducts[groupName] = []
                            
                            machines = splitLine[2].split(",")
                            
                            for machine in machines:
                                 groupParameters.groupsMachines[groupName].extend( machineParameters.getMachinesAssociatedWith(machine) )

                            groupParameters.groupFileTypes[groupName] = splitLine[3]
                            groupParameters.groupsMembers[groupName].extend( splitLine[4].split(",") )
                            groupParameters.groupsProducts[groupName].extend( splitLine[5].split(",") )
                    
                line = fileHandle.readline()     
                                
        fileHandle.close()            
        
        self.groupParameters = groupParameters
开发者ID:hawkeye438,项目名称:metpx,代码行数:56,代码来源:StatsConfigParameters.py

示例3: getTranslationFileName

# 需要导入模块: from pxStats.lib.StatsPaths import StatsPaths [as 别名]
# 或者: from pxStats.lib.StatsPaths.StatsPaths import setBasicPaths [as 别名]
  def getTranslationFileName( language = 'en', moduleAbsPath = 'module' ):
      """
          
          @summary : Returns the filename containing the translation text required 
                     by the specified module for the spcified language.
          
          @Note : Will return "" if language is not supported.
          
          @param language: Language for which we need the translation file.
          
          @param moduleAbsPath: AbsolutePath name of the module for which we need the translation file.
      
          @return : Returns the filename containing the translation text required 
                    by the specified module for the spcified language. 
                    
                    Will return "" if language is not supported.
                      
          
      """
      
      translationfileName = ""
      moduleAbsPath = os.path.realpath(moduleAbsPath) #decodes symlinks.
      try : 
          
          paths = StatsPaths()
          paths.setBasicPaths()
 
          if language == 'en' : 
              correspondingPaths = { paths.STATSBIN : paths.STATSLANGENBIN, paths.STATSDEBUGTOOLS : paths.STATSLANGENBINDEBUGTOOLS \
                                    , paths.STATSTOOLS : paths.STATSLANGENBINTOOLS, paths.STATSWEBPAGESGENERATORS : paths.STATSLANGENBINWEBPAGES \
                                    , paths.STATSLIB : paths.STATSLANGENLIB  }
                       
          elif language == 'fr': 
              correspondingPaths = { paths.STATSBIN : paths.STATSLANGFRBIN, paths.STATSDEBUGTOOLS : paths.STATSLANGFRBINDEBUGTOOLS \
                    , paths.STATSTOOLS : paths.STATSLANGFRBINTOOLS, paths.STATSWEBPAGESGENERATORS : paths.STATSLANGFRBINWEBPAGES \
                    , paths.STATSLIB : paths.STATSLANGFRLIB  } 
          
          
          for key in correspondingPaths.keys():
              correspondingPaths[ key.split("pxStats")[-1:][0]] = correspondingPaths[ key]
          
          modulePath = str(os.path.dirname( moduleAbsPath ) + '/').split("pxStats")[-1:][0]
          moduleBaseName =  str(os.path.basename( moduleAbsPath )).replace( ".py", "" )
          
          #print "modulePath",modulePath
          
          #print "correspondingPaths", correspondingPaths
                     
          translationfileName = correspondingPaths[ modulePath ] + moduleBaseName
          
          #print translationfileName
          
      except Exception, instance:
          print instance
开发者ID:hawkeye438,项目名称:metpx,代码行数:56,代码来源:LanguageTools.py

示例4: getCrontabLine

# 需要导入模块: from pxStats.lib.StatsPaths import StatsPaths [as 别名]
# 或者: from pxStats.lib.StatsPaths.StatsPaths import setBasicPaths [as 别名]
 def getCrontabLine(self, attribute, attributeValue ):
     """
     
         @param attribute: attribute for wich you want to build a crontab line.
         
         @return: a crontab based on the program associated with the attribute and the frequency that was specified. 
         
     """        
     
     paths = StatsPaths()
     paths.setBasicPaths()
     
     crontabArray = ['*','*','*','*','*','']        
     frequency = attributeValue.keys()[0]
     timeUnit  =  attributeValue[ frequency ]
     
     
     
     
     if timeUnit in TimeConfigParameters.validTimeUnits:
         if timeUnit != 'minutes':
             if attribute == "pxStatsFrequency":
                 crontabArray[0] =  random.randint(1,10)
             else:
                 crontabArray[0] = random.randint(45,59)
     
         indexToModify = TimeConfigParameters.validTimeUnits.index( timeUnit )
         
         crontabArray[indexToModify] = crontabArray[indexToModify] + '/' + str(frequency)
                         
         if attribute == "pxStatsFrequency" :
             crontabArray[5] = paths.STATSLIBRARY + 'pxStats.py'
         elif attribute == "monitoringFrequency" :
             crontabArray[5] = paths.STATSLIBRARY + 'statsMonitor.py'
         elif attribute == "dbBackupsFrequency" :  
             crontabArray[5] = paths.STATSLIBRARY + 'backupRRDDatabases.py'
         elif attribute == "pickleCleanerFrequency" :
             crontabArray[5] = paths.STATSLIBRARY + 'pickleCleaner.py'
         elif attribute == "generalCleanerFrequency" :
             crontabArray[5] = paths.STATSLIBRARY + 'clean_dir.plx'
             
         crontabLine= ""            
         for item in crontabArray:
             crontabLine = crontabLine  + str(item) + " "     
     
     else:
     
         crontabLine = ""
                 
     
     return crontabLine
开发者ID:hawkeye438,项目名称:metpx,代码行数:53,代码来源:TimeParameters.py

示例5: getParametersFromMachineConfigurationFile

# 需要导入模块: from pxStats.lib.StatsPaths import StatsPaths [as 别名]
# 或者: from pxStats.lib.StatsPaths.StatsPaths import setBasicPaths [as 别名]
 def getParametersFromMachineConfigurationFile(self):     
     '''
     
     @summary: Gathers all the information found within 
               the configForMachines configuration file.
               
     @return: Returns an _MachineConfigParameters instance 
              containing all the found parameters.            
     
     '''
     
     paths = StatsPaths()          
     paths.setBasicPaths()
     
     CONFIG = paths.STATSETC + "configForMachines"     
     
     if os.path.isfile( CONFIG ):
         
         fileHandle =  open( CONFIG )    
         lines = fileHandle.readlines() 
         
         for line in lines:
             if line != '' and  line[0] != '#' and line[0] != '\n' :
                 
                 splitLine = line.split()                    
                 machineTag = splitLine[0]
                 machines = splitLine[1].split(",")
                 userNames = splitLine[2].split(",")
                
                 if ( len(machines) ==  len(userNames) ):
                     for i in range( len( machines ) ):                    
                         self.addMachineTagToTagList( machineTag)    
                         self.addMachineToMachineList( machines[i] )
                         self.addMachineToMachineTag(machines[i], machineTag)
                         self.setUserNameForMachine(machines[i], userNames[i])
         
         fileHandle.seek(0)
         fileHandle.close()          
         
         
         
         
         
         
         
         
         
         
         
开发者ID:hawkeye438,项目名称:metpx,代码行数:40,代码来源:MachineConfigParameters.py

示例6: getGeneralParametersFromStatsConfigurationFile

# 需要导入模块: from pxStats.lib.StatsPaths import StatsPaths [as 别名]
# 或者: from pxStats.lib.StatsPaths.StatsPaths import setBasicPaths [as 别名]
 def getGeneralParametersFromStatsConfigurationFile(self):
     """
         @summary : Gathers GENERAL parameters from the
                    StatsPath.STATSETC/config file.
         
         @note : Does not set groupParameters, time parameters 
                 and detailed parameters.
                 
         @return : None
     
     """   
     
     paths = StatsPaths()
     paths.setBasicPaths()
     
     configFile = paths.STATSETC + "config" 
     config = ConfigParser()
     file = open( configFile )
     config.readfp( file ) 
               
     self.sourceMachinesTags     = []   
     self.picklingMachines       = []
     self.machinesToBackupInDb   = []
     self.graphicsUpLoadMachines = []   
     self.artifactsLanguages     = []  
     self.webPagesLanguages      = []
     self.mainApplicationLanguage = config.get( 'generalConfig', 'mainApplicationLanguage' )
     self.artifactsLanguages.extend( config.get( 'generalConfig', 'artifactsLanguages' ).split(',') )
     
     languagePairs = config.get( 'generalConfig', 'webPagesLanguages' ).split(',')
     
     for languagePair in languagePairs:
         self.webPagesLanguages.append( (languagePair.split(":")[0], languagePair.split(":")[1]) )
        
     self.statsRoot = config.get( 'generalConfig', 'statsRoot' )    
     self.sourceMachinesTags.extend( config.get( 'generalConfig', 'sourceMachinesTags' ).split(',') )
     self.picklingMachines.extend( config.get( 'generalConfig', 'picklingMachines' ).split(',') ) 
     self.machinesToBackupInDb.extend( config.get( 'generalConfig', 'machinesToBackupInDb' ).split(',') ) 
     self.graphicsUpLoadMachines.extend( config.get( 'generalConfig', 'graphicsUpLoadMachines' ).split(',') ) 
     self.daysOfPicklesToKeep = float( config.get( 'generalConfig', 'daysOfPicklesToKeep' ) )
     self.nbDbBackupsToKeep   = float( config.get( 'generalConfig', 'nbDbBackupsToKeep' ) )
     self.nbAutoUpdatesLogsToKeep = int( config.get( 'generalConfig', 'nbAutoUpdatesLogsToKeep' ) )
     
     try:
         file.close()
     except:
         pass    
开发者ID:hawkeye438,项目名称:metpx,代码行数:49,代码来源:StatsConfigParameters.py

示例7: getTimeParametersFromConfigurationFile

# 需要导入模块: from pxStats.lib.StatsPaths import StatsPaths [as 别名]
# 或者: from pxStats.lib.StatsPaths.StatsPaths import setBasicPaths [as 别名]
  def getTimeParametersFromConfigurationFile(self):
      """
          @summary: gathers all the time related parameters
                   from the config file. 
          
          @raise exception: Will raise and exception if 
          one of the units of time used is illegal. 
          
      """
 
      readTimeUnits = []
      
      paths = StatsPaths()
      paths.setBasicPaths()
      CONFIG = paths.STATSETC + "config" 
      config = ConfigParser()
      file = open( CONFIG )
      config.readfp( file ) 
      
      self.pxStatsFrequency =  {}
      self.monitoringFrequency =   {}
      self.dbBackupsFrequency =  {}
      self.pickleCleanerFrequency =  {}
      self.generalCleanerFrequency =  {}
      
      values = config.get( 'timeConfig', 'pxStatsFrequency' ).split('/')
      frequency, timeUnit = values[0],values[1]
      self.pxStatsFrequency[frequency] = timeUnit
      readTimeUnits.append(timeUnit)
      
      values = config.get( 'timeConfig', 'monitoringFrequency' ).split('/')
      frequency, timeUnit = values[0],values[1]
      self.monitoringFrequency[frequency] = timeUnit
      readTimeUnits.append(timeUnit)
      
      values = config.get( 'timeConfig', 'dbBackupsFrequency' ).split('/')
      frequency, timeUnit = values[0],values[1]
      self.dbBackupsFrequency[frequency] = timeUnit
      readTimeUnits.append(timeUnit)
      
      values = config.get( 'timeConfig', 'pickleCleanerFrequency' ).split('/')
      frequency, timeUnit = values[0],values[1]
      self.pickleCleanerFrequency[frequency] = timeUnit
      readTimeUnits.append(timeUnit)
      
      values = config.get( 'timeConfig', 'generalCleanerFrequency' ).split('/')
      frequency, timeUnit = values[0],values[1]
      self.generalCleanerFrequency[frequency] = timeUnit
      readTimeUnits.append(timeUnit)
      
      for unit in readTimeUnits:
          if unit not in TimeConfigParameters.validTimeUnits:
              raise Exception("Invalid time unit found in configuration file.")
      
      
      self.dailyWebPageFrequency   =  config.get( 'timeConfig', 'dailyWebPageUpdatesFrequency' ).replace( " ", "").replace( "'","" ).replace( '"','' )
      self.weeklyWebPageFrequency  =  config.get( 'timeConfig', 'weeklyWebPageUpdatesFrequency' ).replace( " ", "").replace( "'","" ).replace( '"','' )
      self.monthlyWebPageFrequency =  config.get( 'timeConfig', 'monthlyWebPageUpdatesFrequency' ).replace( " ", "").replace( "'","" ).replace( '"','' )
      self.yearlyWebPageFrequency  =  config.get( 'timeConfig', 'yearlyWebPageUpdatesFrequency' ).replace( " ", "").replace( "'","" ).replace( '"','' )
      self.totalWebPagesUpdatesFrequency =  config.get( 'timeConfig', 'totalWebPagesUpdatesFrequency' ).replace( " ", "").replace( "'","" ).replace( '"','' )
      
           
      try:
          file.close() 
      except:
          pass
开发者ID:hawkeye438,项目名称:metpx,代码行数:68,代码来源:TimeParameters.py

示例8: StatsPaths

# 需要导入模块: from pxStats.lib.StatsPaths import StatsPaths [as 别名]
# 或者: from pxStats.lib.StatsPaths.StatsPaths import setBasicPaths [as 别名]
import cgi
import cgitb; cgitb.enable()

"""
    Small function that adds pxStats to the sys path.  
"""
sys.path.insert(1, sys.path[0] + '/../../..')

from pxStats.lib.StatsPaths import StatsPaths
from pxStats.lib.LanguageTools import LanguageTools

"""
    Small method required to add pxLib to syspath.
"""
PATHS = StatsPaths()
PATHS.setBasicPaths()
sys.path.append( PATHS.PXLIB ) 
    


def returnReplyToQuerier( error ="" ):
    """
        @summary : Prints an empty reply so that the receiving web page will
                   not modify it's display.
                   
        @param  error : Error to return to querier.            
        
        @return : None
   
        @note: Method does not actually "return" anything. 
               It just prints out it's reply that is to be 
开发者ID:hawkeye438,项目名称:metpx,代码行数:33,代码来源:generateImageWebPage.py

示例9: StatsPaths

# 需要导入模块: from pxStats.lib.StatsPaths import StatsPaths [as 别名]
# 或者: from pxStats.lib.StatsPaths.StatsPaths import setBasicPaths [as 别名]
"""
    Small function that adds pxlib to the environment path.  
"""


sys.path.insert(1, os.path.dirname( os.path.abspath(__file__) ) + '/../../')

from pxStats.lib.StatsPaths import StatsPaths
from pxStats.lib.StatsDateLib import StatsDateLib
from pxStats.lib.StatsPickler import StatsPickler
from pxStats.lib.LanguageTools import LanguageTools
from pxStats.lib.GeneralStatsLibraryMethods import GeneralStatsLibraryMethods


STATSPATHS = StatsPaths()
STATSPATHS.setBasicPaths()
sys.path.append( STATSPATHS.PXLIB )

"""
    Imports which require pxlib 
"""
from Logger import * 
from PXManager import * 


LOCAL_MACHINE = os.uname()[1]   
CURRENT_MODULE_ABS_PATH =  os.path.abspath(__file__).replace( ".pyc", ".py" )     
    
    
    
class _UpdaterInfos:  
开发者ID:hawkeye438,项目名称:metpx,代码行数:33,代码来源:pickleUpdater.py

示例10: StatsPaths

# 需要导入模块: from pxStats.lib.StatsPaths import StatsPaths [as 别名]
# 或者: from pxStats.lib.StatsPaths.StatsPaths import setBasicPaths [as 别名]
"""
sys.path.insert(1,  os.path.dirname( os.path.abspath(__file__) ) + '/../../')

from pxStats.lib.StatsPaths import StatsPaths
from pxStats.lib.StatsPickler import StatsPickler
from pxStats.lib.StatsDateLib import StatsDateLib
from pxStats.lib.PickleMerging import PickleMerging
from pxStats.lib.GnuPlotter import GnuPlotter
from pxStats.lib.GeneralStatsLibraryMethods import GeneralStatsLibraryMethods
from pxStats.lib.Translatable import Translatable

"""
    These imports require pxlib 
"""
statsPaths = StatsPaths( )
statsPaths.setBasicPaths()
sys.path.append( statsPaths.PXLIB )

import logging 
from Logger import Logger


LOCAL_MACHINE = os.uname()[1]
CURRENT_MODULE_ABS_PATH =  os.path.abspath(__file__).replace( ".pyc", ".py" )


class GnuGraphicProducer( Translatable ):
                
        
    def __init__( self, directory, fileType, clientNames = None , groupName = "",  timespan = 12,\
                  currentTime = None, productTypes = None, logger = None, logging = True, machines = None,\
开发者ID:hawkeye438,项目名称:metpx,代码行数:33,代码来源:GnuGraphicProducer.py


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