'Builds a crash-report when StarCluster encounters an unhandled
exception. Report includes system info, python version, dependency
versions, and a full debug log and stack-trace of the crash.'

def bug_found(self):

    dashes = ('-' * 10)
    header = (((dashes + '    %s    ') + dashes) + '\n')
    crashfile = open(static.CRASH_FILE, 'w')
    argv = sys.argv[:]
    argv[0] = os.path.basename(argv[0])
    argv = '    '.join(argv)
    crashfile.write((header % 'SYSTEM    INFO'))
    crashfile.write(('StarCluster:    %s\n' % __version__))
    crashfile.write(('Python:    %s\n' % sys.version.replace('\n', '    ')))
    crashfile.write(('Platform:    %s\n' % platform.platform()))
    dependencies = ['boto', 'paramiko', 'Crypto']
    for dep in dependencies:
        self.__write_module_version(dep, crashfile)
    crashfile.write(('\n' + (header % 'CRASH    DETAILS')))
    crashfile.write(('Command:    %s\n\n' % argv))
    for line in logger.get_session_log():
        crashfile.write(line)
    crashfile.close()
    print
    log.error("Oops!    Looks    like    you've    found    a    bug    in    StarCluster")
    log.error(('Crash    report    written    to:    %s' % static.CRASH_FILE))
    log.error('Please    remove    any    sensitive    data    from    the    crash    report')
    log.error('and    submit    it    to    starcluster@mit.edu')
    sys.exit(1)
