Minor code cleanup on development helper scripts

This commit is contained in:
htgoebel 2011-06-12 12:01:03 +00:00
parent 0f95357e8b
commit c0ee498c5c
4 changed files with 96 additions and 88 deletions

View File

@ -1,10 +1,10 @@
#!/bin/sh
#
# set some environmental variables for pylint and run it
# Set some environmental variables for pylint and run it.
#
# you may specify single files or modules as parameters
# You may specify single files or modules as parameters.
#
# no parameters: check all python files
# If no parameters are given, all python files are checked.
#
set -eu
@ -18,12 +18,15 @@ BASIC_PYTHONPATH=$PROJ_DIR/src
# check for the pylint program
[ ! -x /usr/bin/pylint ] && echo >&2 "please run \"apt-get install pylint\" first" && exit 1
if [ ! -x /usr/bin/pylint ] ; then
echo >&2 "/usr/bin/pylint not found"
echo >&2 "please run \"apt-get install pylint\" first"
exit 1
fi
is_filename() {
echo "$1" | grep -q "\.py$" && test -e "$1" && return 0
return 1
[ "${1%.py}" != "$1" -a -e "$1" ]
}
@ -35,7 +38,7 @@ get_pythonpath() {
get_module() {
if is_filename "$1"; then
echo -n "$(basename "${1%.py}")"
echo -n "$(basename "$1" .py)"
else
echo -n "$1"
fi
@ -49,16 +52,15 @@ run_pylint() {
}
# check the complete (basic) package and the plugins, if no arguments were given
if test $# -eq 0; then
# If no arguments were given, check the complete (basic) package and
# the plugin.
if [ $# -eq 0 ] ; then
run_pylint cryptobox
find "$PROJ_DIR/plugins" -type f -name \*.py | while read fname; do
run_pylint "$fname"
done
find "$PROJ_DIR/plugins" -type f -name \*.py -print0 | xargs -0 run_pylint
else
while test $# -gt 0; do
run_pylint "$1"
shift
for name in "$@" ; do
run_pylint "$name"
done
fi

View File

@ -1,7 +1,7 @@
#!/bin/sh
#do_unittests.sh
#
# run this script _before_ you do a commit and fix errors before uploading
# Run this script _before_ you do a commit and fix errors before uploading.
#
# preparations:
# - add the following lines to /etc/super.tab:
@ -32,19 +32,18 @@ run_tests()
disable_filecheck
if test -n "$files"
then # do the specified tests
##The use of "eval", plus not using double quotes for
##$a below are
##required because getopt already puts argument names in
##single-quotes, and the script will not work with both sets
##of quotes.
for a in $files
do eval testoob -v $a
if [ -n "$files" ] ; then # run only the specified tests
## The use of "eval", plus not using double quotes for $a
## below are required because getopt already puts argument
## names in single-quotes, and the script will not work with
## both sets of quotes.
for a in $files ; do
eval testoob -v $a
done
else # do all tests
for a in ${BASE_DIR}/src/cryptobox/tests/test.*.py
do testoob -v "$a"
else
# run all tests
for a in ${BASE_DIR}/src/cryptobox/tests/test.*.py ; do
testoob -v "$a"
done
fi
@ -76,8 +75,7 @@ clobber_dev_arg=""
## Use the getopt command line utility to simplify parsing
getopt_str=`${GETOPT} -o c: --long clobber: \
-n do_unittests.sh -- "$@"`
getopt_str=$(${GETOPT} -o c: --long clobber: -n do_unittests.sh -- "$@")
#echo $getopt_str
## Assign the tokens to an array
getopt_arr=($getopt_str)

View File

@ -2,21 +2,27 @@
#
# example start script to run a local cryptobox webserver
#
# we set some parameters to make it possible to run it without an
# existing cryptobox installation
# We set some parameters to make it possible to run it without an
# existing cryptobox installation.
#
# change your local settings in "cryptobox-local.conf" - if this file
# does not exist, then "cryptobox.conf" is used
# Change your local settings in "cryptobox-local.conf" - if this file
# does not exist, then "cryptobox.conf" is used.
#
# the environment variable PORT may override the default (8080)
# Use the environment variable PORT to override the default port
# (8080).
#
# BEWARE: the super.tab entry must be named "CryptoBoxRootActionsLocal" instead of
# "CryptoBoxRootActions" (useful for development)
# BEWARE: the super.tab entry must be named "CryptoBoxRootActionsLocal"
# instead of "CryptoBoxRootActions" (useful for development)
#
BIN_DIR=$(dirname "$0")
BIN_DIR=$(cd "$BIN_DIR"; pwd)
PREFERRED_CONF_FILE=$BIN_DIR/cryptobox-local.conf
FALLBACK_CONF_FILE=$BIN_DIR/cryptobox-unittests.conf
## disable ssl detection
#export HTTPS=1
disable_filecheck()
{
sed -i "s/^OVERRIDE_FILECHECK = .*$/OVERRIDE_FILECHECK = True/" "$BIN_DIR/CryptoBoxRootActions"
@ -29,15 +35,12 @@ enable_filecheck()
## add the local python directory to the search path
export PYTHONPATH="$BIN_DIR/../src"
## disable ssl detection
#export HTTPS=1
PREFERRED_CONF_FILE=$BIN_DIR/cryptobox-local.conf
FALLBACK_CONF_FILE=$BIN_DIR/cryptobox-unittests.conf
## determine the configuration file
CONFIG_FILE=$FALLBACK_CONF_FILE
test -r "$PREFERRED_CONF_FILE" && CONFIG_FILE=$PREFERRED_CONF_FILE
if [ -r "$PREFERRED_CONF_FILE" ] ; then
CONFIG_FILE=$PREFERRED_CONF_FILE
fi
echo "used config: $CONFIG_FILE"
## create necessary directories
@ -46,12 +49,15 @@ mkdir -p "$BIN_DIR/../ttt/settings"
cd "$BIN_DIR"
# disable strict security checks of CryptoBoxRootActions
disable_filecheck
## run the webserver
"$BIN_DIR/CryptoBoxWebserver" --config="$CONFIG_FILE" --pidfile=/tmp/cryptoboxwebserver.pid --logfile=/tmp/cryptoboxwebserver.log --port=${PORT:-8080} --datadir="$BIN_DIR/../www-data" "$@"
"$BIN_DIR/CryptoBoxWebserver" --config="$CONFIG_FILE" \
--port=${PORT:-8080} \
--pidfile=/tmp/cryptoboxwebserver.pid \
--logfile=/tmp/cryptoboxwebserver.log \
--datadir="$BIN_DIR/../www-data" "$@"
# enable strict security checks of CryptoBoxRootActions again
enable_filecheck

View File

@ -12,8 +12,8 @@ TEST_IMG=$PROJ_DIR/bin/test.img
TEST_SIZE=128
MEM_SIZE=128M
if test ! -e "$ROOT_IMG"
then echo "Could not find the cryptobox system image ($ROOT_IMG)"
if [ ! -e "$ROOT_IMG" ] ; then
echo "Could not find the cryptobox system image ($ROOT_IMG)"
echo " see stuff/uml-howto.txt for information on how to build a system image"
echo " store (or link) the result as '$ROOT_IMG'"
exit 1
@ -25,11 +25,13 @@ if test ! -e "$ROOT_IMG"
# add your user to the group 'uml-net'
#
/sbin/ifconfig tap0 &>/dev/null || { echo "tap0 is not configured - read /usr/share/doc/uml-utilities/README.Debian for hints"; exit 1; }
if ! /sbin/ifconfig tap0 &>/dev/null ; then
echo "tap0 is not configured - read /usr/share/doc/uml-utilities/README.Debian for hints"
exit 1
fi
if [ ! -e "$TEST_IMG" ]
then echo "Creating testing image file ..."
if [ ! -e "$TEST_IMG" ] ; then
echo "Creating testing image file ..."
dd if=/dev/zero of="$TEST_IMG" bs=1M count=$TEST_SIZE
fi