Skip to content

Commit

Permalink
Add demonstration programs for testing (#3)
Browse files Browse the repository at this point in the history
README.md:  Updated for this commit.

developers_notes.txt: New file used for tracking developer information
  This is intended to be later put into either Wiki or Readme files.

drats_*/hello_world_*.py:  Sample demonstration programs

fedora/requirements.txt:
mobaxterm/requirements.txt:
windows/requirements.txt:   PyPi modules needed for running D-Rats.

install_*.sh: Installation scripts for Linux like platforms with Bash.

pylintrc: Remove suppressions that that should not be needed for drats2.
  • Loading branch information
wb8tyw authored Jan 20, 2025
1 parent a69c2e6 commit 4d0af38
Show file tree
Hide file tree
Showing 16 changed files with 867 additions and 7 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ to date.
Developers and even testers are strongly encouraged to add detail about
what they need for their environment.

See the developer_notes.txt file for more information.

## Security warning

Do not use the root or an Administrator account for developing or running
Expand Down Expand Up @@ -317,9 +319,9 @@ manage it.

* Code Spell Checker from Street Side Software
* markdownlint from David Anson
* Python from Microsoft
* Python from Microsoft (Brings in some more extensions)
* ShellCheck from Timon Wong

* YAML from Red Hat

[1]: https://github.com/ham-radio-software/lzhuf
[2]: https://github.com/ham-radio-software/D-Rats/wiki/010.020-Installation-of-D%E2%80%90Rats-on-Microsoft-Windows-with-MobaXterm
Expand Down
470 changes: 470 additions & 0 deletions developers_notes.txt

Large diffs are not rendered by default.

39 changes: 39 additions & 0 deletions drats_gtk/hello_world_gtk.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/python

import logging
import os
from sys import exit

logger = logging.getLogger(__name__)

default_gtk = '4.0'
if 'MSYSTEM' in os.environ:
default_gtk = '3.0'
try:
import gi # type: ignore
try:
gi.require_version('Gtk', default_gtk)
except ValueError:
logger.info(f'GTK {default_gtk} is not available!')
try:
gi.require_version('Gtk', '3.0')
except ValueError:
logger.error('GTK 3 does not appear to be installed!')
exit(1)
from gi.repository import Gtk # type: ignore
except ModuleNotFoundError:
logger.error('GTK does not appear to be installed!')
exit(1)

def on_activate(app):
win = Gtk.ApplicationWindow(application=app)
win.present()

def main():
app = Gtk.Application()
app.connect('activate', on_activate)

app.run(None)

if __name__ == "__main__":
main()
30 changes: 30 additions & 0 deletions drats_kivy/hello_world_kivy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/python

import logging
# import os
from sys import exit

logger = logging.getLogger(__name__)

try:
from kivy.app import App
from kivy.uix.widget import Widget
except ModuleNotFoundError:
logger.error('Kivy does not appear to be installed!')
exit(1)


class HelloWorld(Widget):
pass


class HelloApp(App):
def build(self):
return HelloWorld()


def main():
HelloApp().run()

if __name__ == "__main__":
main()
10 changes: 10 additions & 0 deletions drats_tk/hello_world_tk.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/python

import tkinter as tk

def main():
window = tk.Tk()
window.mainloop()

if __name__ == "__main__":
main()
12 changes: 12 additions & 0 deletions drats_wx/hello_world_wx.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/python

import wx

def main():
app = wx.App()
frame = wx.Frame(parent=None, title='Hello World')
frame.Show()
app.MainLoop()

if __name__ == "__main__":
main()
2 changes: 2 additions & 0 deletions fedora/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pip
kivy
50 changes: 50 additions & 0 deletions install_debian.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/bash

set -uex

DEBIAN_FRONTEND=noninteractive
export DEBIAN_FRONTEND

sudo -S -E apt-get --assume-yes update
sudo -S -E apt-get --assume-yes install \
aspell aspell-de aspell-en aspell-es aspell-it aspell-nl \
ca-certificates \
gedit \
libcairo2-dev \
libxml2-utils \
libgirepository1.0-dev \
python3 \
python3-feedparser \
python3-flask \
python3-geopy \
python3-gevent \
python3-gi \
python3-gi-cairo \
python3-greenlet \
python3-kivy \
python3-lxml \
python3-pil \
python3-pyaudio \
python3-pycountry \
python3-pydub \
python3-serial \
python3-tk \
wxpython-tools

if [[ "${1:-}" == dev* ]]; then
sudo -S -E apt-get --assume-yes install \
bandit \
codespell \
gcc \
make \
pkg-config \
pylint \
python3-dev \
python3-ipykernel \
python3-pip \
python3-simplejson \
python3-sphinx \
python3_venv \
shellcheck \
yamllint
fi
65 changes: 65 additions & 0 deletions install_fedora.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!/bin/bash

set -uex

my_dir="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)"

sudo dnf -y install \
aspell aspell-de aspell-en aspell-es aspell-it aspell-nl \
ca-certificates \
gedit \
libxml2 \
python3 \
python3-cairo \
python3-feedparser \
python3-flask \
python3-geopy \
python3-gevent \
python3-gobject \
python3-greenlet \
python3-libxml2 \
python3-pillow \
python3-pyaudio \
python3-pycountry \
python3-pyserial \
python3-wxpython4

pypi_dir=~/drats_support/local/lib/pypi
mkdir -p "$pypi_dir"

if [ -e "$pypi_dir/bin/pip3" ]; then
echo 'Pip already updated'
else
# Pip always complains if a newer version is available until
# you upgrade to it.
echo "upgrading pip, this will warn that pip needs upgrading"
pip3 install --upgrade --target="$pypi_dir" pip
ls "$pypi_dir/bin"
fi
# Need to set PYTHONPATH to use the PyPi packages
PYTHONPATH="$pypi_dir"
export PYTHONPATH
ls "$pypi_dir/bin"
# If we do not include pip here, for some reason pip removes the
# binary for it. Why???
"$pypi_dir/bin"/pip3 install --upgrade --target="$pypi_dir" \
-r "${my_dir}/fedora/requirements.txt"

if [[ "${1:-}" == dev* ]]; then
sudo dnf -y install \
bandit \
codespell \
gcc \
make \
pkgconf-pkg-config \
pylint \
python3-devel \
python3-ipykernel \
python3-pip \
python3-simplejson \
python3-sphinx \
python3-tkinter \
python3-virtualenv \
shellcheck \
yamllint
fi
52 changes: 52 additions & 0 deletions install_linux.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/bin/bash

set -uex

my_dir="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)"

: "${NAME:=unknown}"
: "${ID:=unknown}"
: "${ID_LIKE:=unknown}"
if [ -e /etc/os-release ]; then
# shellcheck disable=SC1091
source /etc/os-release
else
# Cygwin / MobaXterm does not have /etc/os-release file
if [ -e /cygdrive ]; then
# Found for Cygwin / MobaXterm
if [ -e /bin/MobaBox.exe ]; then
# Found MobaXterm
ID="mobaxterm"
ID_LIKE="cygwin"
else
ID="cygwin"
fi
fi
fi
# Debian ID="debian" no ID_LIKE present has wxpython-tools, python3-kivy
# Ubuntu ID="ubuntu" ID_LIKE=debian has wxpython-tools, python3-kivy
#
# Fedora ID="fedora" no ID_LIKE python3-wxpython4 no kivy package
# epel for el-8 and el-9 also have the python3-wxpython4
# No current cygwin users, no scripted package install known.
# msys2 ID="msys2" has mingw-w64-x86_64-wxPython
# mobaxterm has python3.9 and python39-wx package, no gtk4, no kivy
case "$ID" in
mobaxterm)
"${my_dir}/install_mobaxterm.sh"
;;
msys2)
"${my_dir}/install_msys2.sh"
;;
fedora)
# Rocky/Alma is probably similar to this
"${my_dir}/install_fedora.sh"
;;
debian|ubuntu)
"${my_dir}/install_debian.sh"
;;
*)
echo "$ID is not yet supported by this script."
exit 1
;;
esac
60 changes: 60 additions & 0 deletions install_mobaxterm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/bin/bash

