:param exit_code: if *exit_code* is True, this function will exit python with its exit code when it has finished executing. Otherwise, it will return its exit code. :return: the exit code from dnf.yum execution """ errcode = None if 'YUM_PROF' in os.environ: if os.environ['YUM_PROF'] == 'cprof': errcode = cprof(main, args) if os.environ['YUM_PROF'] == 'hotshot': errcode = hotshot(main, args) if 'YUM_PDB' in os.environ: import pdb pdb.run(main(args)) if errcode is None: errcode = main(args) if exit_code: sys.exit(errcode) return errcode suppress_keyboard_interrupt_message() if __name__ == "__main__": try: user_main(sys.argv[1:], exit_code=True) except KeyboardInterrupt, e: print >> sys.stderr, _("\n\nExiting on user cancel.") sys.exit(1)
stats.print_stats(20) stats.sort_stats('cumulative') stats.print_stats(40) def user_main(args, exit_code=False): """ This calls one of the multiple main() functions based on env. vars """ errcode = None if 'YUM_PROF' in os.environ: if os.environ['YUM_PROF'] == 'cprof': errcode = cprof(main, args) if os.environ['YUM_PROF'] == 'hotshot': errcode = hotshot(main, args) if 'YUM_PDB' in os.environ: import pdb pdb.run(main(args)) if errcode is None: errcode = main(args) if exit_code: sys.exit(errcode) return errcode suppress_keyboard_interrupt_message() if __name__ == "__main__": try: user_main(sys.argv[1:], exit_code=True) except KeyboardInterrupt, e: print >> sys.stderr, _("\n\nExiting on user cancel.") sys.exit(1)