yandextank/stepper/config.py
def get_ammo_generator(self):
        """
        return ammo generator
        """
        af_readers = {
            'phantom': missile.AmmoFileReader,
            'slowlog': missile.SlowLogReader,
            'line': missile.LineReader,
            'uri': missile.UriReader,
            'uripost': missile.UriPostReader,
            'access': missile.AccessLogReader,
            'caseline': missile.CaseLineReader,
        }
        if self.uris and self.ammo_file:
            raise StepperConfigurationError(
                'Both uris and ammo file specified. You must specify only one of them'
            )
        elif self.uris:
            ammo_gen = missile.UriStyleGenerator(
                self.uris, self.headers, http_ver=self.http_ver)
        elif self.ammo_file:
            if self.ammo_type in af_readers:
                if self.ammo_type == 'phantom':
                    opener = resource.get_opener(self.ammo_file)
                    with opener(self.use_cache) as ammo:
                        try:
                            if not ammo.next()[0].isdigit():
                                self.ammo_type = 'uri'
                                self.log.info(
                                    "Setting ammo_type 'uri' because ammo is not started with digit and you did not specify ammo format"
                                )
                            else:
                                self.log.info(
                                    "Default ammo type ('phantom') used, use 'phantom.ammo_type' option to override it"
                                )
                        except StopIteration:
                            self.log.exception(
                                "Couldn't read first line of ammo file")
                            raise AmmoFileError(
                                "Couldn't read first line of ammo file")
            else:
                raise NotImplementedError(
                    'No such ammo type implemented: "%s"' % self.ammo_type)
            ammo_gen = af_readers[self.ammo_type](
                self.ammo_file, headers=self.headers, http_ver=self.http_ver, use_cache=self.use_cache)
        else:
            raise StepperConfigurationError(
                'Ammo not found. Specify uris or ammo file')
        self.log.info("Using %s ammo reader" % type(ammo_gen).__name__)
        return ammo_gen
def get_ammo_generator(self):
        af_readers = {
            'phantom': missile.AmmoFileReader,
            'slowlog': missile.SlowLogReader,
            'line': missile.LineReader,
            'uri': missile.UriReader,
            'uripost': missile.UriPostReader,
            'access': missile.AccessLogReader,
            'caseline': missile.CaseLineReader,
        }
        if self.uris and self.ammo_file:
            raise StepperConfigurationError(
                'Both uris and ammo file specified. You must specify only one of them'
            )
        elif self.uris:
            ammo_gen = missile.UriStyleGenerator(
                self.uris, self.headers, http_ver=self.http_ver)
        elif self.ammo_file:
            if self.ammo_type in af_readers:
                if self.ammo_type == 'phantom':
                    opener = resource.get_opener(self.ammo_file)
                    with opener(self.use_cache) as ammo:
                        try:
                            if not ammo.next()[0].isdigit():
                                self.ammo_type = 'uri'
                                self.log.info(
                                    "Setting ammo_type 'uri' because ammo is not started with digit and you did not specify ammo format"
                                )
                            else:
                                self.log.info(
                                    "Default ammo type ('phantom') used, use 'phantom.ammo_type' option to override it"
                                )
                        except StopIteration:
                            self.log.exception(
                                "Couldn't read first line of ammo file")
                            raise AmmoFileError(
                                "Couldn't read first line of ammo file")
            else:
                raise NotImplementedError(
                    'No such ammo type implemented: "%s"' % self.ammo_type)
            ammo_gen = af_readers[self.ammo_type](
                self.ammo_file, headers=self.headers, http_ver=self.http_ver, use_cache=self.use_cache)
        else:
            raise StepperConfigurationError(
                'Ammo not found. Specify uris or ammo file')
        self.log.info("Using %s ammo reader" % type(ammo_gen).__name__)
        return ammo_gen
def get_ammo_generator ( self ) : af_readers = { 'phantom' : missile . AmmoFileReader , 'slowlog' : missile . SlowLogReader , 'line' : missile . LineReader , 'uri' : missile . UriReader , 'uripost' : missile . UriPostReader , 'access' : missile . AccessLogReader , 'caseline' : missile . CaseLineReader , } if self . uris and self . ammo_file : raise StepperConfigurationError ( 'Both uris and ammo file specified. You must specify only one of them' ) elif self . uris : ammo_gen = missile . UriStyleGenerator ( self . uris , self . headers , http_ver = self . http_ver ) elif self . ammo_file : if self . ammo_type in af_readers : if self . ammo_type == 'phantom' : opener = resource . get_opener ( self . ammo_file ) with opener ( self . use_cache ) as ammo : try : if not ammo . next ( ) [ 0 ] . isdigit ( ) : self . ammo_type = 'uri' self . log . info ( "Setting ammo_type 'uri' because ammo is not started with digit and you did not specify ammo format" ) else : self . log . info ( "Default ammo type ('phantom') used, use 'phantom.ammo_type' option to override it" ) except StopIteration : self . log . exception ( "Couldn't read first line of ammo file" ) raise AmmoFileError ( "Couldn't read first line of ammo file" ) else : raise NotImplementedError ( 'No such ammo type implemented: "%s"' % self . ammo_type ) ammo_gen = af_readers [ self . ammo_type ] ( self . ammo_file , headers = self . headers , http_ver = self . http_ver , use_cache = self . use_cache ) else : raise StepperConfigurationError ( 'Ammo not found. Specify uris or ammo file' ) self . log . info ( "Using %s ammo reader" % type ( ammo_gen ) . __name__ ) return ammo_gen
return ammo generator
return ammo generator