Changeset 5516

Show
Ignore:
Timestamp:
10/30/09 09:16:22 (3 weeks ago)
Author:
desai
Message:

bcfg2-info: fix traceback when python-profiler is not available (see Ticket #767 for details)

Location:
trunk/bcfg2
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/bcfg2/debian/changelog

    r5512 r5516  
    22 
    33  * Update packaging 
    4     * Switch to plain debhelper 
    5     * Switch from pycentral to python-support 
    6     * Move homepage to the dedicated Homepage field 
    7     * Update Standards-Version to 3.8.3.0 
     4  * Switch to plain debhelper 
     5  * Switch from pycentral to python-support 
     6  * Move homepage to the dedicated Homepage field 
     7  * Update Standards-Version to 3.8.3.0 
    88 
    99 -- Sami Haahtinen <ressu@debian.org>  Sat, 24 Oct 2009 00:20:51 +0300 
  • trunk/bcfg2/src/sbin/bcfg2-info

    r5504 r5516  
    1010import lxml.etree 
    1111import os 
    12 import profile 
    13 import pstats 
    1412import sys 
    1513import tempfile 
     14 
     15try: 
     16    import profile 
     17    import pstats 
     18    have_profile = True 
     19except: 
     20    have_profile = False 
    1621 
    1722import Bcfg2.Logger 
     
    411416 
    412417    def do_profile(self, arg): 
     418        if not have_profile: 
     419            print("Profiling functionality not available") 
     420            return 
    413421        tracefname = tempfile.mktemp() 
    414422        p = profile.Profile() 
     
    437445    setup = Bcfg2.Options.OptionParser(optinfo) 
    438446    setup.parse(sys.argv[1:]) 
    439     print(setup) 
    440     if setup['profile']: 
     447    if setup['profile'] and have_profile: 
    441448        prof = profile.Profile() 
    442449        loop = prof.runcall(infoCore, setup['repo'], setup['plugins'], 
     
    445452        displayTrace(prof) 
    446453    else: 
     454        if setup['profile']: 
     455            print("Profiling functionality not available") 
    447456        loop = infoCore(setup['repo'], setup['plugins'], setup['password'], 
    448457                        setup['encoding'], setup['event debug'])