Changeset 47111 for funkload/branches/ben-refactor
- Timestamp:
- 07/13/06 18:28:41 (2 years ago)
- Files:
-
- funkload/branches/ben-refactor/funkload/BenchRunner.py (modified) (3 diffs)
- funkload/branches/ben-refactor/funkload/FunkLoadTestCase.py (modified) (4 diffs)
- funkload/branches/ben-refactor/funkload/browser.py (modified) (1 diff)
- funkload/branches/ben-refactor/funkload/optionconfigparser.py (modified) (3 diffs)
- funkload/branches/ben-refactor/funkload/utils.py (modified) (2 diffs)
- funkload/branches/ben-refactor/funkload/version.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
funkload/branches/ben-refactor/funkload/BenchRunner.py
r32283 r47111 207 207 self.sleep_time_min = test.conf_getFloat('bench', 'sleep_time_min') 208 208 self.sleep_time_max = test.conf_getFloat('bench', 'sleep_time_max') 209 209 self.fetcher_type = test.fetcher_type 210 210 211 # setup monitoring 211 212 monitor_hosts = [] # list of (host, port, descr) … … 427 428 text.append("* Current time: %s" % datetime.now().isoformat()) 428 429 text.append("* Configuration file: %s" % self.config_path) 430 text.append("* Fetcher: %s" % self.fetcher_type) 429 431 text.append("* Log xml: %s" % self.result_path) 430 432 text.append("* Server: %s" % self.test_url) … … 479 481 help="Don't load additional links like css " 480 482 "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 481 487 options, args = parser.parse_args() 482 488 if len(args) != 2: funkload/branches/ben-refactor/funkload/FunkLoadTestCase.py
r34386 r47111 38 38 from browser import Browser 39 39 from curlfetcher import CurlFetcher 40 from webunitfetcher import WebunitFetcher 40 41 from xmlrpclib import ServerProxy 41 42 … … 99 100 self.__class__.__name__ + '.conf') 100 101 config_path = os.path.abspath(config_path) 101 config = OptionConfigParser(config_path )102 config = OptionConfigParser(config_path, self.options) 102 103 self._config = config 103 104 self.conf_get = self._config.get … … 124 125 125 126 # 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, 127 129 log_console=self.log_to.count('console')) 128 130 self.logger_result = get_logger(name="funkload.result", 129 131 log_console=False, 130 132 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 133 150 self.clearContext() 134 151 … … 569 586 ok = False 570 587 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', '')) 574 592 self.setUp() 575 593 except KeyboardInterrupt: funkload/branches/ben-refactor/funkload/browser.py
r34613 r47111 40 40 from webunitfetcher import WebunitFetcher 41 41 from htmlresourceparser import HTMLResourceParser 42 from utils import get_ logger, get_version, truncate, guess_file_extension42 from utils import get_version, truncate, guess_file_extension 43 43 44 44 funkload/branches/ben-refactor/funkload/optionconfigparser.py
r34382 r47111 31 31 32 32 options is a OptionParser object. 33 logger is a Logger34 33 35 34 Options should be of the format: section_key. … … 53 52 if options is not None: 54 53 opt_key = '%s_%s' % (section, key) 55 opt_val = getattr( self._options, opt_key, None)54 opt_val = getattr(options, opt_key, None) 56 55 if opt_val: 57 56 self.logd('[%s] %s = %s from options.' % 58 57 (section, key, opt_val)) 59 return opt_val58 return opt_val 60 59 # check for the configuration file if opt val is None 61 60 # or nul … … 83 82 """Return a list from options or configuration file.""" 84 83 value = self.get(section, key, default, quiet) 85 if value is default:86 return value84 if not value or value is default: 85 return default 87 86 if separator is None: 88 87 separator = ':' funkload/branches/ben-refactor/funkload/utils.py
r34385 r47111 157 157 158 158 159 def get_logger(name=None, log_path=None, log_console=True, level= None,159 def get_logger(name=None, log_path=None, log_console=True, level=logging.DEBUG, 160 160 format='%(asctime)s %(levelname)s %(message)s', propagate=True): 161 161 """Get a logger add handlers if needed.""" 162 162 if name is None: 163 163 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) 165 166 logger = logging.getLogger(name) 166 167 add_stream_hdlr = True … … 168 169 if logger.handlers: 169 170 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: 171 173 add_stream_hdlr = False 172 elif isinstance(hdlr, logging.FileHandler):174 elif hdlr.__class__ is logging.FileHandler: 173 175 add_file_hdlr = False 174 176 if log_console and add_stream_hdlr: funkload/branches/ben-refactor/funkload/version.py
r33704 r47111 21 21 $Id$ 22 22 """ 23 __version__ = ' 1.6.0'23 __version__ = '2.0.0'
