summaryrefslogtreecommitdiffstats
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
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
-rw-r--r--debian/changelog8
-rwxr-xr-xsrc/sbin/bcfg2-info17
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 <ressu@debian.org> 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'])