def main(): usage = '%prog result_dir [report_dir]' parser = OptionParser(usage, version="FunkLoad %s" % get_version()) parser.add_option("-p", "--port", type="int", default=8000, dest="port", help="port used to run the server") options, args = parser.parse_args() if len(args) > 2 or len(args) == 0: parser.print_help() sys.exit(1) results_dir = args[0] if not os.path.exists(results_dir): print("%r does not exists" % results_dir) parser.print_help() sys.exit(1) if len(args) == 1: reports_dir = os.path.join(args[0], 'reports') else: reports_dir = args[1] if not os.path.exists(reports_dir): print("%r does not exists" % reports_dir) parser.print_help() sys.exit(1) sys.exit(run_server(results_dir, reports_dir, options.port))
def _open_result_log(self, **kw): """Use the same stamp for the results, logs, and reports""" time = datetime.datetime.now() stamp = time.isoformat()[:19].replace( ':', '').replace('-', '') utils.close_logger("FunkLoad") log_path = os.path.splitext(self.log_path) self.logger = utils.get_default_logger( self.log_to, '%s-%s%s' % (log_path[0], stamp, log_path[1])) utils.close_logger("FunkLoadResult") result_path = os.path.splitext(self.result_path) self.logger_result = utils.get_default_logger( log_to="xml", log_path='%s-%s%s' % (result_path[0], stamp, result_path[1]), name="FunkLoadResult") xml = ['<funkload version="%s" time="%s">' % (utils.get_version(), time.isoformat())] for key, value in kw.items(): xml.append('<config key="%s" value=%s />' % ( key, saxutils.quoteattr(str(value)))) self._logr('\n'.join(xml), force=True)
def start_log(self): self.xml_logger.start_log('funkload', { 'version': get_version(), 'time': datetime.now().isoformat() })
import os import collections import optparse import xml.parsers.expat from funkload import utils from funkload import ReportRenderHtml from funkload import ReportRenderDiff from funkload import ReportBuilder parser = optparse.OptionParser( ReportBuilder.USAGE, formatter=optparse.TitledHelpFormatter(), version="FunkLoad %s" % utils.get_version()) output_option = parser.add_option( "-o", "--output-directory", type="string", dest="output_dir", help="Parent directory to store reports, the directory" "name of the report will be generated automatically.", default=os.path.abspath(os.getcwd())) report_option = parser.add_option( "-r", "--report-directory", type="string", dest="report_dir", help="Directory name to store the report.", default=None) percent_option = parser.add_option( "-P", "--with-percentiles", action="store_true", default=True, dest="with_percentiles", help=("Include percentiles in tables, use 10%, 50% and" " 90% for charts, default option."))