def run(self, args_orig): try: config = Configuration(args_orig) args = config.get_args() except ConfigurationException as ce: warnings.warn("Configuration exception occurred:") warnings.warn(ce) sys.exit(1) # check gnuplot version needed to HTML reports if config.is_html_output() and not config.is_valid_gnuplot_version(): warnings.warn("Invalid gnuplot version. Required " "minimal version: %s. Current version: %s" % (Configuration.GNUPLOT_MINIMAL_VERSION, config.get_gnuplot_version())) sys.exit(1) output_path = args.output_path run_dir = config.get_run_dir() print('Output path: %s' % output_path) cachefile = os.path.join(output_path, 'gitstats.cache') data = GitDataCollector(config.get_args_dict()) data.load_cache(cachefile) # todo: Check loop result. It seems every loop rewrite the collected information in data object. # Is this loop really needed? # for git_repo in args.git_repo: print('Git path: %s' % args.git_repo) prevdir = os.getcwd() os.chdir(args.git_repo) print('Collecting data...') data.collect(args.git_repo) os.chdir(prevdir) print('Refining data...') # data.saveCache(cachefile) data.refine() os.chdir(run_dir) print('Generating report...') # fixme: pass GitStatistics object directly when obsolete GitDataCollector is removed if config.is_html_output(): print('Generating HTML report...') report = HTMLReportCreator(config, data.repo_statistics) report.create(data, output_path) if sys.stdin.isatty(): print('You may now run:') print('') print(' sensible-browser \'%s\'' % os.path.join(output_path, 'general.html').replace("'", "'\\''")) print('') elif config.is_csv_output(): print('Generating CSV report...') report = CSVReportCreator() report.create(data.repo_statistics, output_path, config.get_args_dict(), config.is_append_csv()) print('CSV report created here: %s' % output_path) self.get_times()
def test_gnuplot_version_faild_not_exists(self): expected_project_name = "UTEST HTML Project" cli_params = list([ '--project_name=' + expected_project_name, self.repo_folder, self.output_folder ]) config = Configuration(cli_params) # rewrite fields with test data self.assertFalse(config.is_valid_gnuplot_version('-'))
def test_gnuplot_version_failed_lower(self): expected_project_name = "UTEST HTML Project" cli_params = list([ '--project_name=' + expected_project_name, self.repo_folder, self.output_folder ]) config = Configuration(cli_params) # rewrite fields with test data config.GNUPLOT_VERSION_STRING = '5.0' config.GNUPLOT_MINIMAL_VERSION = '5.2' self.assertFalse(config.is_valid_gnuplot_version())
def main(): try: config = Configuration(sys.argv[1:]) args = config.get_args() except ConfigurationException as ce: warnings.warn("Configuration exception occurred:") warnings.warn(ce) sys.exit(1) # check gnuplot version needed to HTML reports if config.is_html_output() and not config.is_valid_gnuplot_version(): warnings.warn("Invalid gnuplot version. Required " "minimal version: %s. Current version: %s" % (Configuration.GNUPLOT_MINIMAL_VERSION, config.get_gnuplot_version())) sys.exit(1) print('Git path: %s' % args.git_repo) print('Collecting data...') repository_statistics = GitStatistics(args.git_repo) output_path = args.output_path print('Output path: %s' % output_path) os.chdir(config.get_run_dir()) if config.is_html_output(): print('Generating HTML report...') report = HTMLReportCreator(config, repository_statistics) report.create(output_path) if sys.stdin.isatty(): print('You may now run:') print('') print(' sensible-browser \'%s\'' % os.path.join(output_path, 'general.html').replace("'", "'\\''")) print('') elif config.is_csv_output(): print('Generating CSV report...') report = CSVReportCreator() report.create(repository_statistics, output_path, config.get_args_dict(), config.is_append_csv()) print('CSV report created here: %s' % output_path) print_exec_times()