本文整理汇总了Python中pxStats.lib.LanguageTools.LanguageTools类的典型用法代码示例。如果您正苦于以下问题:Python LanguageTools类的具体用法?Python LanguageTools怎么用?Python LanguageTools使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LanguageTools类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setGlobalLanguageParameters
def setGlobalLanguageParameters( language = "" ):
"""
@summary : Sets up all the needed global language
tranlator so that it can be used
everywhere in this program.
@Note : The scope of the global _ function
is restrained to this module only and
does not cover the entire project.
@param language : language to set.
@return: None
"""
global _
global SUPPORTED_RX_DATATYPES
global SUPPORTED_TX_DATATYPES
if language == "":
_ = LanguageTools.getTranslatorForModule( CURRENT_MODULE_ABS_PATH )
else :
_ = LanguageTools.getTranslatorForModule( CURRENT_MODULE_ABS_PATH, language )
SUPPORTED_RX_DATATYPES = { "bytecount":_("bytecount") , "filecount": _("filecount"), "errors":_("errors") }
SUPPORTED_TX_DATATYPES = { "latency" :_("latency"), "filesOverMaxLatency":_("filesOverMaxLatency"), "bytecount":_("bytecount"), "filecount" :_("filecount"), "errors":_("errors") }
示例2: setLanguage
def setLanguage( language ):
"""
@summary : sets specified language as the
language used for translations
throughout the entire class.
"""
if language in LanguageTools.getSupportedLanguages() :
global _
_ = LanguageTools.getTranslatorForModule( CURRENT_MODULE_ABS_PATH, language )
示例3: __init__
def __init__( self, languages = None ):
"""
@param languages: list of languages
for which to generate
the doc web pages.
"""
global _
self.mainLanguage = LanguageTools.getMainApplicationLanguage()
self.languages = languages or LanguageTools.getSupportedLanguages()
示例4: __init__
def __init__(self, querierLanguage, queryParameters = None, replyParameters = None,\
graphicProducer = None ):
"""
@summary: GnuQueryBroker constructor.
@param querierLanguage : Language spoken by the qerier at the time of the query.
@param queryParameters: _QueryParameters instance wich
contains the query parameters.
@param replyParameters :
@param graphicProducer :
"""
self.queryParameters = queryParameters
self.graphicProducer = graphicProducer
self.replyParameters = replyParameters
self.querierLanguage = querierLanguage
if self.querierLanguage not in LanguageTools.getSupportedLanguages():
raise Exception( "Error. Unsupported language detected in GnuQueryBroker. %s is not a supported language."%( self.querierLanguage ) )
else:#language is supposed to be supported
global _
_ = self.getTranslatorForModule( CURRENT_MODULE_ABS_PATH, self.querierLanguage )
示例5: addOptions
def addOptions( parser ):
"""
@summary : This method is used to add all available options to the option parser.
"""
parser.add_option("-c", "--combine", action="store_true", dest = "combine", default=False, \
help=_("Combine data from all specified machines.") )
parser.add_option("-d", "--date", action="store", type="string", dest="date", default=StatsDateLib.getIsoFromEpoch( time.time() ),\
help=_("Decide current time. Usefull for testing.") )
parser.add_option("-i", "--individual", action="store_true", dest = "individual", default=False, \
help=_("Create individual graphics for all specified machines.") )
parser.add_option( "-l", "--logins", action="store", type="string", dest="logins", default="pds",\
help = _("Logins to be used to connect to machines.") )
parser.add_option( "-m", "--machines", action="store", type="string", dest="machines", default=LOCAL_MACHINE,\
help = _("Machines for wich you want to collect data.") )
parser.add_option("-o", "--outputLanguage", action="store", type="string", dest="outputLanguage",\
default=LanguageTools.getMainApplicationLanguage(), help = _("Language in which the graphics are outputted.") )
parser.add_option("-s", "--span", action="store",type ="int", dest = "timespan", default=24, \
help=_("timespan( in hours) of the graphic."))
示例6: prepareQuery
def prepareQuery(self):
"""
@summary : Buildup the query to be executed.
@SIDE_EFFECT : modifies self.query value.
"""
global _
if self.queryParameters.combine == 'true':
totals = True
mergerType = "regular"
else:
totals = False
mergerType = ""
fixedCurrent = False
fixedPrevious = False
if _("current") in str(self.queryParameters.fixedSpan).lower() :
fixedCurrent = True
elif _("previous") in str(self.queryParameters.fixedSpan).lower():
fixedPrevious = True
else:
fixedCurrent = False
fixedPrevious = False
hour = self.queryParameters.endTime.split(" ")[1]
splitDate = self.queryParameters.endTime.split(" ")[0].split( '-' )
date = splitDate[2] + '-' + splitDate[1] + '-' + splitDate[0] + " " + hour
if self.queryParameters.span == "":
timespan = 0
else:
timespan = int(self.queryParameters.span )
StatsDateLib.setLanguage( self.querierLanguage )
startTime, endTime = StatsDateLib.getStartEndInIsoFormat(date, timespan, self.queryParameters.specificSpan, fixedCurrent, fixedPrevious )
timespan = int( StatsDateLib.getSecondsSinceEpoch( endTime ) - StatsDateLib.getSecondsSinceEpoch( startTime ) ) / 3600
combinedMachineName = ""
for machine in self.queryParameters.machines:
combinedMachineName = combinedMachineName + machine
machines = [ combinedMachineName ]
self.graphicProducer = RRDGraphicProducer( self.queryParameters.fileTypes[0], self.queryParameters.statsTypes ,\
totals, self.queryParameters.specificSpan,\
self.queryParameters.sourLients, timespan,\
startTime, endTime, machines, False,
mergerType, True, self.querierLanguage, self.querierLanguage )
StatsDateLib.setLanguage( LanguageTools.getMainApplicationLanguage() )
示例7: searchForParameterErrors
def searchForParameterErrors(self):
"""
@summary : Validates parameters.
@return : Returns the first error
found within the current
query parameters.
"""
global _
error = ""
try :
if self.queryParameters.plotter != "gnuplot":
error = _("Internal error. GnuQueryBroker was not called to plota gnuplot graphic.")
raise
for fileType in self.queryParameters.fileTypes :
if fileType != "tx" and fileType != "rx":
error = _("Error. FileType needs to be either rx or tx.")
raise
if self.queryParameters.sourLients == []:
if self.queryParameters.groupName == "":
error = _("Error. At least one sourlient name needs to be specified.")
else:
error = _("Error. When specifying a group name without any sourlients names, the group must be a pre-existing group.")
if self.queryParameters.machines == []:
error = _("Error. At least one machine name needs to be specified.")
if self.queryParameters.combine != 'true' and self.queryParameters.combine != 'false':
error = _("Error. Combine sourlients option needs to be either true or false." )
if self.queryParameters.statsTypes == []:
error = _("Error. At Leat one statsType needs to be specified.")
try:
int(self.queryParameters.span)
except:
error = _("Error. Span(in hours) value needs to be numeric.")
if self.queryParameters.language == "" :
error = _("Error. No language was specified by the querier. Please speciffy a language. Ex : lang=fr")
elif self.queryParameters.language not in LanguageTools.getSupportedLanguages() :
error = _("Error. Unsupported language detected in GnuQueryBroker. %s is not a supported language.")%( self.queryParameters.language)
except:
pass
return error
示例8: giveOutPermissionsToFolders
def giveOutPermissionsToFolders( currentlyUsedLanguages ):
"""
@summary : opens up permissions to folders that
might be required by the web user.
@param currentlyUsedLanguages: Languages currently set to be
displayed in the web interface
"""
for language in currentlyUsedLanguages:
_ = LanguageTools.getTranslatorForModule(CURRENT_MODULE_ABS_PATH, language)
paths = StatsPaths()
paths.setPaths(language)
pathsToOpenUp = []
pathsToOpenUp.append( paths.STATSLOGGING)
pathsToOpenUp.append( paths.STATSPICKLES )
pathsToOpenUp.append( paths.STATSDB)
pathsToOpenUp.append( paths.STATSCURRENTDB )
pathsToOpenUp.append( paths.STATSCURRENTDB + _("bytecount") )
pathsToOpenUp.append( paths.STATSCURRENTDB + _("errors") )
pathsToOpenUp.append( paths.STATSCURRENTDB + _("filecount") )
pathsToOpenUp.append( paths.STATSCURRENTDB + _("filesOverMaxLatency"))
pathsToOpenUp.append( paths.STATSCURRENTDB + _("latency"))
pathsToOpenUp.append( paths.STATSCURRENTDBUPDATES)
pathsToOpenUp.append( paths.STATSCURRENTDBUPDATES + _("rx") )
pathsToOpenUp.append( paths.STATSCURRENTDBUPDATES + _("tx") )
pathsToOpenUp.append( paths.STATSCURRENTDBUPDATES + _("totals") )
pathsToOpenUp.append( paths.STATSDBBACKUPS )
pathsToOpenUp.append( paths.STATSDBBACKUPS + "*/" + _("rx") )
pathsToOpenUp.append( paths.STATSDBBACKUPS + "*/" + _("tx") )
pathsToOpenUp.append( paths.STATSDBBACKUPS + "*/" + _("totals") )
pathsToOpenUp.append( paths.STATSGRAPHS )
pathsToOpenUp.append( paths.STATSGRAPHS +_("others/"))
pathsToOpenUp.append( paths.STATSGRAPHS +_("others/") + "gnuplot/")
pathsToOpenUp.append( paths.STATSGRAPHS +_("others/") + "rrd/")
pathsToOpenUp.append( paths.STATSWEBPAGESHTML + "/popUps/")
for path in pathsToOpenUp:
if not os.path.isdir(path):
os.makedirs(path, 0777)
commands.getstatusoutput( "chmod 0777 %s" %path )
commands.getstatusoutput( "chmod 0777 %s/*" %path )
示例9: generateTopWebPage
def generateTopWebPage(self):
"""
@summary : Generates the top web page based on the
"""
configParameters = StatsConfigParameters()
configParameters.getAllParameters()
machineParameters = MachineConfigParameters()
machineParameters.getParametersFromMachineConfigurationFile()
supportedLanguages = LanguageTools.getSupportedLanguages()
self.__createTheWebPage( configParameters.sourceMachinesTags, supportedLanguages )
示例10: getTranslatorForModule
def getTranslatorForModule(self, moduleName, language = None ):
"""
@summary : Sets up all the needed global language
tranlator so that it can be used
everywhere in this program.
@Note : The scope of the global _ function
is restrained to this class and the one in.
@return: None
"""
return LanguageTools.getTranslatorForModule( moduleName, language )
示例11: __init__
def __init__( self, outputLanguage ):
"""
@param outputLanguage: Language that will be displayed on the web page.
"""
self.outputLanguage = outputLanguage
if self.outputLanguage not in LanguageTools.getSupportedLanguages():
raise Exception( "Error. Unsupported language detected in TopWebPageGenerator. %s is not a supported language." %(self.outputLanguage) )
else:
global _ #Global translator for this module.
_ = self.getTranslatorForModule( CURRENT_MODULE_ABS_PATH, self.outputLanguage )
示例12: setPaths
def setPaths( self, language = None ):
global _
from pxStats.lib.LanguageTools import LanguageTools
_ = LanguageTools.getTranslatorForModule( CURRENT_MODULE_ABS_PATH, language )
"""
Sets all the paths that can not be translated.
"""
self.setBasicPaths()
"""
Translatable paths.
"""
self.STATSDATA = self.STATSROOT + _('data/')
self.STATSDOC = self.STATSROOT + _( 'doc/' )
self.STATSLOGGING = self.STATSROOT + _( 'logs/' )
self.STATSMAN = self.STATSROOT + _( 'man/' )
self.STATSTEMP = self.STATSROOT + _( "temp/" )
#csvfiles
self.STATSCSVFILES = self.STATSDATA + _("csvFiles/")
#Databases related paths.
self.STATSDB = self.STATSDATA + _( 'databases/' )
self.STATSCURRENTDB = self.STATSDB + _( 'currentDatabases/' )
self.STATSCURRENTDBUPDATES = self.STATSDB + _( 'currentDatabasesTimeOfUpdates/' )
self.STATSDBBACKUPS = self.STATSDB + _( 'databasesBackups/' )
self.STATSDBUPDATESBACKUPS = self.STATSDB + _( 'databasesTimeOfUpdatesBackups/' )
#Various paths under pxStats/data/
self.STATSFILEVERSIONS = self.STATSDATA + _( 'fileAcessVersions/' )
self.STATSLOGACCESS = self.STATSDATA + _( 'logFileAccess/' )
self.STATSMONITORING = self.STATSDATA + _( 'monitoring/' )
self.STATSPICKLES = self.STATSDATA + _( 'pickles/' )
self.STATSLOGS = self.STATSDATA + _( 'logFiles/' )
self.STATSWEBPAGES = self.STATSDATA + _( 'webPages/' )
self.STATSWEBPAGESHTML = self.STATSWEBPAGES + _( 'html/' )
self.STATSWEBPAGESWORDDBS = self.STATSWEBPAGES + _( 'wordDatabases/' )
self.STATSGRAPHS = self.STATSDATA + _( 'graphics/' )
self.STATSWEBGRAPHS = self.STATSGRAPHS + _( 'webGraphics/' )
self.STATSWEBWORDDATABASES = self.STATSWEBPAGES + _( 'wordDatabases/' )
self.STATSGRAPHSARCHIVES = self.STATSWEBGRAPHS + _( 'archives/' )
self.STATSCOLGRAPHS = self.STATSWEBGRAPHS + _( 'columbo/' )
self.STATSPICKLESTIMEOFUPDATES = self.STATSDATA + _( 'picklesTimeOfUpdates/' )
self.STATSPREVIOUSMACHINEPARAMS = self.STATSDATA + _( 'previousMachineParameters' )
self.STATSTEMPLOCKFILES = self.STATSTEMP + _( "lockFiles/" )
self.STATSTEMPAUTUPDTLOGS = self.STATSTEMP + _( "automaticUpdatesLogs/" )
示例13: __init__
def __init__(self, timeOfRequest, outputLanguage):
"""
@param timeOfRequest : Time at which the graphics are requested.
@param outputLanguage : Language in which to output the graphics.
"""
self.timeOfRequest = timeOfRequest
self.outputLanguage = outputLanguage
if outputLanguage not in LanguageTools.getSupportedLanguages():
raise Exception("Usage of unsuported language detected in timeOfRequest constructor.")
示例14: main
def main():
"""
Generates the web page based on the received
machines and file type parameters.
"""
error = ""
form = getForm()
# print form
try:
wordType = form["wordType"]
if wordType != "products" and wordType != "groupName":
error = "Error. Word type needs to be either products or groupName."
except:
wordType = ""
try:
language = form["lang"]
if language not in LanguageTools.getSupportedLanguages():
raise
except:
language = LanguageTools.getMainApplicationLanguage()
try:
word = form["word"]
word = word.replace(" ", "")
except:
error = "Error. Word needs to be specified."
word = ""
if word != "":
updateWordsFromDB(wordType, word, language)
returnReply(error)
示例15: setGlobalLanguageParameters
def setGlobalLanguageParameters( language ):
"""
@summary : Sets up all the needed global language
variables so that they can be used
everywhere in this program.
@param language: language with whom this
script was called.
@return: None
"""
global _
_ = LanguageTools.getTranslatorForModule( CURRENT_MODULE_ABS_PATH, language)