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


Python LanguageTools.getTranslatorForModule方法代码示例

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


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

示例1: setGlobalLanguageParameters

# 需要导入模块: from pxStats.lib.LanguageTools import LanguageTools [as 别名]
# 或者: from pxStats.lib.LanguageTools.LanguageTools import getTranslatorForModule [as 别名]
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") }
开发者ID:hawkeye438,项目名称:metpx,代码行数:30,代码来源:csvDataConversion.py

示例2: setLanguage

# 需要导入模块: from pxStats.lib.LanguageTools import LanguageTools [as 别名]
# 或者: from pxStats.lib.LanguageTools.LanguageTools import getTranslatorForModule [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 )
开发者ID:hawkeye438,项目名称:metpx,代码行数:12,代码来源:StatsDateLib.py

示例3: giveOutPermissionsToFolders

# 需要导入模块: from pxStats.lib.LanguageTools import LanguageTools [as 别名]
# 或者: from pxStats.lib.LanguageTools.LanguageTools import getTranslatorForModule [as 别名]
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 )
开发者ID:hawkeye438,项目名称:metpx,代码行数:55,代码来源:installPxStatsWebInterface.py

示例4: setPaths

# 需要导入模块: from pxStats.lib.LanguageTools import LanguageTools [as 别名]
# 或者: from pxStats.lib.LanguageTools.LanguageTools import getTranslatorForModule [as 别名]
    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/" )
开发者ID:hawkeye438,项目名称:metpx,代码行数:52,代码来源:StatsPaths.py

示例5: getTranslatorForModule

# 需要导入模块: from pxStats.lib.LanguageTools import LanguageTools [as 别名]
# 或者: from pxStats.lib.LanguageTools.LanguageTools import getTranslatorForModule [as 别名]
 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 )  
开发者ID:hawkeye438,项目名称:metpx,代码行数:16,代码来源:Translatable.py

示例6: setGlobalLanguageParameters

# 需要导入模块: from pxStats.lib.LanguageTools import LanguageTools [as 别名]
# 或者: from pxStats.lib.LanguageTools.LanguageTools import getTranslatorForModule [as 别名]
def  setGlobalLanguageParameters():
    """
        @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.
        
        @return: None
        
    """
    
    global _ 
    
    _ = LanguageTools.getTranslatorForModule( CURRENT_MODULE_ABS_PATH )    
开发者ID:hawkeye438,项目名称:metpx,代码行数:19,代码来源:sameLanguagePotFileTranslator.py

示例7: setGlobalLanguageParameters

# 需要导入模块: from pxStats.lib.LanguageTools import LanguageTools [as 别名]
# 或者: from pxStats.lib.LanguageTools.LanguageTools import getTranslatorForModule [as 别名]
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)    
开发者ID:hawkeye438,项目名称:metpx,代码行数:19,代码来源:graphicsRequestBroker.py

示例8: __getFileNameFromExecutionOutput

# 需要导入模块: from pxStats.lib.LanguageTools import LanguageTools [as 别名]
# 或者: from pxStats.lib.LanguageTools.LanguageTools import getTranslatorForModule [as 别名]
 def __getFileNameFromExecutionOutput( self, output ):
     """
         @summary : Parses an execution output coming from the 
                    csvDataConversion.py file and searchs for 
                    the filename that was generated.
     
     """
     
     global _
     
     _ = LanguageTools.getTranslatorForModule(CURRENT_MODULE_ABS_PATH, self.outputLanguage )
     
     fileName = ""
     
     lines = str( output ).splitlines()
     
     for line in lines:
         if _( "generated filename : " ) in str(line).lower():
             fileName = line.split( _( "generated filename : " ) )[1].replace(' ','') 
             break
 
     return fileName
开发者ID:hawkeye438,项目名称:metpx,代码行数:24,代码来源:WebPageCsvFilesGenerator.py

示例9: createSubFolders

# 需要导入模块: from pxStats.lib.LanguageTools import LanguageTools [as 别名]
# 或者: from pxStats.lib.LanguageTools.LanguageTools import getTranslatorForModule [as 别名]
def createSubFolders( path, currentlyUsedLanguages ):
    """
        @summary : Creates all the required sub folders.
        
        @param path : Paths in which we are installing the web interface.  
        
        @param currentlyUsedLanguages: Languages currently set to be 
                                       displayed in the web interface. 
        
    """
    
    global _ 
    subFolders = [ "scripts" ] 
    
    for language in currentlyUsedLanguages :
        _ = LanguageTools.getTranslatorForModule( CURRENT_MODULE_ABS_PATH, language )
        subFolders.append( _("wordDatabases") )
    
    
    for subFolder in subFolders :
        if not os.path.isdir( path + '/'+ subFolder ):
            os.makedirs( path + '/' + subFolder )
