From c91c0a184aec35ad51a9dbcfe0a39e9032d9087c Mon Sep 17 00:00:00 2001 From: Dirk Alders Date: Sun, 7 Mar 2021 21:44:45 +0100 Subject: [PATCH] Some updates --- amplifier | 32 ------------------ apt-extend-mint | 7 ++++ eachsubdir | 89 +++++++++++++++++++++++++++++++++++++++++++++++++ init_homepath | 2 +- mkunittest | 57 +++++++++++++++++++++++++++++-- 5 files changed, 152 insertions(+), 35 deletions(-) delete mode 100755 amplifier create mode 100755 eachsubdir diff --git a/amplifier b/amplifier deleted file mode 100755 index 14fa8e0..0000000 --- a/amplifier +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/env python2 -import subprocess -import time -from requests.exceptions import ConnectionError -from kodijson import Kodi # sudo pip install kodi-json - -def monitor_state(): - mon_state = subprocess.check_output(['/usr/bin/tvservice', '-s']) - return mon_state.split(' ')[1] in ['0xa', '0x12000a', '0x40002'] - - -def kodi_state(): - try: - kodi = Kodi("http://tv:8080/jsonrpc") - ap = kodi.Player.GetActivePlayers() - return len(ap['result']) > 0 - except ConnectionError: # This is a dirty trick, if kodi is not yet ready to answer requests - return False - - -prev_state = None -while True: - # second count - curr_state = kodi_state() - # check if there is a change in the screen state - if curr_state != prev_state: - if curr_state is True: - subprocess.check_output(['sispmctl', '-o', '1']) - else: - subprocess.check_output(['sispmctl', '-f', '1']) - prev_state = curr_state - time.sleep(1.) diff --git a/apt-extend-mint b/apt-extend-mint index 035f760..f8a8a5c 100755 --- a/apt-extend-mint +++ b/apt-extend-mint @@ -6,21 +6,25 @@ COMMON=" joe git tmux keepass2 xdotool +brasero sshfs curlftpfs openssh-server fonts-powerline powerline python3-powerline python3-powerline-gitstatus lib32stdc++6 " MULTIMEDIA=" +ffmpeg kodi kodi-pvr-hts spotify-client " TOOLS=" evolution +gnuplot gnome-boxes gvncviewer texlive-binaries texlive-latex-extra texlive-lang-german texlive-fonts-recommended texstudio +gimp " PROGRAMMING=" @@ -28,7 +32,10 @@ pycodestyle virtualenv python-coverage python3-coverage python-jinja2 python3-jinja2 python-wxtools python3-wxgtk4.0 +python3-evdev python3-serial +python3-sphinx python3-sphinx-rtd-theme meld +retext " ALL=$COMMON\ $MULTIMEDIA\ $TOOLS\ $PROGRAMMING diff --git a/eachsubdir b/eachsubdir new file mode 100755 index 0000000..89fbe15 --- /dev/null +++ b/eachsubdir @@ -0,0 +1,89 @@ +#!/bin/bash +# + +BASEDIR=`pwd` + +usage="Execute a command in each subdirectory:\n\nUsage: $0 [-p | print subdir info] \"command\"" + +# More safety, by turning some bugs into errors. +# Without `errexit` you don’t need ! and can replace +# PIPESTATUS with a simple $?, but I don’t do that. +set -o errexit -o pipefail -o noclobber -o nounset + +# -allow a command to fail with !’s side effect on errexit +# -use return value from ${PIPESTATUS[0]}, because ! hosed $? +! getopt --test > /dev/null +if [[ ${PIPESTATUS[0]} -ne 4 ]]; then + echo 'I’m sorry, `getopt --test` failed in this environment.' + exit 1 +fi + +OPTIONS=phe: +LONGOPTS=print-subdir,help,exclude: + +# -regarding ! and PIPESTATUS see above +# -temporarily store output to be able to check for errors +# -activate quoting/enhanced mode (e.g. by writing out “--options”) +# -pass arguments only via -- "$@" to separate them correctly +! PARSED=$(getopt --options=$OPTIONS --longoptions=$LONGOPTS --name "$0" -- "$@") +if [[ ${PIPESTATUS[0]} -ne 0 ]]; then + # e.g. return value is 1 + # then getopt has complained about wrong arguments to stdout + exit 2 +fi +# read getopt’s output this way to handle the quoting right: +eval set -- "$PARSED" + +p=n +exc="" +# now enjoy the options in order and nicely split until we see -- +while true; do + case "$1" in + -p|--print-subdir) + p=y + shift + ;; + -h|--help) + echo -e "Execute a command in each subdirectory:\n\nUsage: $0 [-p(--print-subdir) -e(--exclude) dir1, dir2,...,dirn)] \"command\"" + exit 0 + shift + ;; + -e|--exclude) + exc="$2" + shift 2 + ;; + --) + shift + break + ;; + *) + echo "Programming error" + exit 3 + ;; + esac +done + +# handle non-option arguments +if [[ $# -ne 1 ]]; then + echo "$0: A single command is required." + exit 4 +fi + + + +for subdir in `find $BASEDIR -maxdepth 1 -type d` +do + bn=`basename $subdir` + if [[ $subdir != $BASEDIR ]] && [[ ",$exc," != *",$bn,"* ]]; then + cd $subdir + if [[ $p = "y" ]]; then + echo -en "\n\n\033[1;33m╔" + for ((i=1;i<=$((${#bn} + 2));i++)); do echo -n "═"; done ; echo "╗" + echo "║ $bn ║" + echo -n "╚" + for ((i=1;i<=$((${#bn} + 2));i++)); do echo -n "═"; done ; echo "╝" + echo -e "\033[00m" + fi + eval $1 + fi +done diff --git a/init_homepath b/init_homepath index fd797f4..ac5ad81 100755 --- a/init_homepath +++ b/init_homepath @@ -1,7 +1,7 @@ #!/bin/sh # -REPLACE_FOLDERS="Audio Bilder data Dokumente Downloads eclipse Musik prj Schreibtisch Videos" +REPLACE_FOLDERS="Audio Bilder data Dokumente Downloads eclipse Musik prj Schreibtisch Videos choords" echo The following folders will be deleted: diff --git a/mkunittest b/mkunittest index 978d023..a0dd3bb 100755 --- a/mkunittest +++ b/mkunittest @@ -134,15 +134,68 @@ def testrun(tcl): # tcl.testCase('description', TCEL_FULL, test_.func, *args, **kwargs) """ % name + +main_makefile = """MODULE_NAME := $(shell basename `pwd`) + +view_unittest: + xdg-open pylibs/$(MODULE_NAME)/_testresults_/unittest.pdf + +view_requirements: + xdg-open pylibs/$(MODULE_NAME)/_requirements_/specification.pdf + +view_docs: + xdg-open pylibs/$(MODULE_NAME)/_docs_/index.html + +clean: + make -kC docs clean; make -kC requirements cleanall; make -kC unittest clean +""" + +docs_makefile = """# Minimal makefile for Sphinx documentation +# + +# You can set these variables from the command line. +SPHINXOPTS = +SPHINXBUILD = sphinx-build +SPHINXPRJ = state_machine +SOURCEDIR = . +BUILDDIR = _build + +# Put it first so that "make" without argument is like "make help". +help: + @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +.PHONY: help Makefile + +# Catch-all target: route all unknown targets to Sphinx using the new +# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). +%: $(SPHINXPRJ) + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +$(SPHINXPRJ): Makefile + make -C $@/_examples_ all + +release: html + rm -rf $(SPHINXPRJ)/_docs_ + mv $(BUILDDIR)/html $(SPHINXPRJ)/_docs_ + +view_html: html + xdg-open $(BUILDDIR)/html/index.html +""" + with open('.gitignore', 'w') as fh: fh.write(gitignore) +with open('Makefile', 'w') as fh: + fh.write(main_makefile) os.mkdir('docs') +with open('docs/Makefile', 'w') as fh: + fh.write(docs_makefile) os.symlink('../pylibs/%s' % name, 'docs/%s' % name) os.mkdir('pylibs') os.mkdir('requirements') +os.symlink('../pylibs/reqif/scripts/Makefile', 'requirements/Makefile') +os.symlink('../pylibs/reqif', 'requirements/reqif') os.mkdir('unittest') -os.symlink('../pylibs/unittest/scripts/unittest.sh', 'unittest/unittest.sh') -os.symlink('../pylibs/unittest/scripts/unittest.py', 'unittest/unittest.py') +os.symlink('../pylibs/unittest/scripts/Makefile', 'unittest/Makefile') os.mkdir('unittest/input_data') os.mkdir('unittest/output_data') os.mkdir('unittest/src')