This file is indexed.

/usr/bin/pycallgraph is in python-pycallgraph 0.5.1-3.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
#!/usr/bin/python
"""
pycallgraph
This script is the command line interface to the pycallgraph make_dot_graph
method.

U{http://pycallgraph.slowchop.com/}

Copyright Gerald Kaszuba 2007

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
"""
import sys
import os
from optparse import OptionParser

import pycallgraph


parser = OptionParser(usage='%prog [options] pythonfile')

parser.add_option(
    '-o', '--output-file', dest='output_file', default='pycallgraph.png',
    help='The generated GraphViz image. Default: pycallgraph.png',
    )

parser.add_option(
    '-f', '--image-format', dest='format', default='png',
    help='The image format of imagefile. Default: png',
    )

parser.add_option(
    '-q', '--quiet', dest='quiet', action='store_true',
    help='Suppress status output to the console.',
    )

parser.add_option(
    '-t', '--tool', dest='tool', default='dot',
    help='The tool from Graphviz to use. Default: dot',
    )

parser.add_option(
    '-s', '--stdlib', dest='include_stdlib', action='store_true',
    default=False,
    help='Include standard library functions in the trace. Default: False',
    )

parser.add_option(
    '-i', '--include', dest='include', default=[],
    action='append',
    help='Wildcard pattern of modules to include in the output. ' \
        'You can have multiple include arguments.',
    )

parser.add_option(
    '-e', '--exclude', dest='exclude', default=[],
    action='append',
    help='Wildcard pattern of modules to exclude in the output. ' \
        'You can have multiple exclude arguments.',
    )

parser.add_option(
    '-d', '--max-depth', dest='max_depth', default=None,
    help='Maximum stack depth to trace.',
    )

parser.add_option(
    '--include-timing', dest='include_timing', default=[],
    action='append',
    help='Wildcard pattern of modules to include in time measurement. ' \
        'You can have multiple include arguments.',
    )

parser.add_option(
    '--exclude-timing', dest='exclude_timing', default=[],
    action='append',
    help='Wildcard pattern of modules to exclude in time measurement. ' \
        'You can have multiple exclude arguments.',
    )

(options, args) = parser.parse_args()

if not options.quiet:
    print('Python Call Graph v%s' % pycallgraph.__version__)

if len(args) < 1:
    parser.print_help()
    sys.exit(0)

# Create filter
if not options.include:
    options.include = ['*']
filter_func = pycallgraph.GlobbingFilter(
    include=options.include,
    exclude=options.exclude,
    max_depth=options.max_depth,
    )

# Create timing filter
if not options.include_timing:
    options.include_timing = ['*']
time_filter_func = pycallgraph.GlobbingFilter(
    include=options.include_timing,
    exclude=options.exclude_timing,
    )

pycallgraph.settings['include_stdlib'] = options.include_stdlib

# Remove this script from the argument list so we don't break the Python
# script we are calling.
sys.argv = args

# Sometimes scripts change "options", so use a secret one.
# Also, this (kind of) allows pygc to call itself, since calling itself would
# overwrite global variables in this file.
try:
    __pygc_options.append(options)
except NameError:
    __pygc_options = [options]

# Insert the current working directory into the path
sys.path.insert(0, os.getcwd())

if not options.quiet:
    print('Starting trace')

reraise = False

pycallgraph.start_trace(
    filter_func=filter_func,
    time_filter_func=time_filter_func,
)

try:
    execfile(args[0])
except SystemExit, e:
    # Ignore it when the script calls os.exit() so we can still make the graph.
    pass
except Exception, e:
    reraise = True
    if not options.quiet:
        print('Caught exception, will raise after graph is made.')

options = __pygc_options.pop()

if not options.quiet:
    print('Creating %s' % options.output_file)

pycallgraph.make_dot_graph(options.output_file, options.format, options.tool)
    
if reraise:
    if not options.quiet:
        print('Done and raising the caught exception:')
    raise

if not options.quiet:
    print('Done!')

# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79: