Fix reviews

This commit is contained in:
biast12 authored and DevilXD committed 2024-12-31 21:05:35 +01:00
1 parent 7473aaebc5
commit f8fa68b5b6
5 files changed
+202 -218

No files matched your search

Regular → Executable
+37 -37
View File
@@ -1,37 +1,37 @@
@echo off @echo off
REM Get the directory path of the script REM Get the directory path of the script
set "dirpath=%~dp0" set "dirpath=%~dp0"
if "%dirpath:~-1%" == "\" set "dirpath=%dirpath:~0,-1%" if "%dirpath:~-1%" == "\" set "dirpath=%dirpath:~0,-1%"
REM Check if the virtual environment exists REM Check if the virtual environment exists
if not exist "%dirpath%\env" ( if not exist "%dirpath%\env" (
echo: echo:
echo No virtual environment found! Run setup_env.bat to set it up first. echo No virtual environment found! Run setup_env.bat to set it up first.
echo: echo:
pause pause
exit /b exit /b 1
) )
REM Check if pyinstaller and pywin32 is installed in the virtual environment REM Check if pyinstaller and pywin32 is installed in the virtual environment
if not exist "%dirpath%\env\scripts\pyinstaller.exe" ( if not exist "%dirpath%\env\scripts\pyinstaller.exe" (
"%dirpath%\env\scripts\pip" install pyinstaller "%dirpath%\env\scripts\pip" install pyinstaller
if errorlevel 1 ( if errorlevel 1 (
echo Failed to install pyinstaller. echo Failed to install pyinstaller.
exit /b 1 exit /b 1
) )
"%dirpath%\env\scripts\python" "%dirpath%\env\scripts\pywin32_postinstall.py" -install -silent "%dirpath%\env\scripts\python" "%dirpath%\env\scripts\pywin32_postinstall.py" -install -silent
if errorlevel 1 ( if errorlevel 1 (
echo Failed to run pywin32_postinstall.py. echo Failed to run pywin32_postinstall.py.
exit /b 1 exit /b 1
) )
) )
REM Run pyinstaller with the specified build spec file REM Run pyinstaller with the specified build spec file
"%dirpath%\env\scripts\pyinstaller" "%dirpath%\build.spec" "%dirpath%\env\scripts\pyinstaller" "%dirpath%\build.spec"
if errorlevel 1 ( if errorlevel 1 (
echo PyInstaller build failed. echo PyInstaller build failed.
exit /b 1 exit /b 1
) )
echo Build completed successfully. echo Build completed successfully.
+1 -1
View File
@@ -33,4 +33,4 @@ fi
echo echo
echo "Build completed successfully." echo "Build completed successfully."
read -p "Press any key to continue..." read -p "Press any key to continue..."
Regular → Executable
+117 -117
View File
@@ -1,117 +1,117 @@
# -*- mode: python ; coding: utf-8 -*- # -*- mode: python ; coding: utf-8 -*-
from __future__ import annotations from __future__ import annotations
import sys import sys
from pathlib import Path import platform
from typing import Any, TYPE_CHECKING from pathlib import Path
import platform from typing import Any, TYPE_CHECKING
SELF_PATH = str(Path(".").resolve()) SELF_PATH = str(Path(".").resolve())
if SELF_PATH not in sys.path: if SELF_PATH not in sys.path:
sys.path.insert(0, SELF_PATH) sys.path.insert(0, SELF_PATH)
from constants import WORKING_DIR, SITE_PACKAGES_PATH, DEFAULT_LANG from constants import WORKING_DIR, SITE_PACKAGES_PATH, DEFAULT_LANG
if TYPE_CHECKING: if TYPE_CHECKING:
from PyInstaller.building.api import PYZ, EXE from PyInstaller.building.api import PYZ, EXE
from PyInstaller.building.build_main import Analysis from PyInstaller.building.build_main import Analysis
# (source_path, dest_path, required) # (source_path, dest_path, required)
to_add: list[tuple[Path, str, bool]] = [ to_add: list[tuple[Path, str, bool]] = [
# icon files # icon files
(Path("icons/pickaxe.ico"), "./icons", True), (Path("icons/pickaxe.ico"), "./icons", True),
(Path("icons/active.ico"), "./icons", True), (Path("icons/active.ico"), "./icons", True),
(Path("icons/idle.ico"), "./icons", True), (Path("icons/idle.ico"), "./icons", True),
(Path("icons/error.ico"), "./icons", True), (Path("icons/error.ico"), "./icons", True),
(Path("icons/maint.ico"), "./icons", True), (Path("icons/maint.ico"), "./icons", True),
# SeleniumWire HTTPS/SSL cert file and key # SeleniumWire HTTPS/SSL cert file and key
(Path(SITE_PACKAGES_PATH, "seleniumwire/ca.crt"), "./seleniumwire", False), (Path(SITE_PACKAGES_PATH, "seleniumwire/ca.crt"), "./seleniumwire", False),
(Path(SITE_PACKAGES_PATH, "seleniumwire/ca.key"), "./seleniumwire", False), (Path(SITE_PACKAGES_PATH, "seleniumwire/ca.key"), "./seleniumwire", False),
] ]
for lang_filepath in WORKING_DIR.joinpath("lang").glob("*.json"): for lang_filepath in WORKING_DIR.joinpath("lang").glob("*.json"):
if lang_filepath.stem != DEFAULT_LANG: if lang_filepath.stem != DEFAULT_LANG:
to_add.append((lang_filepath, "lang", True)) to_add.append((lang_filepath, "lang", True))
# Ensure the required to-be-added data exists # Ensure the required to-be-added data exists
datas: list[tuple[Path, str]] = [] datas: list[tuple[Path, str]] = []
for source_path, dest_path, required in to_add: for source_path, dest_path, required in to_add:
if source_path.exists(): if source_path.exists():
datas.append((source_path, dest_path)) datas.append((source_path, dest_path))
elif required: elif required:
raise FileNotFoundError(str(source_path)) raise FileNotFoundError(str(source_path))
hooksconfig: dict[str, Any] = {} hooksconfig: dict[str, Any] = {}
binaries: list[tuple[Path, str]] = [] binaries: list[tuple[Path, str]] = []
hiddenimports: list[str] = [ hiddenimports: list[str] = [
"PIL._tkinter_finder", "PIL._tkinter_finder",
"setuptools._distutils.log", "setuptools._distutils.log",
"setuptools._distutils.dir_util", "setuptools._distutils.dir_util",
"setuptools._distutils.file_util", "setuptools._distutils.file_util",
"setuptools._distutils.archive_util", "setuptools._distutils.archive_util",
] ]
if sys.platform == "linux": if sys.platform == "linux":
# Needed files for better system tray support on Linux via pystray (AppIndicator backend). # Needed files for better system tray support on Linux via pystray (AppIndicator backend).
arch = platform.machine() arch = platform.machine()
datas.append((Path(f"/usr/lib/{arch}-linux-gnu/girepository-1.0/AyatanaAppIndicator3-0.1.typelib"), "gi_typelibs")) datas.append((Path(f"/usr/lib/{arch}-linux-gnu/girepository-1.0/AyatanaAppIndicator3-0.1.typelib"), "gi_typelibs"))
binaries.append((Path(f"/usr/lib/{arch}-linux-gnu/libayatana-appindicator3.so.1"), ".")) binaries.append((Path(f"/usr/lib/{arch}-linux-gnu/libayatana-appindicator3.so.1"), "."))
hiddenimports.extend([ hiddenimports.extend([
"gi.repository.Gtk", "gi.repository.Gtk",
"gi.repository.GObject", "gi.repository.GObject",
]) ])
hooksconfig = { hooksconfig = {
"gi": { "gi": {
"icons": [], "icons": [],
"themes": [], "themes": [],
"languages": ["en_US"] "languages": ["en_US"]
} }
} }
block_cipher = None block_cipher = None
a = Analysis( a = Analysis(
["main.py"], ["main.py"],
pathex=[], pathex=[],
datas=datas, datas=datas,
excludes=[], excludes=[],
hookspath=[], hookspath=[],
noarchive=False, noarchive=False,
runtime_hooks=[], runtime_hooks=[],
binaries=binaries, binaries=binaries,
cipher=block_cipher, cipher=block_cipher,
hooksconfig=hooksconfig, hooksconfig=hooksconfig,
hiddenimports=hiddenimports, hiddenimports=hiddenimports,
win_private_assemblies=False, win_private_assemblies=False,
win_no_prefer_redirects=False, win_no_prefer_redirects=False,
) )
# Exclude unneeded Linux libraries # Exclude unneeded Linux libraries
excluded_binaries = [ excluded_binaries = [
"libicudata.so.66", "libicudata.so.66",
"libicuuc.so.66", "libicuuc.so.66",
"librsvg-2.so.2" "librsvg-2.so.2"
] ]
a.binaries = [b for b in a.binaries if b[0] not in excluded_binaries] a.binaries = [b for b in a.binaries if b[0] not in excluded_binaries]
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher) pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)
exe = EXE( exe = EXE(
pyz, pyz,
a.scripts, a.scripts,
a.binaries, a.binaries,
a.zipfiles, a.zipfiles,
a.datas, a.datas,
[], [],
upx=True, upx=True,
debug=False, debug=False,
strip=False, strip=False,
console=False, console=False,
upx_exclude=[], upx_exclude=[],
target_arch=None, target_arch=None,
runtime_tmpdir=None, runtime_tmpdir=None,
codesign_identity=None, codesign_identity=None,
entitlements_file=None, entitlements_file=None,
icon="icons/pickaxe.ico", icon="icons/pickaxe.ico",
bootloader_ignore_signals=False, bootloader_ignore_signals=False,
disable_windowed_traceback=False, disable_windowed_traceback=False,
name="Twitch Drops Miner (by DevilXD)", name="Twitch Drops Miner (by DevilXD)",
) )
Regular → Executable
+46 -54
View File
@@ -1,54 +1,46 @@
@echo off @echo off
REM Get the directory path of the script REM Get the directory path of the script
set "dirpath=%~dp0" set "dirpath=%~dp0"
if "%dirpath:~-1%" == "\" set "dirpath=%dirpath:~0,-1%" if "%dirpath:~-1%" == "\" set "dirpath=%dirpath:~0,-1%"
REM Check if git is installed REM Check if git is installed
git --version > nul 2>&1 git --version > nul 2>&1
if %errorlevel% NEQ 0 ( if %errorlevel% NEQ 0 (
echo No git executable found in PATH! echo No git executable found in PATH!
echo: echo:
pause pause
exit /b 1 exit /b 1
) )
REM Create the virtual environment if it doesn't exist REM Create the virtual environment if it doesn't exist
if not exist "%dirpath%\env" ( if not exist "%dirpath%\env" (
echo: echo:
echo Creating the env folder... echo Creating the env folder...
python -m venv "%dirpath%\env" python -m venv "%dirpath%\env"
if %errorlevel% NEQ 0 ( if %errorlevel% NEQ 0 (
echo: echo:
echo No python executable found in PATH or failed to create virtual environment! echo No python executable found in PATH or failed to create virtual environment!
echo: echo:
pause pause
exit /b 1 exit /b 1
) )
) )
REM Activate the virtual environment and install requirements REM Activate the virtual environment and install requirements
echo: echo:
echo Installing requirements.txt... echo Installing requirements.txt...
"%dirpath%\env\scripts\python" -m pip install -U pip "%dirpath%\env\scripts\python" -m pip install -U pip
if %errorlevel% NEQ 0 (
echo Failed to upgrade pip. "%dirpath%\env\scripts\pip" install wheel
exit /b 1
) "%dirpath%\env\scripts\pip" install -r "%dirpath%\requirements.txt"
if %errorlevel% NEQ 0 (
"%dirpath%\env\scripts\pip" install wheel echo Failed to install requirements.
if %errorlevel% NEQ 0 ( exit /b 1
echo Failed to install wheel. )
exit /b 1
) echo:
echo All done!
"%dirpath%\env\scripts\pip" install -r "%dirpath%\requirements.txt" echo:
if %errorlevel% NEQ 0 ( pause
echo Failed to install requirements.
exit /b 1
)
echo:
echo All done!
echo:
pause
+1 -9
View File
@@ -28,16 +28,8 @@ fi
echo echo
echo "Installing requirements.txt..." echo "Installing requirements.txt..."
"$dirpath/env/bin/python" -m pip install -U pip "$dirpath/env/bin/python" -m pip install -U pip
if [ $? -ne 0 ]; then
echo "Failed to upgrade pip."
exit 1
fi
"$dirpath/env/bin/pip" install wheel "$dirpath/env/bin/pip" install wheel
if [ $? -ne 0 ]; then
echo "Failed to install wheel."
exit 1
fi
"$dirpath/env/bin/pip" install -r "$dirpath/requirements.txt" "$dirpath/env/bin/pip" install -r "$dirpath/requirements.txt"
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
@@ -48,4 +40,4 @@ fi
echo echo
echo "All done!" echo "All done!"
echo echo
read -p "Press any key to continue..." read -p "Press any key to continue..."