Skip to content

Commit

Permalink
Modified due to changes in the component locations (MVC paradigm)
Browse files Browse the repository at this point in the history
  • Loading branch information
avalon60 committed Mar 31, 2024
1 parent b4ed5ff commit cf38cba
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 15 deletions.
14 changes: 14 additions & 0 deletions build_app.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,20 @@
# Name: build_app.sh
# Descr: Setup Python environment and modules for Ctk Theme Builder
##############################################################################
PROG=$(basename $0)
PROG_DIR=$(dirname $0)
APP_HOME=$(realpath ${PROG_DIR})

APP_ENV=${APP_HOME}/venv
APP_UTILS=${APP_HOME}/utils
APP_MODEL=${APP_HOME}/model
APP_VIEW=${APP_HOME}/view
APP_CTL=${APP_HOME}/controller
E="-e"

echo $E "Application Home: ${APP_HOME}"
cd ${APP_HOME}

fix_eols ()
{
echo "Ensuring Linux style line terminators."
Expand Down
21 changes: 18 additions & 3 deletions theme_builder_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ def dir_access(directory_path: Path):
return ''


def purge_files(directory, file_match):
def purge_files(directory: Path, file_match: Path):
"""Pattern match and delete files in specified directory."""
file_list = glob.glob(pathname=f'{directory}/{file_match}')

Expand All @@ -437,6 +437,17 @@ def purge_files(directory, file_match):
lprint(f'Failed to delete file: {file_path} (OSError)')


def purge_file(directory: Path, file_name: Path):
"""purge_file purges an individual file, assuming that the file exists."""
if not os.path.exists(directory / file_name):
return
try:
lprint(f'Removing previous: {directory / file_name}')
os.remove(directory / file_name)
except OSError:
lprint(f'Failed to delete file: {directory / file_name} (OSError)')


def unpack_package(zip_pathname: Path, install_location: Path):
""""The unpack_package function, is provided for when we need to perform a software upgrade.
We unpack the wallet contents to the target application home directory, prior to initialisation of the Python
Expand Down Expand Up @@ -595,6 +606,10 @@ def unpack_package(zip_pathname: Path, install_location: Path):
purge_files(directory=app_home / 'controller', file_match='*.py')
purge_files(directory=app_home / 'utils', file_match='*.sh')
purge_files(directory=app_home / 'utils', file_match='*.py')
if operating_system != 'Windows':
# Remove the ctk_theme_builder.sh -> ctk_theme_builder hard-link.
# We reinstate it later.
purge_file(directory=app_home, file_name='ctk_theme_builder')
unpack_package(zip_pathname=package_path, install_location=install_location)

version_script = PRODUCT.lower() + '.py'
Expand All @@ -618,8 +633,8 @@ def unpack_package(zip_pathname: Path, install_location: Path):
lprint(line, inc_newline=False)
lprint('')
else:
lprint('Set execute permissions for build_app.sh')
os.system('chmod 750 *.sh')
lprint('Set execute permissions for scripts')
os.system('find . -name "*.sh" -exec chmod 750 "{}" ";"')
lprint('')
lprint('Launching build_app.sh')
os.system('./build_app.sh > build_app.log 2>&1')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@
::# Descr:CustomTkinter Theme Builder Test App Launcher (Windows)
::##############################################################################
@echo off
set PROG_PATH="%~dp0"
set APP_ENV=%PROG_PATH%\venv
:: Get the directory of the batch script
set PROG_PATH=%~dp0

:: Derive the parent directory of PROG_PATH
for %%I in ("%PROG_PATH%\..") do set "APP_HOME=%%~fI"

set APP_ENV=%APP_HOME%\venv
set PYTHONPATH=%PYTHONPATH%;%APP_HOME%\utils;%APP_HOME%\model;%APP_HOME%\view

call %APP_ENV%\Scripts\activate.bat
%PROG_PATH%\ctk_theme_builder_qa_app.py %1 %2 %3 %4 %5 %6
%APP_HOME%\utils\ctk_theme_builder_qa_app.py %1 %2 %3 %4 %5 %6
22 changes: 13 additions & 9 deletions utils/ctk_theme_builder_qa_app.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,25 @@
# Name: ctk_theme_builder_test_app.sh
# Descr: CustomTkinter Theme Builder Test App Launcher (Linux/Mac)
##############################################################################
PROG=`basename $0`
PROG_PATH=`dirname $0`
FULL_PATH=$0
APP_HOME=$(realpath ${FULL_PATH})
APP_HOME=$(dirname ${APP_HOME})
PROG=$(basename $0)
PROG_DIR=$(dirname $0)
APP_HOME=$(realpath ${PROG_DIR})
APP_HOME=$(dirname ${APP_HOME})
APP_ENV=${APP_HOME}/venv
APP_UTILS=${APP_HOME}/utils
APP_MODEL=${APP_HOME}/model
APP_VIEW=${APP_HOME}/view

export PYTHONPATH=${PYTHONPATH}:${APP_UTILS}:${APP_MODEL}:${APP_VIEW}

if [[ "${PROG}" == *\.sh ]]
then
DCCM_PY=`echo ${FULL_PATH} | sed "s/\.sh/.py/"`
QA_PY="${APP_UTILS}/$(echo ${PROG} | sed 's/.sh/.py/')"
else
DCCM_PY="${FULL_PATH}.py"
QA_PY="${FULL_PATH}.py"
fi

APP_ENV=${APP_HOME}/venv

if [ -f ${APP_ENV}/bin/activate ]
then
source ${APP_ENV}/bin/activate
Expand All @@ -41,5 +45,5 @@ else
exit 1
fi
fi
${PYTHON} ${DCCM_PY} $*

${PYTHON} ${QA_PY} $*

0 comments on commit cf38cba

Please sign in to comment.