Skip to content

Commit

Permalink
Extend the profiling env options to generic bin/yum
Browse files Browse the repository at this point in the history
  • Loading branch information
james-antill committed Jan 23, 2008
1 parent 590c5a7 commit 83628d8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion bin/yum.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
sys.path.insert(0, '/usr/share/yum-cli')
try:
import yummain
yummain.main(sys.argv[1:])
yummain.user_main(sys.argv[1:])
except KeyboardInterrupt, e:
print >> sys.stderr, "\n\nExiting on user cancel."
sys.exit(1)
21 changes: 15 additions & 6 deletions yummain.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,14 +224,23 @@ def print_stats(stats):
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 errcode is None:
errcode = main(args)
if exit_code:
sys.exit(errcode)
return exit_code

if __name__ == "__main__":
try:
if 'YUM_PROF' in os.environ:
if os.environ['YUM_PROF'] == 'cprof':
sys.exit(cprof(main, sys.argv[1:]))
if os.environ['YUM_PROF'] == 'hotshot':
sys.exit(hotshot(main, sys.argv[1:]))
sys.exit(main(sys.argv[1:]))
user_main(sys.argv[1:], exit_code=True)
except KeyboardInterrupt, e:
print >> sys.stderr, "\n\nExiting on user cancel."
sys.exit(1)

0 comments on commit 83628d8

Please sign in to comment.