Beispiel #1
0
 def resolveNames(self):
     """
     Resolve any names given in the parameters.
     
     This methods is called after all objects have been initialized.
     """
     pdict = self.scenario.getObjectsDict('parser')
     if self.parserNames:
         for parser in self.parserNames:
             if parser not in pdict:
                 try:
                     Campaign.loadModule( 'parser', parser )
                 except ImportError:
                     raise Exception( "Execution defined at line {0} refers to parser {1} which is never declared".format( self.declarationLine, parser ) )
     self.host = self.scenario.resolveObjectName( 'host', self.hostName )
     self.client = self.scenario.resolveObjectName( 'client', self.clientName )
     self.files = []
     if self.fileNames:
         for fileName in self.fileNames:
             self.files.append( self.scenario.resolveObjectName( 'file', fileName ) )
     if self.parserNames:
         self.parsers = []
         for parser in self.parserNames:
             if parser in pdict:
                 self.parsers.append( pdict[parser] )
             else:
                 modclass = Campaign.loadModule( 'parser', parser )
                 # *Sigh*. PyLint. Dynamic loading!
                 # pylint: disable-msg=E1121
                 obj = modclass( self.scenario )
                 # pylint: enable-msg=E1121
                 obj.checkSettings()
                 self.parsers.append( obj )
Beispiel #2
0
    def loadDefaultParsers(self, execution):
        """
        Loads the default parsers for the given execution.

        The order in which parsers are determined is this (first hit goes):
        - The parsers given in the execution object
        - The parsers given in the client object
        - The parser object with the same name as the client
        - The parser with the same name as the client
        The second, third and fourth are to be loaded by this method.
        
        @param  execution       The execution for which to load a parser.

        @return The list of parser instances.
        """
        if self.parsers:
            return client.loadDefaultParsers(self, execution)
        else:
            if execution.isSeeder():
                parserType = 'lighttpd'
            else:
                parserType = 'aria2'
            if parserType in self.scenario.getObjectsDict( 'parser' ):
                return [self.scenario.getObjectsDict( 'parser' )[parserType]]
            else:
                modclass = Campaign.loadModule( 'parser', parserType )
                # *Sigh*. PyLint. Dynamic loading!
                # pylint: disable-msg=E1121
                obj = modclass( self.scenario )
                # pylint: enable-msg=E1121
                obj.checkSettings()
                return [obj]