- prepare_static_content(spec)
-
- data = InputData(spec)
- data.read_data()
-
- generate_tables(spec, data)
- generate_plots(spec, data)
- generate_files(spec, data)
- generate_report(args.release, spec)
-
- logging.info("Successfully finished.")
-
- # except (KeyError, ValueError, PresentationError) as err:
- # logging.info("Finished with an error.")
- # logging.critical(str(err))
- # except Exception as err:
- # logging.info("Finished with an unexpected error.")
- # logging.critical(str(err))
- #
- # finally:
- # if spec is not None and not spec.is_debug:
- # clean_environment(spec.environment)
- # sys.exit(1)
-
-
-if __name__ == '__main__':
- main()
+ return_code = 1
+ try:
+ env = Environment(spec.environment, args.force)
+ env.set_environment()
+
+ prepare_static_content(spec)
+
+ data = InputData(spec, spec.output["output"])
+ if args.input_file:
+ data.process_local_file(args.input_file)
+ elif args.input_directory:
+ data.process_local_directory(args.input_directory)
+ else:
+ data.download_and_parse_data(repeat=1)
+
+ if args.print_all_oper_data:
+ data.print_all_oper_data()
+
+ generate_tables(spec, data)
+ generate_plots(spec, data)
+ generate_files(spec, data)
+
+ if spec.output["output"] == "report":
+ generate_report(args.release, spec, args.week)
+ elif spec.output["output"] == "trending":
+ sys.stdout.write(generate_cpta(spec, data))
+ try:
+ alert = Alerting(spec)
+ alert.generate_alerts()
+ except AlertingError as err:
+ logging.warning(repr(err))
+ elif spec.output["output"] == "convert-xml-to-json":
+ convert_xml_to_json(spec, data)
+ else:
+ logging.info("No output will be generated.")
+
+ logging.info("Successfully finished.")
+ return_code = 0
+
+ except AlertingError as err:
+ logging.critical(f"Finished with an alerting error.\n{repr(err)}")
+ except PresentationError as err:
+ logging.critical(f"Finished with a PAL error.\n{str(err)}")
+ except (KeyError, ValueError) as err:
+ logging.critical(f"Finished with an error.\n{repr(err)}")
+ finally:
+ if spec is not None:
+ clean_environment(spec.environment)
+ return return_code
+
+
+if __name__ == "__main__":
+ sys.exit(main())