summaryrefslogtreecommitdiffstats
path: root/src/sbin
diff options
context:
space:
mode:
authorNarayan Desai <desai@mcs.anl.gov>2009-10-30 14:16:22 +0000
committerNarayan Desai <desai@mcs.anl.gov>2009-10-30 14:16:22 +0000
commita567a335b63b32bac5131bdda92a6f180c97e45e (patch)
tree6e3844a912a526a029d00cf75e29c91b37404a58 /src/sbin
parentd19d25e03a1ceb4471dc772f334747d4c4d7c6fb (diff)
downloadbcfg2-a567a335b63b32bac5131bdda92a6f180c97e45e.tar.gz
bcfg2-a567a335b63b32bac5131bdda92a6f180c97e45e.tar.bz2
bcfg2-a567a335b63b32bac5131bdda92a6f180c97e45e.zip
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
Diffstat (limited to 'src/sbin')
-rwxr-xr-xsrc/sbin/bcfg2-info17
1 files changed, 13 insertions, 4 deletions
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'])