Compare commits

..
Author SHA1 Message Date
Duo Developerandadmin b9d8c82f19 Remove unused temp dir variables that leaked on every invocation
utils_dir, temp_dir, build_dir, and staging_dir were computed at
module level but never referenced. tempfile.mkdtemp() ran
unconditionally on every invocation (including --help and
argument-parse errors), leaking an empty temp directory on disk
each time. Remove all four variables and the now-unused tempfile
import.
2026-08-28 09:51:24 +00:00
2 changed files with 37 additions and 4 deletions
+1
View File
@@ -5,5 +5,6 @@ LOCATION="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
CONFIG=${CONFIG:-${LOCATION}/config.json} CONFIG=${CONFIG:-${LOCATION}/config.json}
SRC=${SRC:-${LOCATION}/src} SRC=${SRC:-${LOCATION}/src}
BUILD_DIR=${BUILD_DIR:-${LOCATION}/build-packages} BUILD_DIR=${BUILD_DIR:-${LOCATION}/build-packages}
#INSTALL_SCRIPT=${LOCATION}/install.sh
${LOCATION}/hosted-app-utils/package ${CONFIG} ${SRC} output=${BUILD_DIR} $@ ${LOCATION}/hosted-app-utils/package ${CONFIG} ${SRC} output=${BUILD_DIR} $@
+36 -4
View File
@@ -1,6 +1,6 @@
#! /usr/bin/env python3 #! /usr/bin/env python3
import sys, os, argparse, json, shutil, tempfile, subprocess, traceback import sys, os, argparse, json, shutil, subprocess, traceback
def run_script(script_path: str) -> int: def run_script(script_path: str) -> int:
""" """
@@ -13,7 +13,7 @@ def run_script(script_path: str) -> int:
if not os.path.exists(script_path): if not os.path.exists(script_path):
print(f"Error: Script not found at {script_path}", file=sys.stderr) print(f"Error: Script not found at {script_path}", file=sys.stderr)
return 1 return 1
try: try:
subprocess.run(f'{script_path}', check=True, capture_output=True, text=True) subprocess.run(f'{script_path}', check=True, capture_output=True, text=True)
return 0 return 0
@@ -97,8 +97,40 @@ def handle_restart(src_path: str, install_path: str):
return 0 return 0
def uninstall_app(args: argparse.Namespace, install_path) -> int:
"""
Uninstall application at specified installation directory.
Args:
install_path (str): Path to target installation directory.
Returns:
Int
"""
rval = 0
try:
# disable application then uninstall
disable_path = os.path.join(install_path, 'disable')
stop_path = os.path.join(install_path, 'stop')
if os.path.exists(disable_path):
subprocess.check_output(disable_path)
if os.path.exists(stop_path):
subprocess.check_output(stop_path)
# reset vols, networks
subprocess.check_output(['docker', 'compose', '-f', f'{install_path}/docker-compose.yml', 'down', '-v'])
if os.path.exists(install_path):
shutil.rmtree(install_path)
except Exception as e:
print(f'Exception encountered: {e}')
traceback.print_exc()
rval = 1
return rval
# script constants # script constants
utils_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir))
working_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) working_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
src_path = os.path.join(working_dir, 'src') src_path = os.path.join(working_dir, 'src')
CONFIG_JSON = os.path.join(working_dir, 'config.json') CONFIG_JSON = os.path.join(working_dir, 'config.json')
@@ -168,4 +200,4 @@ def main() -> int:
return 1 return 1
if __name__ == '__main__': if __name__ == '__main__':
sys.exit(main()) sys.exit(main())