set -uex

my_dir="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)"

# MobaXterm has some of these packages built in.
# curl git wget

# MobaXterm uses aliases which are needed in a setup script
apt_get='/bin/MobaBox.exe apt-get'
mkdir='/usr/bin/busybox mkdir'

# This is needed to prevent pop ups that pause the install
DEBIAN_FRONTEND=noninteractive
export DEBIAN_FRONTEND
# Update to current and add packages
# apt-get --assume-yes update
$apt_get -y upgrade
$apt_get -y install \
aspell aspell-de aspell-en aspell-es aspell-it \
ffmpeg \
gedit gettext gettext-devel git gcc-core \
libgtk3_0 libjpeg-devel libportaudio-devel \
python3 python3-pip python3-tkinter \
zlib-devel

python_version_raw="$(python --version)"
python_version="${python_version_raw#* }"
python_major_minimum="${python_version%.*}"
python_major="${python_major_minimum%.*}"
python_minor="${python_major_minimum#*.}"
pyver="python${python_major}${python_minor}"

$apt_get -y install \
"${pyver}-devel" "${pyver}-gi" "${pyver}-lxml" \
"${pyver}-sphinx" "${pyver}-wx" \

pypi_dir=/usr/local/lib/pypi
$mkdir -p "$pypi_dir"

if [ -e "$pypi_dir/bin/pip3" ]; then
echo 'Pip already updated'
else
# Pip always complains if a newer version is available until
# you upgrade to it.
echo "upgrading pip, this will warn that pip needs upgrading"
pip3 install --upgrade --target="$pypi_dir" pip
ls "$pypi_dir/bin"
fi
# Need to set PYTHONPATH to use the PyPi packages
PYTHONPATH="$pypi_dir"
export PYTHONPATH
ls "$pypi_dir/bin"
# If we do not include pip here, for some reason pip removes the
# binary for it. Why???
"$pypi_dir/bin"/pip3 install --upgrade --target="$pypi_dir" \
-r "${my_dir}/mobaxterm/requirements.txt"
#
# kivy does not apparently install on cygwin/MobaXterm
34 changes: 34 additions & 0 deletions install_msys2.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/bash

set -uex

mingw='mingw-w64-x86_64'

pacman -Syu --noconfirm \
"${mingw}-ca-certificates" \
"${mingw}-python" \
"${mingw}-gtk4" \
"${mingw}-gettext" \
"${mingw}-python3-gobject" \
"${mingw}-aspell" "${mingw}-aspell-en" \
"${mingw}-python-pywin32" \
"${mingw}-python-lxml" \
"${mingw}-python-pyserial" \
"${mingw}-python-pillow" \
"${mingw}-python-pycountry" \
"${mingw}-wxPython"

if [[ "${1:-}" == dev* ]]; then
# packaging
# no aspell-it dictionary at this time.
pacman -Syu --noconfirm \
"${mingw}-gcc" \
"${mingw}-make" \
"${mingw}-python-codespell" \
"${mingw}-python-pylint" \
"${mingw}-python-setuptools" \
"${mingw}-python-virtualenv"

# This should not be needed, but is for now.
ln -sf /mingw64/bin/mingw32-make.exe /mingw64/bin/make.exe
fi
Loading

0 comments on commit 4d0af38

Please sign in to comment.