Esempio n. 1
0
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" )
Esempio n. 2
0
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")
Esempio n. 3
0
    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
Esempio n. 4
0
    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
Esempio n. 5
0
    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
Esempio n. 6
0
  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
Esempio n. 7
0
    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
Esempio n. 8
0
 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
 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()          
         
         
         
         
         
         
         
         
         
         
         
Esempio n. 10
0
    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
Esempio n. 11
0
 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    
Esempio n. 12
0
    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()
Esempio n. 13
0
"""
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,\
Esempio n. 14
0
    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
Esempio n. 15
0
  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
Esempio n. 16
0
    - Small function that adds pxStats to sys path.  
"""
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,\
                  workingLanguage = None, outputLanguage = None  ):
Esempio n. 17
0
"""
    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:  
from optparse import OptionParser
"""
    Small function that adds pxlib to the environment path.  
"""
sys.path.insert(1, os.path.dirname(os.path.abspath(__file__)) + '/../../')
print os.path.abspath(__file__) + '/../../'
from pxStats.lib.StatsPaths import StatsPaths
from pxStats.lib.StatsDateLib import StatsDateLib
from pxStats.lib.GeneralStatsLibraryMethods import GeneralStatsLibraryMethods
from pxStats.lib.LanguageTools import LanguageTools
"""
    Imports
    PXManager requires pxlib 
"""
STATSPATHS = StatsPaths()
STATSPATHS.setBasicPaths()
sys.path.append(STATSPATHS.PXLIB)
"""
    These paths require pxlib
"""
from PXManager import *

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


#################################################################
#                                                               #
#################PARSER AND OPTIONS SECTION######################
#                                                               #
#################################################################
Esempio n. 19
0
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