Show
Ignore:
Timestamp:
07/13/06 18:28:41 (2 years ago)
Author:
bdelbosc
Message:

fixing loggers and update bench runner

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • funkload/branches/ben-refactor/funkload/BenchRunner.py

    r32283 r47111  
    207207        self.sleep_time_min = test.conf_getFloat('bench', 'sleep_time_min') 
    208208        self.sleep_time_max = test.conf_getFloat('bench', 'sleep_time_max') 
    209  
     209        self.fetcher_type = test.fetcher_type 
     210         
    210211        # setup monitoring 
    211212        monitor_hosts = []                  # list of (host, port, descr) 
     
    427428        text.append("* Current time: %s" % datetime.now().isoformat()) 
    428429        text.append("* Configuration file: %s" % self.config_path) 
     430        text.append("* Fetcher: %s" % self.fetcher_type) 
    429431        text.append("* Log xml: %s" % self.result_path) 
    430432        text.append("* Server: %s" % self.test_url) 
     
    479481                      help="Don't load additional links like css " 
    480482                      "or images when fetching an html page.") 
     483    parser.add_option("", "--fetcher", type="string", dest="main_fetcher", 
     484                      help="Choose a fetcher: webunit or curl.") 
     485    parser.set_defaults(main_fetcher='curl') 
     486 
    481487    options, args = parser.parse_args() 
    482488    if len(args) != 2: 
  • funkload/branches/ben-refactor/funkload/FunkLoadTestCase.py

    r34386 r47111  
    3838from browser import Browser 
    3939from curlfetcher import CurlFetcher 
     40from webunitfetcher import WebunitFetcher 
    4041from xmlrpclib import ServerProxy 
    4142 
     
    99100                                   self.__class__.__name__ + '.conf') 
    100101        config_path = os.path.abspath(config_path) 
    101         config = OptionConfigParser(config_path
     102        config = OptionConfigParser(config_path, self.options
    102103        self._config = config 
    103104        self.conf_get = self._config.get 
     
    124125 
    125126        # init loggers 
    126         self.logger = get_logger(log_path=self.log_path, 
     127        self.logger = get_logger(name="funkload.log", 
     128                                 log_path=self.log_path, 
    127129                                 log_console=self.log_to.count('console')) 
    128130        self.logger_result = get_logger(name="funkload.result", 
    129131                                        log_console=False, 
    130132                                        log_path=self.result_path, 
    131                                         format=None, propagate=False) 
    132         self._browser = Browser(CurlFetcher) 
     133                                        format=None, propagate=True) 
     134        # init a browser 
     135        fetcher_type = self.conf_get('main', 'fetcher', 'curl') 
     136        if fetcher_type == 'webunit': 
     137            # webunit fetcher 
     138            self.fetcher_type = fetcher_type 
     139            browser = Browser(WebunitFetcher) 
     140        else: 
     141            # curl fetcher setup 
     142            self.fetcher_type = 'curl' 
     143            browser = Browser(CurlFetcher) 
     144            if self.conf_getInt('main', 'curl_concurrency', 0, quiet=True): 
     145                browser.concurrency = options.concurrency 
     146            if self.conf_getInt('main', 'curl_verbose', 0, quiet=True): 
     147                browser.fetcher.curlVerbose(1) 
     148 
     149        self._browser = browser 
    133150        self.clearContext() 
    134151 
     
    569586            ok = False 
    570587            try: 
    571                 self.logd('Starting -----------------------------------\n\t%s' 
    572                           % self.conf_get(self.meta_method_name, 'description', 
    573                                           '')) 
     588                if not self.in_bench_mode: 
     589                    self.logd( 
     590                        'Starting -----------------------------------\n\t%s' % 
     591                        self.conf_get(self.method_name, 'description', '')) 
    574592                self.setUp() 
    575593            except KeyboardInterrupt: 
  • funkload/branches/ben-refactor/funkload/browser.py

    r34613 r47111  
    4040from webunitfetcher import WebunitFetcher 
    4141from htmlresourceparser import HTMLResourceParser 
    42 from utils import get_logger, get_version, truncate, guess_file_extension 
     42from utils import get_version, truncate, guess_file_extension 
    4343 
    4444 
  • funkload/branches/ben-refactor/funkload/optionconfigparser.py

    r34382 r47111  
    3131 
    3232    options is a OptionParser object. 
    33     logger is a Logger 
    3433 
    3534    Options should be of the format: section_key. 
     
    5352        if options is not None: 
    5453            opt_key = '%s_%s' % (section, key) 
    55             opt_val = getattr(self._options, opt_key, None) 
     54            opt_val = getattr(options, opt_key, None) 
    5655            if opt_val: 
    5756                self.logd('[%s] %s = %s from options.' % 
    5857                           (section, key, opt_val)) 
    59             return opt_val 
     58                return opt_val 
    6059        # check for the configuration file if opt val is None 
    6160        # or nul 
     
    8382        """Return a list from options or configuration file.""" 
    8483        value = self.get(section, key, default, quiet) 
    85         if value is default: 
    86             return value 
     84        if not value or value is default: 
     85            return default 
    8786        if separator is None: 
    8887            separator = ':' 
  • funkload/branches/ben-refactor/funkload/utils.py

    r34385 r47111  
    157157 
    158158 
    159 def get_logger(name=None, log_path=None, log_console=True, level=None
     159def get_logger(name=None, log_path=None, log_console=True, level=logging.DEBUG
    160160               format='%(asctime)s %(levelname)s %(message)s', propagate=True): 
    161161    """Get a logger add handlers if needed.""" 
    162162    if name is None: 
    163163        name = ""                       # default logger 
    164     #print "ask '%s' path:%s level:%s" % (name, log_path, level) 
     164    # print "ask '%s' path:%s console:%s level:%s" % ( 
     165    #     name, log_path, log_console, level) 
    165166    logger = logging.getLogger(name) 
    166167    add_stream_hdlr = True 
     
    168169    if logger.handlers: 
    169170        for hdlr in logger.handlers: 
    170             if isinstance(hdlr, logging.StreamHandler): 
     171            # duno why isinstance(hdlr, logging.StreamHandler) doesn't work ? 
     172            if hdlr.__class__ is logging.StreamHandler: 
    171173                add_stream_hdlr = False 
    172             elif isinstance(hdlr, logging.FileHandler)
     174            elif hdlr.__class__ is logging.FileHandler
    173175                add_file_hdlr = False 
    174176    if log_console and add_stream_hdlr: 
  • funkload/branches/ben-refactor/funkload/version.py

    r33704 r47111  
    2121$Id$ 
    2222""" 
    23 __version__ = '1.6.0' 
     23__version__ = '2.0.0'