From a567a335b63b32bac5131bdda92a6f180c97e45e Mon Sep 17 00:00:00 2001 From: Narayan Desai Date: Fri, 30 Oct 2009 14:16:22 +0000 Subject: bcfg2-info: fix traceback when python-profiler is not available (see Ticket #767 for details) git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5516 ce84e21b-d406-0410-9b95-82705330c041 --- debian/changelog | 8 ++++---- src/sbin/bcfg2-info | 17 +++++++++++++---- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/debian/changelog b/debian/changelog index 81b94a155..88fd9da30 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,10 +1,10 @@ bcfg2 (1.0.0rc1-1) unstable; urgency=low * Update packaging - * Switch to plain debhelper - * Switch from pycentral to python-support - * Move homepage to the dedicated Homepage field - * Update Standards-Version to 3.8.3.0 + * Switch to plain debhelper + * Switch from pycentral to python-support + * Move homepage to the dedicated Homepage field + * Update Standards-Version to 3.8.3.0 -- Sami Haahtinen Sat, 24 Oct 2009 00:20:51 +0300 diff --git a/src/sbin/bcfg2-info b/src/sbin/bcfg2-info index 801fb1fc1..fd29f314f 100755 --- a/src/sbin/bcfg2-info +++ b/src/sbin/bcfg2-info @@ -9,11 +9,16 @@ import getopt import logging import lxml.etree import os -import profile -import pstats import sys import tempfile +try: + import profile + import pstats + have_profile = True +except: + have_profile = False + import Bcfg2.Logger import Bcfg2.Options import Bcfg2.Server.Core @@ -410,6 +415,9 @@ Usage: [quit|exit]""" print(cand[0].name) def do_profile(self, arg): + if not have_profile: + print("Profiling functionality not available") + return tracefname = tempfile.mktemp() p = profile.Profile() p.runcall(self.onecmd, arg) @@ -436,14 +444,15 @@ if __name__ == '__main__': 'encoding': Bcfg2.Options.ENCODING}) setup = Bcfg2.Options.OptionParser(optinfo) setup.parse(sys.argv[1:]) - print(setup) - if setup['profile']: + if setup['profile'] and have_profile: prof = profile.Profile() loop = prof.runcall(infoCore, setup['repo'], setup['plugins'], setup['password'], setup['encoding'], setup['event debug']) displayTrace(prof) else: + if setup['profile']: + print("Profiling functionality not available") loop = infoCore(setup['repo'], setup['plugins'], setup['password'], setup['encoding'], setup['event debug']) -- cgit v1.2.3-1-g7c22