def print_elapsed_time_summary(start, end): time_needed = end - start millis = ((time_needed.days * 24 * 60 * 60) + time_needed.seconds) * \ 1000 + time_needed.microseconds / 1000 print_text_line("Build finished at %s" % format_timestamp(end)) print_text_line("Build took %d seconds (%d ms)" % (time_needed.seconds, millis))
def main(*args): if not args: args = sys.argv[1:] try: options, arguments = parse_options(args) except CommandLineUsageException as e: print_error_line("Usage error: %s\n" % e) print_error(e.usage) return 1 start = datetime.datetime.now() logger = init_logger(options) reactor = init_reactor(logger) if options.start_project: return start_project() if options.update_project: return update_project() if options.list_tasks or options.list_plan_tasks: try: reactor.prepare_build(property_overrides=options.property_overrides, project_directory=options.project_directory, exclude_optional_tasks=options.exclude_optional_tasks, exclude_tasks=options.exclude_tasks, exclude_all_optional=options.exclude_all_optional ) if options.list_tasks: print_list_of_tasks(reactor, quiet=options.very_quiet) if options.list_plan_tasks: print_plan_list_of_tasks(options, arguments, reactor, quiet=options.very_quiet) return 0 except PyBuilderException as e: print_build_status(str(e), options, successful=False) return 1 if not options.very_quiet: print_styled_text_line( "PyBuilder version {0}".format(__version__), options, BOLD) print_text_line("Build started at %s" % format_timestamp(start)) draw_line() successful = True failure_message = None summary = None try: try: reactor.prepare_build(property_overrides=options.property_overrides, project_directory=options.project_directory, exclude_optional_tasks=options.exclude_optional_tasks, exclude_tasks=options.exclude_tasks, exclude_all_optional=options.exclude_all_optional ) if options.verbose or options.debug: logger.debug("Verbose output enabled.\n") reactor.project.set_property("verbose", True) summary = reactor.build( environments=options.environments, tasks=arguments) except KeyboardInterrupt: raise PyBuilderException("Build aborted") except (Exception, SystemExit) as e: successful = False failure_message = str(e) if options.debug: traceback.print_exc(file=sys.stderr) finally: end = datetime.datetime.now() if not options.very_quiet: print_summary( successful, summary, start, end, options, failure_message) if not successful: return 1 return 0
def test_should_format_timestamp(self): self.assert_matches(r"^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$", format_timestamp(datetime.datetime.now()))
def print_elapsed_time_summary(start, end): time_needed = end - start millis = ((time_needed.days * 24 * 60 * 60) + time_needed.seconds) * 1000 + time_needed.microseconds / 1000 print_text_line("Build finished at {0!s}".format(format_timestamp(end))) print_text_line("Build took {0:d} seconds ({1:d} ms)".format(time_needed.seconds, millis))