本文整理汇总了Python中pxStats.lib.LanguageTools.LanguageTools.getSupportedLanguages方法的典型用法代码示例。如果您正苦于以下问题:Python LanguageTools.getSupportedLanguages方法的具体用法?Python LanguageTools.getSupportedLanguages怎么用?Python LanguageTools.getSupportedLanguages使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pxStats.lib.LanguageTools.LanguageTools
的用法示例。
在下文中一共展示了LanguageTools.getSupportedLanguages方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from pxStats.lib.LanguageTools import LanguageTools [as 别名]
# 或者: from pxStats.lib.LanguageTools.LanguageTools import getSupportedLanguages [as 别名]
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 )
示例2: setLanguage
# 需要导入模块: from pxStats.lib.LanguageTools import LanguageTools [as 别名]
# 或者: from pxStats.lib.LanguageTools.LanguageTools import getSupportedLanguages [as 别名]
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: searchForParameterErrors
# 需要导入模块: from pxStats.lib.LanguageTools import LanguageTools [as 别名]
# 或者: from pxStats.lib.LanguageTools.LanguageTools import getSupportedLanguages [as 别名]
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
示例4: __init__
# 需要导入模块: from pxStats.lib.LanguageTools import LanguageTools [as 别名]
# 或者: from pxStats.lib.LanguageTools.LanguageTools import getSupportedLanguages [as 别名]
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()
示例5: generateTopWebPage
# 需要导入模块: from pxStats.lib.LanguageTools import LanguageTools [as 别名]
# 或者: from pxStats.lib.LanguageTools.LanguageTools import getSupportedLanguages [as 别名]
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 )
示例6: __init__
# 需要导入模块: from pxStats.lib.LanguageTools import LanguageTools [as 别名]
# 或者: from pxStats.lib.LanguageTools.LanguageTools import getSupportedLanguages [as 别名]
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 )
示例7: __init__
# 需要导入模块: from pxStats.lib.LanguageTools import LanguageTools [as 别名]
# 或者: from pxStats.lib.LanguageTools.LanguageTools import getSupportedLanguages [as 别名]
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.")
示例8: main
# 需要导入模块: from pxStats.lib.LanguageTools import LanguageTools [as 别名]
# 或者: from pxStats.lib.LanguageTools.LanguageTools import getSupportedLanguages [as 别名]
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)
示例9: main
# 需要导入模块: from pxStats.lib.LanguageTools import LanguageTools [as 别名]
# 或者: from pxStats.lib.LanguageTools.LanguageTools import getSupportedLanguages [as 别名]
def main():
"""
@summary: Based on the plotter specified in the received form,
executes query using a broker that's specific to
the said plotter.
"""
try:
form = getForm()
language = getLanguage( form )
if language == "" : # unspecified language.
querier = getQuerierLocation( form )
reply = "images=;error=" + "Error in query broker. Cannot proceed with query. No language was specified." #No language, do not translate.
returnToQueriersLocationWithReply( querier, reply )
elif language not in LanguageTools.getSupportedLanguages(): # unsupported language
querier = getQuerierLocation( form )
reply = "images=;error=" + "Error in query broker. Cannot proceed with query. %s is not a supported language." %language #Unsupported language, do not translate.
returnToQueriersLocationWithReply( querier, reply )
else: #params seem ok
setGlobalLanguageParameters( language )
handlePlotRequest( form, language )
except Exception, instance : #temp file helpfull for debugging!
fileHandle= open('graphicsRequestBrokerDebuggingOutput','w')
fileHandle.write( str(instance) )
fileHandle.close()
示例10: getOptionsFromParser
# 需要导入模块: from pxStats.lib.LanguageTools import LanguageTools [as 别名]
# 或者: from pxStats.lib.LanguageTools.LanguageTools import getSupportedLanguages [as 别名]
#.........这里部分代码省略.........
currentTime = options.currentTime.replace('"','').replace("'",'')
fileType = options.fileType.replace("'",'')
collectUpToNow = options.collectUpToNow
copy = options.copy
combineClients = options.combineClients
productTypes = options.productTypes.replace( ' ', '' ).split( ',' )
groupName = options.groupName.replace( ' ','' )
outputLanguage = options.outputLanguage
try: # Makes sure date is of valid format.
# Makes sure only one space is kept between date and hour.
t = time.strptime( currentTime, '%Y-%m-%d %H:%M:%S' )
split = currentTime.split()
currentTime = "%s %s" %( split[0], split[1] )
except:
print _("Error. The date format must be YYYY-MM-DD HH:MM:SS" )
print _("Use -h for help.")
print _("Program terminated.")
sys.exit()
try:
if int( timespan ) < 1 :
raise
except:
print _("Error. The timespan value needs to be an integer one above 0." )
print _("Use -h for help.")
print _("Program terminated.")
sys.exit()
if fileType != "tx" and fileType != "rx":
print _("Error. File type must be either tx or rx.")
print _('Multiple types are not accepted.' )
print _("Use -h for additional help.")
print _("Program terminated.")
sys.exit()
if groupName != "" and combineClients == False :
print _("Error. -g|--groupeName option requires the --combineClients options.")
print _('Group names are otherwise irrelevant.' )
print _("Use -h for additional help.")
print _("Program terminated.")
sys.exit()
try :
if fileType == "tx":
validTypes = [ _("errors"), _("filecount"), _("bytecount"), _("latency") ]
if types[0] == _("All"):
types = validTypes
else :
for t in types :
if t not in validTypes:
raise Exception("")
else:
validTypes = [ _("errors"), _("filecount"), _("bytecount") ]
if types[0] == _("All"):
types = validTypes
else :
for t in types :
if t not in validTypes:
raise Exception("")
except:
print _("Error. With %s fileType, possible data types values are : %s.") %( fileType,validTypes )
print _('For multiple types use this syntax : -t "type1,type2"')
print _("Use -h for additional help.")
print _("Program terminated.")
sys.exit()
if outputLanguage not in LanguageTools.getSupportedLanguages():
print _("Error. %s is not one of the supproted languages")
print _("Use one of the following languages : %s" % str( LanguageTools.getSupportedLanguages() ).replace("[","").replace("]","") )
print _("Use -h for additional help.")
print _("Program terminated.")
clientNames = GeneralStatsLibraryMethods.filterClientsNamesUsingWilcardFilters( currentTime, timespan, clientNames, machines, [fileType])
directory = GeneralStatsLibraryMethods.getPathToLogFiles( LOCAL_MACHINE, machines[0] )
infos = _GraphicsInfos( collectUpToNow = collectUpToNow, currentTime = currentTime, clientNames = clientNames,\
groupName = groupName, directory = directory , types = types, fileType = fileType, \
timespan = timespan, productTypes = productTypes, machines = machines, copy = copy, \
combineClients = combineClients, outputLanguage = outputLanguage )
if collectUpToNow == False:
infos.endTime = StatsDateLib.getIsoWithRoundedHours( infos.currentTime )
return infos
示例11: getGraphicProducerFromParserOptions
# 需要导入模块: from pxStats.lib.LanguageTools import LanguageTools [as 别名]
# 或者: from pxStats.lib.LanguageTools.LanguageTools import getSupportedLanguages [as 别名]
def getGraphicProducerFromParserOptions( parser ):
"""
This method parses the argv received when the program was called
It takes the params wich have been passed by the user and sets them
in the corresponding fields of the infos variable.
If errors are encountered in parameters used, it will immediatly terminate
the application.
"""
graphicType = _("other")
mergerType = ""
( options, args )= parser.parse_args()
timespan = options.timespan
machines = options.machines.replace( ' ','').split(',')
clientNames = options.clients.replace( ' ','' ).split(',')
types = options.types.replace( ' ', '').split(',')
date = options.date.replace('"','').replace("'",'')
fileType = options.fileType.replace("'",'')
havingRun = options.havingRun
individual = options.individual
totals = options.totals
daily = options.daily
weekly = options.weekly
monthly = options.monthly
yearly = options.yearly
fixedCurrent = options.fixedCurrent
fixedPrevious = options.fixedPrevious
copy = options.copy
turnOffLogging = options.turnOffLogging
outputLanguage = options.outputLanguage
if outputLanguage == "":
outputLanguage = LanguageTools.getMainApplicationLanguage()
else :
if outputLanguage not in LanguageTools.getSupportedLanguages():
print _("Error. The specified language is not currently supported by this application.")
print _("Please specify one of the following languages %s or use the default value()" %( str( LanguageTools.getSupportedLanguages() ).replace("[","").replace("]",""), LanguageTools.getMainApplicationLanguage() ) )
print _("Program terminated.")
sys.exit()
counter = 0
specialParameters = [daily, monthly, weekly, yearly]
for specialParameter in specialParameters:
if specialParameter:
counter = counter + 1
if counter > 1 :
print _("Error. Only one of the daily, weekly and yearly options can be use at a time ")
print _("Use -h for help.")
print _("Program terminated.")
sys.exit()
elif counter == 1 and timespan != None :
print _("Error. When using the daily, the weekly or the yearly options timespan cannot be specified. " )
print _("Use -h for help.")
print _("Program terminated.")
sys.exit()
elif counter == 0:
if fixedPrevious or fixedCurrent:
print _("Error. When using one of the fixed options, please use either the -d -m -w or -y options. " )
print _("Use -h for help.")
print _("Program terminated.")
sys.exit()
if copy :
if daily or not( weekly or monthly or yearly ):
print _("Error. Copying can only be used with the -m -w or -y options. ")
print _("Use -h for help.")
print _("Program terminated.")
if counter == 0 and timespan == None :
timespan = 12
if fixedPrevious and fixedCurrent:
print _("Error. Please use only one of the fixed options,either fixedPrevious or fixedCurrent. ")
print _("Use -h for help.")
print _("Program terminated.")
sys.exit()
if individual and totals:
print _("Error. Please use only one of the group options,either individual or totals. ")
print _("Use -h for help.")
print _("Program terminated.")
sys.exit()
try: # Makes sure date is of valid format.
# Makes sure only one space is kept between date and hour.
t = time.strptime( date, '%Y-%m-%d %H:%M:%S' )
split = date.split()
date = "%s %s" %( split[0], split[1] )
except:
print _("Error. The date format must be YYYY-MM-DD HH:MM:SS")
#.........这里部分代码省略.........
示例12: getOptionsFromParser
# 需要导入模块: from pxStats.lib.LanguageTools import LanguageTools [as 别名]
# 或者: from pxStats.lib.LanguageTools.LanguageTools import getSupportedLanguages [as 别名]
def getOptionsFromParser( parser ):
"""
@summary : This method parses the argv received when the program was called
It takes the params wich have been passed by the user and sets them
in the corresponding fields of the infos variable.
If errors are encountered in parameters used, it will immediatly terminate
the application.
"""
( options, args )= parser.parse_args()
timespan = options.timespan
machines = options.machines.replace( ' ','' ).split( ',' )
combinedName = options.machines.replace( ' ','' ).replace( '[','' ).replace( ']', '' )
date = options.date.replace( '"','' ).replace( "'",'')
logins = options.logins.replace( '"', '' ).replace( " ","" ).split( ',' )
combine = options.combine
individual = options.individual
outputLanguage = options.outputLanguage
try: # Makes sure date is of valid format.
# Makes sure only one space is kept between date and hour.
t = time.strptime( date, '%Y-%m-%d %H:%M:%S' )#will raise exception if format is wrong.
split = date.split()
currentTime = "%s %s" %( split[0], split[1] )
except:
print _( "Error. The date format must be YYYY-MM-DD HH:MM:SS" )
print _( "Use -h for help." )
print _( "Program terminated." )
sys.exit()
try:
if int( timespan ) < 1 :
raise
except:
print _( "Error. The timespan value needs to be an integer one above 0." )
print _( "Use -h for help." )
print _( "Program terminated." )
sys.exit()
if len( logins ) != len( machines ) :
print _( "Error. Number of logins does not match number of machines." )
print _( "Use -l 'login1,login2,loginX' for multiple machines." )
print _( "Program terminated." )
sys.exit()
if outputLanguage not in LanguageTools.getSupportedLanguages():
print _("Error. %s is not one of the supproted languages")
print _("Use one of the following languages : %s") % str( LanguageTools.getSupportedLanguages() ).replace("[","").replace("]","")
print _("Use -h for additional help.")
print _("Program terminated.")
if len( machines ) == 1:
combine = False
individual = True
elif combine == False and individual == False :#no option specified + len >1
combine = True
infos = _Infos( date = date, machines = machines, timespan = timespan, logins = logins,\
combine = combine, individual = individual, combinedName = combinedName,\
outputLanguage = outputLanguage )
return infos