[yum-git] bin/yum.py yummain.py
James Antill
james at linux.duke.edu
Wed Jan 23 16:15:38 UTC 2008
bin/yum.py | 2 +-
yummain.py | 21 +++++++++++++++------
2 files changed, 16 insertions(+), 7 deletions(-)
New commits:
commit 83628d8d722e04ec7a1b5d341d51802926fbc23f
Author: James Antill <james at and.org>
Date: Wed Jan 23 11:15:33 2008 -0500
Extend the profiling env options to generic bin/yum
diff --git a/bin/yum.py b/bin/yum.py
index 6a92ee6..1896498 100755
--- a/bin/yum.py
+++ b/bin/yum.py
@@ -26,7 +26,7 @@ the yum faq at:
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)
diff --git a/yummain.py b/yummain.py
index 8f4d8e2..d5f431b 100755
--- a/yummain.py
+++ b/yummain.py
@@ -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)
More information about the Yum-cvs-commits
mailing list