Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
raise ValueError('You can only trace user-defined functions. '
'The birdseye decorator must be applied first, '
'at the bottom of the list.')
try:
if inspect.iscoroutinefunction(func) or inspect.isasyncgenfunction(func):
raise ValueError('You cannot trace async functions')
except AttributeError:
pass
if is_lambda(func):
raise ValueError('You cannot trace lambdas')
filename = inspect.getsourcefile(func) # type: str
if is_ipython_cell(filename):
# noinspection PyPackageRequirements
from IPython import get_ipython
import linecache
flags = get_ipython().compile.flags
source = ''.join(linecache.cache[filename][2])
else:
source = read_source_file(filename)
flags = 0
# We compile the entire file instead of just the function source
# because it can contain context which affects the function code,
# e.g. enclosing functions and classes or __future__ imports
traced_file = self.compile(source, filename, flags)
if func.__dict__:
raise ValueError('You can only trace user-defined functions. '
'The birdseye decorator must be applied first, '
'at the bottom of the list.')
try:
if inspect.iscoroutinefunction(func) or inspect.isasyncgenfunction(func):
raise ValueError('You cannot trace async functions')
except AttributeError:
pass
if is_lambda(func):
raise ValueError('You cannot trace lambdas')
filename = inspect.getsourcefile(func) # type: str
if is_ipython_cell(filename):
# noinspection PyPackageRequirements
from IPython import get_ipython
import linecache
flags = get_ipython().compile.flags
source = ''.join(linecache.cache[filename][2])
else:
source = read_source_file(filename)
flags = 0
# We compile the entire file instead of just the function source
# because it can contain context which affects the function code,
# e.g. enclosing functions and classes or __future__ imports
traced_file = self.compile(source, filename, flags)
if func.__dict__:
def index(session):
all_paths = db.all_file_paths()
recent_calls = (session.query(*(Call.basic_columns + Function.basic_columns))
.join(Function)
.order_by(Call.start_time.desc())[:100])
files = OrderedDict()
for row in recent_calls:
if is_ipython_cell(row.file):
continue
files.setdefault(
row.file, OrderedDict()
).setdefault(
row.name, row
)
for path in all_paths:
files.setdefault(
path, OrderedDict()
)
short = partial(short_path, all_paths=all_paths)
return render_template('index.html',
short=short,
def all_file_paths(self):
# type: () -> List[str]
with self.session_scope() as session:
paths = [f[0] for f in session.query(self.Function.file).distinct()
if not is_ipython_cell(f[0])]
paths.sort()
if IPYTHON_FILE_PATH in paths:
paths.remove(IPYTHON_FILE_PATH)
paths.insert(0, IPYTHON_FILE_PATH)
return paths