Commit 777e8025 authored by Alexey Ivanov's avatar Alexey Ivanov Committed by yonghong-song

Unify python executables to use `#!/usr/bin/env python` shebang (#2102)

* fixed shebangs in tools (and lib)

* fixed shebangs in examples

* do not mangle shebangs in rpm spec

* renamed style-check.sh to c-style-check.sh

* factored out python linter to a separate file

* added shebang validation to the py-style-check

* added shebangs to all python executables
parent f446bd76
......@@ -3,5 +3,6 @@ install:
- sudo apt-get install -y python-pip
- sudo pip install pep8
script:
- set -euo pipefail
- ./scripts/check-helpers.sh
- find tools/ -type f -name "*.py" | xargs pep8 -r --show-source --ignore=E123,E125,E126,E127,E128,E302
- ./scripts/py-style-check.sh
......@@ -88,10 +88,6 @@ popd
%install
pushd build
make install/strip DESTDIR=%{buildroot}
# mangle shebangs
find %{buildroot}/usr/share/bcc/{tools,examples} -type f -exec \
sed -i -e '1 s|^#!/usr/bin/python$|#!'%{__python}'|' \
-e '1 s|^#!/usr/bin/env python$|#!'%{__python}'|' {} \;
%package -n libbcc
Summary: Shared Library for BPF Compiler Collection (BCC)
......
#!/usr/bin/python
#!/usr/bin/env python
from __future__ import print_function
from bcc import BPF
......
#!/usr/bin/python
#!/usr/bin/env python
#
#Bertrone Matteo - Polytechnic of Turin
#November 2015
......
#!/usr/bin/python
#!/usr/bin/env python
#
#Bertrone Matteo - Polytechnic of Turin
#November 2015
......
#!/usr/bin/python
#!/usr/bin/env python
# Copyright (c) PLUMgrid, Inc.
# Licensed under the Apache License, Version 2.0 (the "License")
......
#!/usr/bin/python
#!/usr/bin/env python
from __future__ import print_function
from bcc import BPF
......
#!/usr/bin/python
#!/usr/bin/env python
#
# bitehist.py Block I/O size histogram.
# For Linux, uses BCC, eBPF. Embedded C.
......
#!/usr/bin/python
#!/usr/bin/env python
#
# disksnoop.py Trace block device I/O: basic version of iosnoop.
# For Linux, uses BCC, eBPF. Embedded C.
......
#!/usr/bin/python
#!/usr/bin/env python
#
# mallocstacks Trace malloc() calls in a process and print the full
# stack trace for all callsites.
......
#!/usr/bin/python
#!/usr/bin/env python
#
# mysqld_query Trace MySQL server queries. Example of USDT tracing.
# For Linux, uses BCC, BPF. Embedded C.
......
#!/usr/bin/python
#!/usr/bin/env python
#
# nodejs_http_server Basic example of node.js USDT tracing.
# For Linux, uses BCC, BPF. Embedded C.
......
#!/usr/bin/python
#!/usr/bin/env python
#
# stacksnoop Trace a kernel function and print all kernel stack traces.
# For Linux, uses BCC, eBPF, and currently x86_64 only. Inline C.
......
#!/usr/bin/python
#!/usr/bin/env python
#
# strlen_count Trace strlen() and print a frequency count of strings.
# For Linux, uses BCC, eBPF. Embedded C.
......
#!/usr/bin/python
#!/usr/bin/env python
#
# strlen_hist.py Histogram of system-wide strlen return values
......
#!/usr/bin/python
#!/usr/bin/env python
#
# strlen_snoop Trace strlen() library function for a given PID.
# For Linux, uses BCC, eBPF. Embedded C.
......
#!/usr/bin/python
#!/usr/bin/env python
#
# sync_timing.py Trace time between syncs.
# For Linux, uses BCC, eBPF. Embedded C.
......
#!/usr/bin/python
#!/usr/bin/env python
# Copyright (c) PLUMgrid, Inc.
# Licensed under the Apache License, Version 2.0 (the "License")
......
#!/usr/bin/python
#!/usr/bin/env python
#
# tcpv4connect Trace TCP IPv4 connect()s.
# For Linux, uses BCC, eBPF. Embedded C.
......
#!/usr/bin/python
#!/usr/bin/env python
#
# urandomread-explicit Example of instrumenting a kernel tracepoint.
# For Linux, uses BCC, BPF. Embedded C.
......
#!/usr/bin/python
#!/usr/bin/env python
#
# urandomread Example of instrumenting a kernel tracepoint.
# For Linux, uses BCC, BPF. Embedded C.
......
#!/usr/bin/python
#!/usr/bin/env python
#
# vfsreadlat.py VFS read latency distribution.
# For Linux, uses BCC, eBPF. See .c file.
......
#!/usr/bin/env python
import argparse
from time import sleep, strftime
from sys import argv
......
#!/usr/bin/env python
import argparse
from time import sleep, strftime
from sys import argv
......
#!/usr/bin/env python
import argparse
from time import sleep
from sys import argv
......
#!/bin/bash
set -euo pipefail
# TODO: stop ignoring this. Maybe autopep8 existing stuff?
find tools -type f -name "*.py" | xargs pep8 -r --show-source --ignore=E123,E125,E126,E127,E128,E302 || \
echo "pep8 run failed, please fix it" >&2
NO_PROPER_SHEBANG="$(find tools examples -type f -executable -name '*.py' | xargs grep -L '#!/usr/bin/env python')"
if [ -n "$NO_PROPER_SHEBANG" ]; then
echo "bad shebangs found:"
echo "$NO_PROPER_SHEBANG"
echo
echo "either add proper shebang or remove executable bit" >&2
exit 1
fi
......@@ -4,7 +4,7 @@ configure_file(wrapper.sh.in "${CMAKE_CURRENT_BINARY_DIR}/wrapper.sh" @ONLY)
set(TEST_WRAPPER ${CMAKE_CURRENT_BINARY_DIR}/wrapper.sh)
add_test(NAME style-check COMMAND ${CMAKE_SOURCE_DIR}/scripts/style-check.sh)
add_test(NAME style-check COMMAND ${CMAKE_SOURCE_DIR}/scripts/c-style-check.sh)
set_tests_properties(style-check PROPERTIES PASS_REGULAR_EXPRESSION ".*")
if(ENABLE_CLANG_JIT)
......
#!/usr/bin/python
#!/usr/bin/env python
#
# bashreadline Print entered bash commands from all running shells.
# For Linux, uses BCC, eBPF. Embedded C.
......
#!/usr/bin/python
#!/usr/bin/env python
# @lint-avoid-python-3-compatibility-imports
#
# biolatency Summarize block device I/O latency as a histogram.
......
#!/usr/bin/python
#!/usr/bin/env python
# @lint-avoid-python-3-compatibility-imports
#
# biosnoop Trace block device I/O and print details including issuing PID.
......
#!/usr/bin/python
#!/usr/bin/env python
# @lint-avoid-python-3-compatibility-imports
#
# biotop block device (disk) I/O by process.
......
#!/usr/bin/python
#!/usr/bin/env python
#
# bitehist.py Block I/O size histogram.
# For Linux, uses BCC, eBPF. See .c file.
......
#!/usr/bin/python
#!/usr/bin/env python
#
# bpflist Display processes currently using BPF programs and maps,
# pinned BPF programs and maps, and enabled probes.
......
#!/usr/bin/python
#!/usr/bin/env python
# @lint-avoid-python-3-compatibility-imports
#
# btrfsdist Summarize btrfs operation latency.
......
#!/usr/bin/python
#!/usr/bin/env python
# @lint-avoid-python-3-compatibility-imports
#
# btrfsslower Trace slow btrfs operations.
......
#!/usr/bin/python
#!/usr/bin/env python
#
# cachestat Count cache kernel function calls.
# For Linux, uses BCC, eBPF. See .c file.
......
#!/usr/bin/python
#!/usr/bin/env python
# @lint-avoid-python-3-compatibility-imports
#
# capable Trace security capabilitiy checks (cap_capable()).
......
#!/usr/bin/python
#!/usr/bin/env python
# @lint-avoid-python-3-compatibility-imports
#
# cpudist Summarize on- and off-CPU time per task as a histogram.
......
#!/usr/bin/python
#!/usr/bin/env python
# @lint-avoid-python-3-compatibility-imports
#
# cpuunclaimed Sample CPU run queues and calculate unclaimed idle CPU.
......
#!/usr/bin/python
#!/usr/bin/env python
# @lint-avoid-python-3-compatibility-imports
#
# criticalstat Trace long critical sections (IRQs or preemption disabled)
......
#!/usr/bin/python
#!/usr/bin/env python
#
# dbslower Trace MySQL and PostgreSQL queries slower than a threshold.
#
......
#!/usr/bin/python
#!/usr/bin/env python
#
# dbstat Display a histogram of MySQL and PostgreSQL query latencies.
#
......
#!/usr/bin/python
#!/usr/bin/env python
# @lint-avoid-python-3-compatibility-imports
#
# dcsnoop Trace directory entry cache (dcache) lookups.
......
#!/usr/bin/python
#!/usr/bin/env python
# @lint-avoid-python-3-compatibility-imports
#
# dcstat Directory entry cache (dcache) stats.
......
#!/usr/bin/python
#!/usr/bin/env python
# @lint-avoid-python-3-compatibility-imports
#
# execsnoop Trace new processes via exec() syscalls.
......
#!/usr/bin/python
#!/usr/bin/env python
# @lint-avoid-python-3-compatibility-imports
#
# ext4dist Summarize ext4 operation latency.
......
#!/usr/bin/python
#!/usr/bin/env python
# @lint-avoid-python-3-compatibility-imports
#
# ext4slower Trace slow ext4 operations.
......
#!/usr/bin/python
#!/usr/bin/env python
# @lint-avoid-python-3-compatibility-imports
#
# filelife Trace the lifespan of short-lived files.
......
#!/usr/bin/python
#!/usr/bin/env python
# @lint-avoid-python-3-compatibility-imports
#
# fileslower Trace slow synchronous file reads and writes.
......
#!/usr/bin/python
#!/usr/bin/env python
# @lint-avoid-python-3-compatibility-imports
#
# filetop file reads and writes by process.
......
#!/usr/bin/python
#!/usr/bin/env python
# @lint-avoid-python-3-compatibility-imports
#
# funccount Count functions, tracepoints, and USDT probes.
......
#!/usr/bin/python
#!/usr/bin/env python
# @lint-avoid-python-3-compatibility-imports
#
# funclatency Time functions and print latency as a histogram.
......
#!/usr/bin/python
#!/usr/bin/env python
# @lint-avoid-python-3-compatibility-imports
#
# funcslower Trace slow kernel or user function calls.
......
#!/usr/bin/python
#!/usr/bin/env python
#
# gethostlatency Show latency for getaddrinfo/gethostbyname[2] calls.
# For Linux, uses BCC, eBPF. Embedded C.
......
#!/usr/bin/python
#!/usr/bin/env python
# @lint-avoid-python-3-compatibility-imports
#
# hardirqs Summarize hard IRQ (interrupt) event time.
......
#!/usr/bin/python
#!/usr/bin/env python
# @lint-avoid-python-3-compatibility-imports
#
# killsnoop Trace signals issued by the kill() syscall.
......
#!/usr/bin/python
#!/usr/bin/env python
# @lint-avoid-python-3-compatibility-imports
#
# ucalls Summarize method calls in high-level languages and/or system calls.
......
#!/usr/bin/python
#!/usr/bin/env python
# @lint-avoid-python-3-compatibility-imports
#
# uflow Trace method execution flow in high-level languages.
......
#!/usr/bin/python
#!/usr/bin/env python
# @lint-avoid-python-3-compatibility-imports
#
# ugc Summarize garbage collection events in high-level languages.
......
#!/usr/bin/python
#!/usr/bin/env python
# @lint-avoid-python-3-compatibility-imports
#
# uobjnew Summarize object allocations in high-level languages.
......
#!/usr/bin/python
#!/usr/bin/env python
# @lint-avoid-python-3-compatibility-imports
#
# ustat Activity stats from high-level languages, including exceptions,
......
#!/usr/bin/python
#!/usr/bin/env python
# @lint-avoid-python-3-compatibility-imports
#
# uthreads Trace thread creation/destruction events in high-level languages.
......
#!/usr/bin/python
#!/usr/bin/env python
#
# llcstat.py Summarize cache references and cache misses by PID.
# Cache reference and cache miss are corresponding events defined in
......
#!/usr/bin/python
#!/usr/bin/env python
# @lint-avoid-python-3-compatibility-imports
#
# mdflush Trace md flush events.
......
#!/usr/bin/python
#!/usr/bin/env python
#
# mysqld_qslower MySQL server queries slower than a threshold.
# For Linux, uses BCC, BPF. Embedded C.
......
#!/usr/bin/python
#!/usr/bin/env python
# @lint-avoid-python-3-compatibility-imports
#
# nfsdist Summarize NFS operation latency
......
#!/usr/bin/python
#!/usr/bin/env python
# @lint-avoid-python-3-compatibility-imports
#
# nfsslower Trace slow NFS operations
......
#!/usr/bin/python
#!/usr/bin/env python
#
# offcputime Summarize off-CPU time by stack trace
# For Linux, uses BCC, eBPF.
......
#!/usr/bin/python
#!/usr/bin/env python
#
# offwaketime Summarize blocked time by kernel off-CPU stack + waker stack
# For Linux, uses BCC, eBPF.
......
#!/usr/bin/python
#!/usr/bin/env python
#
# bashreadline Print entered bash commands from all running shells.
# For Linux, uses BCC, eBPF. Embedded C.
......
#!/usr/bin/python
#!/usr/bin/env python
# @lint-avoid-python-3-compatibility-imports
#
# biosnoop Trace block device I/O and print details including issuing PID.
......
#!/usr/bin/python
#!/usr/bin/env python
# @lint-avoid-python-3-compatibility-imports
#
# filelife Trace the lifespan of short-lived files.
......
#!/usr/bin/python
#!/usr/bin/env python
#
# gethostlatency Show latency for getaddrinfo/gethostbyname[2] calls.
# For Linux, uses BCC, eBPF. Embedded C.
......
#!/usr/bin/python
#!/usr/bin/env python
# @lint-avoid-python-3-compatibility-imports
#
# killsnoop Trace signals issued by the kill() syscall.
......
#!/usr/bin/python
#!/usr/bin/env python
#
# offcputime Summarize off-CPU time by kernel stack trace
# For Linux, uses BCC, eBPF.
......
#!/usr/bin/python
#!/usr/bin/env python
#
# offwaketime Summarize blocked time by kernel off-CPU stack + waker stack
# For Linux, uses BCC, eBPF.
......
#!/usr/bin/python
#!/usr/bin/env python
# @lint-avoid-python-3-compatibility-imports
#
# opensnoop Trace open() syscalls.
......
#!/usr/bin/python
#!/usr/bin/env python
# @lint-avoid-python-3-compatibility-imports
#
# profile Profile CPU usage by sampling stack traces at a timed interval.
......
#!/usr/bin/python
#!/usr/bin/env python
# @lint-avoid-python-3-compatibility-imports
#
# softirqs Summarize soft IRQ (interrupt) event time.
......
#!/usr/bin/python
#!/usr/bin/env python
#
# stackcount Count kernel function calls and their stack traces.
# For Linux, uses BCC, eBPF.
......
#!/usr/bin/python
#!/usr/bin/env python
#
# stacksnoop Trace a kernel function and print all kernel stack traces.
# For Linux, uses BCC, eBPF, and currently x86_64 only. Inline C.
......
#!/usr/bin/python
#!/usr/bin/env python
# @lint-avoid-python-3-compatibility-imports
#
# statsnoop Trace stat() syscalls.
......
#!/usr/bin/python
#!/usr/bin/env python
# @lint-avoid-python-3-compatibility-imports
#
# syncsnoop Trace sync() syscall.
......
#!/usr/bin/python
#!/usr/bin/env python
# @lint-avoid-python-3-compatibility-imports
#
# tcpaccept Trace TCP accept()s.
......
#!/usr/bin/python
#!/usr/bin/env python
# @lint-avoid-python-3-compatibility-imports
#
# tcpconnect Trace TCP connect()s.
......
#!/usr/bin/python
#!/usr/bin/env python
#
# wakeuptime Summarize sleep to wakeup time by waker kernel stack
# For Linux, uses BCC, eBPF.
......
#!/usr/bin/python
#!/usr/bin/env python
# @lint-avoid-python-3-compatibility-imports
#
# opensnoop Trace open() syscalls.
......
#!/usr/bin/python
#!/usr/bin/env python
# @lint-avoid-python-3-compatibility-imports
#
# pidpersec Count new processes (via fork).
......
#!/usr/bin/python
#!/usr/bin/env python
# @lint-avoid-python-3-compatibility-imports
#
# profile Profile CPU usage by sampling stack traces at a timed interval.
......
#!/usr/bin/python
#!/usr/bin/env python
# @lint-avoid-python-3-compatibility-imports
#
# runqlat Run queue (scheduler) latency as a histogram.
......
#!/usr/bin/python
#!/usr/bin/env python
# @lint-avoid-python-3-compatibility-imports
#
# runqlen Summarize scheduler run queue length as a histogram.
......
#!/usr/bin/python
#!/usr/bin/env python
# @lint-avoid-python-3-compatibility-imports
#
# runqslower Trace long process scheduling delays.
......
#!/usr/bin/python
#!/usr/bin/env python
# @lint-avoid-python-3-compatibility-imports
#
# shmsnoop Trace shm*() syscalls.
......
#!/usr/bin/python
#!/usr/bin/env python
# @lint-avoid-python-3-compatibility-imports
#
# slabratetop Summarize kmem_cache_alloc() calls.
......
#!/usr/bin/python
#!/usr/bin/env python
# @lint-avoid-python-3-compatibility-imports
#
# sofdsnoop traces file descriptors passed via socket
......
#!/usr/bin/python
#!/usr/bin/env python
# @lint-avoid-python-3-compatibility-imports
#
# softirqs Summarize soft IRQ (interrupt) event time.
......
#!/usr/bin/python
#!/usr/bin/env python
#
# sslsniff Captures data on read/recv or write/send functions of OpenSSL,
# GnuTLS and NSS
......
#!/usr/bin/python
#!/usr/bin/env python
# @lint-avoid-python-3-compatibility-imports
#
# statsnoop Trace stat() syscalls.
......
#!/usr/bin/python
#!/usr/bin/env python
# @lint-avoid-python-3-compatibility-imports
#
# syncsnoop Trace sync() syscall.
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment