Changeset 30199

Show
Ignore:
Timestamp:
12/01/05 17:29:46 (3 years ago)
Author:
bdelbosc
Message:

adding simple-fetch option, +cosmetic

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • funkload/trunk/funkload/BenchRunner.py

    r30187 r30199  
    476476                      help="Do not fail if css/image links are " 
    477477                      "not reachable.") 
     478    parser.add_option("", "--simple-fetch", action="store_true", 
     479                      help="Don't load additional links like css " 
     480                      "or images when fetching an html page.") 
    478481    options, args = parser.parse_args() 
    479482    if len(args) != 2: 
  • funkload/trunk/funkload/FunkLoadTestCase.py

    r29933 r30199  
    7070        self.options = options 
    7171        self._funkload_init() 
    72         self.dumping = getattr(options, 'dump_dir', False) and True 
    73         self.viewing = getattr(options, 'firefox_view', False) 
    74         self.accept_invalid_links = getattr(options, 'accept_invalid_links', 
    75                                             False) 
    76         if self.viewing and not self.dumping: 
     72        self._dump_dir = getattr(options, 'dump_dir', None) 
     73        self._dumping =  self._dump_dir and True or False 
     74        self._viewing = getattr(options, 'firefox_view', False) 
     75        self._accept_invalid_links = getattr(options, 'accept_invalid_links', 
     76                                             False) 
     77        self._simple_fetch = getattr(options, 'simple_fetch', False) 
     78        if self._viewing and not self._dumping: 
    7779            # viewing requires dumping contents 
    78             self.dumping = True 
    79             self.options.dump_dir = mkdtemp('_funkload') 
     80            self._dumping = True 
     81            self._dump_dir = mkdtemp('_funkload') 
    8082        self._loop_mode = getattr(options, 'loop_steps', False) 
    8183        if self._loop_mode: 
     
    161163        """Return an entry from the options or configuration file.""" 
    162164        # check for a command line options 
    163         opt_key = '%s_%s' %(section, key) 
     165        opt_key = '%s_%s' % (section, key) 
    164166        opt_val = getattr(self.options, opt_key, None) 
    165167        if opt_val: 
     
    219221                self.log_response(value.response, rtype, description, 
    220222                                  t_start, t_stop, log_body=True) 
    221                 if self.dumping: 
     223                if self._dumping: 
    222224                    self.dump_content(value.response) 
    223225                raise self.failureException, str(value.response) 
     
    244246        self.logd(' Done in %.3fs' % t_delta) 
    245247        self.log_response(response, rtype, description, t_start, t_stop) 
    246         if self.dumping: 
     248        if self._dumping: 
    247249            self.dump_content(response) 
    248250        return response 
     
    254256               follow_redirect=True, load_auto_links=True, 
    255257               sleep=True): 
    256         """Simulate a browser.""" 
     258        """Simulate a browser handle redirects, load/cache css and images.""" 
    257259        self._response = None 
    258260        # Loop mode 
     
    313315        # Load auto links (css and images) 
    314316        response.is_html = is_html(response.body) 
    315         if load_auto_links and response.is_html
     317        if load_auto_links and response.is_html and not self._simple_fetch
    316318            self.logd(' Load css and images...') 
    317319            page = response.body 
     
    321323                self._browser.pageImages(url, page, self) 
    322324            except HTTPError, error: 
    323                 if self.accept_invalid_links: 
     325                if self._accept_invalid_links: 
    324326                    self.logd('  ' + str(error)) 
    325327                else: 
     
    442444        while(True): 
    443445            try: 
    444                 response = self._browser.fetch(url, None, 
    445                                                ok_codes=[200,301,302]) 
     446                self._browser.fetch(url, None, ok_codes=[200,301,302]) 
    446447            except SocketError: 
    447448                if time.time() - time_start > time_out: 
     
    666667 
    667668        Use firefox to render the content if we are in rt viewing mode.""" 
    668         dump_dir = getattr(self.options, 'dump_dir', None) 
     669        dump_dir = self._dump_dir 
    669670        if dump_dir is None: 
    670671            return 
     
    680681        f.write(response.body) 
    681682        f.close() 
    682         if self.viewing: 
     683        if self._viewing: 
    683684            cmd = 'firefox -remote  "openfile(file://%s,new-tab)"' % file_path 
    684685            ret = os.system(cmd) 
     686            if ret != 0: 
     687                self.logi('Failed to remote control firefox: %s' % cmd) 
     688                self._viewing = False 
    685689 
    686690    # 
  • funkload/trunk/funkload/TestRunner.py

    r29933 r30199  
    258258        parser.add_option("-n", "--loop-number", type="int", 
    259259                          dest="loop_number", default=10, 
    260                           help="Number of loop") 
     260                          help="Number of loop.") 
    261261        parser.add_option("", "--accept-invalid-links", action="store_true", 
    262262                          help="Do not fail if css/image links are " 
    263263                          "not reachable.") 
     264        parser.add_option("", "--simple-fetch", action="store_true", 
     265                          help="Don't load additional links like css " 
     266                          "or images when fetching an html page.") 
    264267 
    265268