def _download_log(self, url, output_file):
        """Saves log returned by the message bus."""
        logger.info("Saving log %s to %s", url, output_file)

        def _do_log_download():
            try:
                return self.session.get(url)
            # pylint: disable=broad-except
            except Exception as err:
                logger.error(err)

        # log file may not be ready yet, wait a bit
        for __ in range(5):
            log_data = _do_log_download()
            if log_data or log_data is None:
                break
            time.sleep(2)

        if not (log_data and log_data.content):
            logger.error("Failed to download log file %s.", url)
            return
        with open(os.path.expanduser(output_file), "ab") as out:
            out.write(log_data.content)
def _download_log ( self , url , output_file ) : logger . info ( "Saving log %s to %s" , url , output_file ) def _do_log_download ( ) : try : return self . session . get ( url ) except Exception as err : logger . error ( err ) for __ in range ( 5 ) : log_data = _do_log_download ( ) if log_data or log_data is None : break time . sleep ( 2 ) if not ( log_data and log_data . content ) : logger . error ( "Failed to download log file %s." , url ) return with open ( os . path . expanduser ( output_file ) , "ab" ) as out : out . write ( log_data . content )
Saves log returned by the message bus.