コード例 #1
0
ファイル: poisson.py プロジェクト: mihaic/p2p-testframework
    def parseSetting(self, key, value):
        """
        Parse a single setting for this object.

        Settings are written in text files in a key=value fashion.
        For each such setting that belongs to this object this method will be called.

        After all settings have been given, the method checkSettings will be called.

        If a setting does not parse correctly, this method raises an Exception with a descriptive message.

        Subclassers should first parse their own settings and then call this implementation to have the
        generic settings parsed and to have any unknown settings raise an Exception.
        
        @param  key     The name of the parameter, i.e. the key from the key=value pair.
        @param  value   The value of the parameter, i.e. the value from the key=value pair.
        """
        if key == 'duration':
            if self.duration:
                parseError( "Duration was already specified: {0}".format( self.duration ) )
            if self.rate:
                parseError( "Rate was already specified: {0}".format( self.rate ) )
            if not isPositiveFloat( value, True ):
                parseError( "Duration should be a non-zero positive floating point number." )
            self.duration = float(value)
        elif key == 'rate':
            if self.duration:
                parseError( "Duration was already specified: {0}".format( self.duration ) )
            if self.rate:
                parseError( "Rate was already specified: {0}".format( self.rate ) )
            if not isPositiveFloat( value, True ):
                parseError( "Rate should be a non-zero positive floating point number." )
            self.rate = float(value)
        else:
            workload.parseSetting(self, key, value)
コード例 #2
0
    def parseSetting(self, key, value):
        """
        Parse a single setting for this object.

        Settings are written in text files in a key=value fashion.
        For each such setting that belongs to this object this method will be called.

        After all settings have been given, the method checkSettings will be called.

        If a setting does not parse correctly, this method raises an Exception with a descriptive message.

        Subclassers should first parse their own settings and then call this implementation to have the
        generic settings parsed and to have any unknown settings raise an Exception.
        
        @param  key     The name of the parameter, i.e. the key from the key=value pair.
        @param  value   The value of the parameter, i.e. the value from the key=value pair.
        """
        # TODO: Parse your settings. Example:
        #
        #   if key == 'duration':
        #       if self.duration:
        #           parseError( "Duration was already specified: {0}".format( self.duration ) )
        #       if self.interval:
        #           parseError( "Interval was already specified: {0}".format( self.interval ) )
        #       if not isPositiveFloat( value, True ):
        #           parseError( "Duration should be a non-zero positive floating point number." )
        #       self.duration = float(value)
        #   elif key == 'interval':
        #       if self.duration:
        #           parseError( "Duration was already specified: {0}".format( self.duration ) )
        #       if self.interval:
        #           parseError( "Interval was already specified: {0}".format( self.interval ) )
        #       if not isPositiveFloat( value, True ):
        #           parseError( "Interval should be a non-zero positive floating point number." )
        #       self.interval = float(value)
        #   elif key == 'rate':
        #       if self.duration:
        #           parseError( "Duration was already specified: {0}".format( self.duration ) )
        #       if self.interval:
        #           parseError( "Interval was already specified: {0}".format( self.interval ) )
        #       if not isPositiveFloat( value, True ):
        #           parseError( "Rate should be a non-zero positive floating point number." )
        #       self.interval = 1.0 / float(value)
        #   else:
        #       workload.parseSetting(self, key, value)
        #
        # Do not forget that last case!
        #
        # The following implementation assumes you have no parameters specific to your workload:
        workload.parseSetting(self, key, value)