From a9b4554156bac38cd3ca1162326ce9cf554f9b50 Mon Sep 17 00:00:00 2001 From: "Kali Kaneko (leap communications)" Date: Tue, 30 Aug 2016 11:25:27 -0400 Subject: [pkg] add some relevant docs --- pkg/tools/check_code.sh | 33 +++++++++++++++++++++++++++++++++ pkg/tools/filter-bitmask-deps | 35 +++++++++++++++++++++++++++++++++++ pkg/tools/get_authors.sh | 2 ++ pkg/tools/monitor_resource.zsh | 26 ++++++++++++++++++++++++++ 4 files changed, 96 insertions(+) create mode 100755 pkg/tools/check_code.sh create mode 100755 pkg/tools/filter-bitmask-deps create mode 100755 pkg/tools/get_authors.sh create mode 100755 pkg/tools/monitor_resource.zsh (limited to 'pkg/tools') diff --git a/pkg/tools/check_code.sh b/pkg/tools/check_code.sh new file mode 100755 index 0000000..7bbd91f --- /dev/null +++ b/pkg/tools/check_code.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +# Escape code +esc=`echo -en "\033"` + +# Set colors +cc_green="${esc}[0;32m" +cc_red="${esc}[0;31m" +cc_normal=`echo -en "${esc}[m\017"` + + +[[ -z "$1" ]] && WHERE='src/leap/bitmask' || WHERE=$1 + +PEP8="pep8 --ignore=E202,W602 --exclude=*_rc.py,ui_*,_version.py $WHERE" +echo "${cc_green}$PEP8${cc_normal}" +$PEP8 + +echo +FLAKE8="flake8 --ignore=E202,W602 --exclude=*_rc.py,ui_*,_version.py $WHERE" +echo "${cc_green}$FLAKE8${cc_normal}" +$FLAKE8 + +echo +echo "${cc_green}Looking for 'print's, no prints in code, use logging/twisted.log.${cc_normal}" +echo `git grep -n "print " | wc -l` 'coincidences.' + +echo +echo "${cc_green}Grepping for 'pdb' code left behind.${cc_normal}" +git grep -n "pdb" + +echo +echo "${cc_green}Grepping for 'XXX|TODO|FIXME|NOTE|HACK'.${cc_normal}" +echo `git grep -E "XXX|TODO|FIXME|NOTE|HACK" | wc -l` 'coincidences.' diff --git a/pkg/tools/filter-bitmask-deps b/pkg/tools/filter-bitmask-deps new file mode 100755 index 0000000..9808d39 --- /dev/null +++ b/pkg/tools/filter-bitmask-deps @@ -0,0 +1,35 @@ +#!/usr/bin/env python + +""" +Filter bitmask dependencies. + +Usage: pipdeptree | filter-bitmask-deps +""" +import fileinput + +TARGET = "leap.bitmask" + + +def get_bitmask_deps(dep_lines): + res = [] + begin = False + for dep in dep_lines: + if dep.startswith(TARGET): + begin = True + res.append(dep) + continue + elif dep.startswith(' ') and begin: + res.append(dep) + continue + if begin: + return res + + +if __name__ == "__main__": + lines = [] + for line in fileinput.input(): + lines.append(line) + + bitmask_deps = get_bitmask_deps(lines) + for line in bitmask_deps: + print line[:-1] diff --git a/pkg/tools/get_authors.sh b/pkg/tools/get_authors.sh new file mode 100755 index 0000000..0169bb1 --- /dev/null +++ b/pkg/tools/get_authors.sh @@ -0,0 +1,2 @@ +#!/bin/sh +git log --format='%aN <%aE>' | awk '{arr[$0]++} END{for (i in arr){print arr[i], i;}}' | sort -rn | cut -d' ' -f2- diff --git a/pkg/tools/monitor_resource.zsh b/pkg/tools/monitor_resource.zsh new file mode 100755 index 0000000..ac468e3 --- /dev/null +++ b/pkg/tools/monitor_resource.zsh @@ -0,0 +1,26 @@ +#!/bin/zsh +if (( ! $# )); then + echo "Usage: $0:t " >&2 + return 1; +fi + +OUT="$1-usage.data" +GRAPH="bitmask-resources.png" +MAX=150 +let "ticks=$2*60/3" +echo "cpu mem" >> $OUT +for i in {1..$ticks}; do; + cpu=$(ps -p $1 -o pcpu | grep -v %) + mem=$(ps wuh -p $1 | awk '{print $4}') + echo "$cpu $mem" >> $OUT; + sleep 3; + echo $i / $ticks; +done; + +gnuplot -e "set term dumb; \ +set key outside; set yrange [0:$MAX]; \ +plot for [col=1:2] '$OUT' using 0:col title columnheader s c" + +gnuplot -e "set term png; set output '$GRAPH'; \ +set key outside; set yrange [0:$MAX]; \ +plot for [col=1:2] '$OUT' using 0:col with lines title columnheader" -- cgit v1.2.3