开发者ID:hawkeye438,项目名称:metpx,代码行数:24,代码来源:installPxStatsWebInterface.py

示例10: updateWordsFromDB

# 需要导入模块: from pxStats.lib.LanguageTools import LanguageTools [as 别名]
# 或者: from pxStats.lib.LanguageTools.LanguageTools import getTranslatorForModule [as 别名]
def updateWordsFromDB(wordType, word, language):
    """    
        @summary: Updates words within the db depending 
                  on the specified type ofdatabases
        
        @param wordType     : Type of word : "products" or "groupName"
        
        @parameter language : Language that is currently used by the caller.
        
        @param word         : Word to add to the database
        
        @return             : None     
        
    """

    _ = LanguageTools.getTranslatorForModule(CURRENT_MODULE_ABS_PATH, language)

    statsPaths = StatsPaths()
    statsPaths.setPaths(language)

    if wordType == "products":
        updateWordsFromFile(statsPaths.STATSWEBWORDDATABASES + _("products"), word)
    elif wordType == "groupName":
        updateWordsFromFile(statsPaths.STATSWEBWORDDATABASES + _("groupNames"), word)
开发者ID:khosrow,项目名称:metpx,代码行数:26,代码来源:updateWordsInDB.py

示例11: generateWebPage

# 需要导入模块: from pxStats.lib.LanguageTools import LanguageTools [as 别名]
# 或者: from pxStats.lib.LanguageTools.LanguageTools import getTranslatorForModule [as 别名]
def generateWebPage( sourlientNames, groups, fileType, outputFileName, language ):
    """
    
        
        @summary: Generates popupAdder web page named after the 
                  received outputFileName and based on the 
                  list of sourlients names received  
        
        @param sourlientNames : List of sources or clients that need to be printed.
        
        @param groups : List of groups that need to be printed.
        
        @param fileType:  tx or rx 
        
        @param outputFileName : Filename that needs to be created.
        
        @return : None
    
    """
     
    statsPaths = StatsPaths()
    statsPaths.setPaths(language)
    
    _ = LanguageTools.getTranslatorForModule( CURRENT_MODULE_ABS_PATH, language )        
    
    if not  os.path.isdir( os.path.dirname(outputFileName) ):
        os.makedirs( os.path.dirname(outputFileName) )
    
    """ Redirect the output"""  
    #print outputFileName
    fileHandle = open( outputFileName, "w" )
    oldStdOut = sys.stdout #save previous stdout
    sys.stdout = fileHandle
    
    print """
    
    <html>
      <head>
        
        <title>Add items to list.</title>
        <meta name="Author" content="Nicholas Lemay">
        <meta name="Description" content="Small popup window used to add items into a list. To be used with graphicsResquests.py">
        <meta name="Keywords" content="">
        <style type="text/css">
            div.selectObject{
                width:300px;            
                height: auto;
            }
            
            
        
        </style>
        <link rel="stylesheet" type="text/css" href="/css/style.css">
    
        <script type="text/javascript" language="JavaScript">
            
            function popupAddingWindow( url ) {
                var newWindow;
                var props = 'scrollBars=no,resizable=no,toolbar=no,menubar=no,location=no,directories=no,width=700,height=300';
                newWindow = window.open(url, "Add_from_Src_to_Dest", props);
            }
            
            function closeWindow(){
                window.close();
            }
            
            // Fill the selcted item list with the items already present in parent.
            function copyLists( srcList, destList ) {
                
                var len = destList.length;
                for(var i = 0; i < srcList.length; i++) {
                    if ( srcList.options[i] != null ) {
                        
                        //Check if this value already exist in the destList or not
                        //if not then add it otherwise do not add it.
                        var found = false;
                        for(var count = 0; count < len; count++) {
                            if (destList.options[count] != null) {
                                if (srcList.options[i].text == destList.options[count].text) {
                                    found = true;
                                    break;
                                }
                            }
                        }
                        
                        if (found != true) {
                            destList.options[len] = new Option(srcList.options[i].text); 
                            len++;
                        }
                    }
                }
            }
            
            
            // Add the SELECTED items from the source to destination list
            // will only add the items wich are not allready present in dest list.
            function addSrcToDestList( srcList, destList ) {
                var len = destList.length;
                for(var i = 0; i < srcList.length; i++) {
                    if ((srcList.options[i] != null) && (srcList.options[i].selected)) {
#.........这里部分代码省略.........
开发者ID:hawkeye438,项目名称:metpx,代码行数:103,代码来源:popupSourlientAdder.py

示例12: createLockFile

# 需要导入模块: from pxStats.lib.LanguageTools import LanguageTools [as 别名]
# 或者: from pxStats.lib.LanguageTools.LanguageTools import getTranslatorForModule [as 别名]
"""
    Imports which require pxlib 
"""
import PXManager
import PXPaths
from   PXManager import *



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

global _ 
_ = LanguageTools.getTranslatorForModule( CURRENT_MODULE_ABS_PATH ) 

class GeneralStatsLibraryMethods:
    

    def createLockFile( processName ):
        """
            @summary : Creates a lock file associated with the 
                       specified processName.
                       
            @param processName : Name of the process for which 
                                 to create the lock file.
            @return : None
                                              
        """
开发者ID:hawkeye438,项目名称:metpx,代码行数:31,代码来源:GeneralStatsLibraryMethods.py

示例13: buildRRDFileName

# 需要导入模块: from pxStats.lib.LanguageTools import LanguageTools [as 别名]
# 或者: from pxStats.lib.LanguageTools.LanguageTools import getTranslatorForModule [as 别名]
 def buildRRDFileName( dataType = 'errors', clients = None , machines = None,\
                       groupName = "", fileType = "", usage = "regular"  ):
     """
         @summary : Returns the name of the round robin database bases on the parameters.
     
         @param dataType: byteocunt, errors, filecount, filesOverMaxLatency and latency.
         
         @param clients: list of clients/sources names. If only one is wanted, include it in a list.
         
         @param machines: list of machines associated with client/sources names. If only one is wanted, include it in a list.
         
         @param fileType : Useless for regular and group databases. Obligatory for totalForMachine databases. 
         
         @param groupName: optional. Use only if the list of client/sources has a KNOWN group name.
         
         @param usage: regular, group or totalForMachine.
     
         @return: Returns the name of the round robin database bases on the parameters.
     
     """
     
     _ = LanguageTools.getTranslatorForModule( CURRENT_MODULE_ABS_PATH, LanguageTools.getMainApplicationLanguage() )
     
     clients  = clients or ['client1','client1']
     machines = machines or ['machine1','machine2']
     
     fileName = ""
     
     combinedMachineName = ""   
     for machine in machines:
         combinedMachineName = combinedMachineName + machine
       
     combinedClientsName = ""  
     for client in clients:
         combinedClientsName = combinedClientsName + client
            
     if len(clients) ==1:       
         if usage == "regular":
             fileName = STATSPATHS.STATSCURRENTDB + "%s/%s_%s" %( dataType, combinedClientsName, combinedMachineName )  
         
         elif usage == "group":
         
             fileName = STATSPATHS.STATSCURRENTDB + "%s/%s_%s" %( dataType, groupName, combinedMachineName )
              
         elif usage == "totalForMachine":
              fileName = STATSPATHS.STATSCURRENTDB + "%s/%s_%s" %( dataType, fileType, combinedMachineName )            
     
     else:
         
         if usage == "regular":
             fileName = STATSPATHS.STATSCURRENTDB + _("%s/combined/%s_%s") %( dataType, combinedClientsName, combinedMachineName )  
         
         elif usage == "group":
         
             #fileName = STATSPATHS.STATSCURRENTDB + _("%s/combined/%s_%s") %( dataType, groupName, combinedMachineName )    
             try:
                 existingFiles=  os.listdir(STATSPATHS.STATSCURRENTDB + "%s/combined/"%( dataType) )
             
                 for file in existingFiles:
                     if fnmatch.fnmatch(file, groupName + "*"):
                         fileName = file
                         break
             except:
                 pass
             
             if fileName == "":#no preexisitng file exist for this group
                 fileName = STATSPATHS.STATSCURRENTDB + "%s/%s_%s" %( dataType, groupName, combinedMachineName )    
             else:#else
                 fileName =  STATSPATHS.STATSCURRENTDB + "%s/combined/"%(dataType) + fileName       
              
              
         elif usage == "totalForMachine":
              fileName = STATSPATHS.STATSCURRENTDB + _("%s/combined/%s_%s") %( dataType, fileType, combinedMachineName )   
     
     #print "before ", fileName 
     #fileName = fileName.replace("année","year").replace("nbreDeBytes","bytecount").replace("nbreDeFichiers","filecount").replace("erreurs","errors").replace("latence","latency").replace("fichiersAvecLatenceInnacceptable","filesOverMaxLatency").replace("heures","hours").replace("mois","month").replace("jour","day").replace("","")    
     #print "after ", fileName
     
     return  fileName 
开发者ID:hawkeye438,项目名称:metpx,代码行数:81,代码来源:RrdUtilities.py


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