From c17812a0c1b7d503bd93a05fd15b8c318afdcc68 Mon Sep 17 00:00:00 2001 From: Scheianu Ionut Date: Fri, 26 Sep 2025 18:53:04 +0300 Subject: [PATCH] updated download --- py_app/app/__pycache__/routes.cpython-312.pyc | Bin 79602 -> 93353 bytes py_app/app/routes.py | 372 ++++++++++++++++ py_app/app/templates/download_extension.html | 199 +++++++-- .../create_portable_package.py | 406 ++++++++++++++++++ 4 files changed, 950 insertions(+), 27 deletions(-) create mode 100644 windows_print_service/create_portable_package.py diff --git a/py_app/app/__pycache__/routes.cpython-312.pyc b/py_app/app/__pycache__/routes.cpython-312.pyc index 45c2c954ad24c8d006ac5cd158bee4b5e3fbf7c1..fc53a575fed532d37d23cbf1a4f4fe32c521d0ce 100644 GIT binary patch delta 12711 zcmbVy3shTIcIdqlNJ9Js2oUCX_!)!&fx#xmUktL10~iDGKfyxx0Fb*{vL~&lnXazx zeeS)Iz)m`Sc=_CO&)H|6{Xcu3tH(b}x%nV9>qnWHdItW!@@MxZzTH2QWn%yOk83Sj z9alKce#`WxN<5~0S@k9>exyCE;|k=lgSrMByQFJKz`q_Y-(64defTqTmfKF zQ7nI$Mpvw+HL?YwPT$HFiaYeh;yJb;RY0_&SKqJV>%`OQ{HpVbbx0Y*aMNF4-juq` ziIW#u^M%{r*Zt;x;AAg zm-?nkLK4&_q1FVnUuWI`sjlB3{DFzh6E836H+l>zCZOT8oKAw}(q50lbNVsW&>Esx zx^)JZ9^XzUK76;RP{(C_D^nR`87?cB7AF~a*{=(vDYHR6mmN&!41x5oGh7aBbKgh} zW^j4I%p}r{bSD1|brSLH?|xiTy@d&8CBYR0vYyQ%$}lI3D~#`(olH?1gD$||0zIgb}9}S*6sxAW6snm)|7ZA@O3k<=Gs-`j9v9&0mB4y1G(a!Vxw55 z(wjW&<@`YIjOwx}g$d@tRGu)9ET$GiAdh2<0INbw(CBScHVGKHQe_-C0mNr4;!hg$ z#6DG8Jy^k~b5Wk)Rg#J>pyw(AsxxikOmm+2&b#`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wNoH)9CH=Kf0LV%+pp;;?#CQW`wFbQL!F)G09zduDqT z_TVjZz6vq*j<}xp%(bhryZi;wap)}hGx?#Fl&=%hHwmXh9qrxC-7T%1?MeNf_=i1n zW;IUArT0~%VEs4``!$=Sza=_|bS+o&qM8{=SG=)>ieXl~boXare+!dy_;m@T-$u*9NtwO}Ub}Mdx zRQO>%o{Rp<3cnEnd78NUul@sOs20n@e@ftcp53%?cBU2+E)Lj3w__{R1quJ|*^3)- z+*_P(?s-;9cX%Flq8@X=F=OwEqflTkmFM>Nw^Q~@GLd_rFa zRalPo`s&JRbckkzRl-zP5Si{q;T*HGXgdsNQ_WB-x(n^l;PUmZX)l|56G8}*3AJ-M)iZ|Ls8xEpzFYnKV*IabX z4cFXa&Gpknul 2>&1 +if %errorLevel% neq 0 ( + echo āŒ ERROR: Administrator privileges required + echo Please right-click this file and select "Run as administrator" + echo. + pause + exit /b 1 +) + +echo [1/7] Administrator privileges confirmed āœ… +echo. + +REM Set variables +set CURRENT_DIR=%~dp0 +set SERVICE_NAME=QualityPrintService +set SERVICE_DISPLAY_NAME=Quality Label Print Service +set INSTALL_DIR=C:\\QualityPrintService +set PYTHON_EXE=%INSTALL_DIR%\\{PYTHON_DIR_NAME}\\python.exe +set PYTHON_SCRIPT=%INSTALL_DIR%\\print_service_complete.py +set LOG_DIR=%USERPROFILE%\\PrintService\\logs + +echo [2/7] Using embedded Python distribution āœ… +echo Python location: %PYTHON_EXE% +echo. + +REM Stop existing service if running +echo [3/7] Stopping existing service (if any)... +sc query "%SERVICE_NAME%" >nul 2>&1 +if %errorLevel% equ 0 ( + echo Stopping existing service... + net stop "%SERVICE_NAME%" >nul 2>&1 + sc delete "%SERVICE_NAME%" >nul 2>&1 + timeout /t 2 >nul +) +echo Service cleanup completed āœ… +echo. + +REM Create installation directory +echo [4/7] Creating installation directory... +if exist "%INSTALL_DIR%" ( + echo Removing old installation... + rmdir /s /q "%INSTALL_DIR%" >nul 2>&1 +) +mkdir "%INSTALL_DIR%" >nul 2>&1 +echo Installation directory: %INSTALL_DIR% āœ… +echo. + +REM Copy all files to installation directory +echo [5/7] Installing service files... +echo Copying embedded Python... +xcopy "%CURRENT_DIR%{PYTHON_DIR_NAME}" "%INSTALL_DIR%\\{PYTHON_DIR_NAME}\\" /E /I /Y >nul +echo Copying service script... +copy "%CURRENT_DIR%print_service_complete.py" "%INSTALL_DIR%\\" >nul +echo Service files installed āœ… +echo. + +REM Create log directory +echo [6/7] Setting up logging... +mkdir "%LOG_DIR%" >nul 2>&1 +echo Log directory: %LOG_DIR% āœ… +echo. + +REM Install and start Windows service +echo [7/7] Installing Windows service... +sc create "%SERVICE_NAME%" binPath= "\\"%PYTHON_EXE%\\" \\"%PYTHON_SCRIPT%\\"" DisplayName= "%SERVICE_DISPLAY_NAME%" start= auto +if %errorLevel% neq 0 ( + echo āŒ Failed to create Windows service + pause + exit /b 1 +) + +REM Configure service recovery +sc failure "%SERVICE_NAME%" reset= 60 actions= restart/10000/restart/30000/restart/60000 +sc config "%SERVICE_NAME%" depend= "" + +REM Start the service +echo Starting service... +net start "%SERVICE_NAME%" +if %errorLevel% neq 0 ( + echo āš ļø Service created but failed to start immediately + echo This is normal - the service will start automatically on reboot +) else ( + echo Service started successfully āœ… +) + +echo. +echo ======================================== +echo INSTALLATION COMPLETED! šŸŽ‰ +echo ======================================== +echo. +echo āœ… Python embedded distribution installed +echo āœ… Windows Print Service installed and configured +echo āœ… Auto-recovery enabled (restarts on failure) +echo āœ… Service will start automatically on boot +echo. +echo 🌐 Service URL: http://localhost:8765 +echo šŸ“Š Health check: http://localhost:8765/health +echo šŸ“ Logs location: %LOG_DIR% +echo. +echo šŸ“‹ NEXT STEPS: +echo 1. Install Chrome extension from 'chrome_extension' folder +echo 2. Test service: http://localhost:8765/health +echo 3. Configure web application to use service +echo. +echo Press any key to test service connection... +pause >nul + +REM Test service +echo Testing service connection... +timeout /t 3 >nul +curl -s http://localhost:8765/health >nul 2>&1 +if %errorLevel% equ 0 ( + echo āœ… Service is responding correctly! +) else ( + echo āš ļø Service test failed - may need a moment to start + echo Check logs in: %LOG_DIR% +) + +echo. +echo Installation complete! Service is ready to use. +pause +''' + + zipf.writestr("INSTALL_ZERO_DEPENDENCIES.bat", installer_content) + files_added += 1 + + # Add comprehensive README + readme_content = f'''# Quality Print Service - ZERO DEPENDENCIES Package + +## šŸŽÆ COMPLETE SELF-CONTAINED INSTALLATION + +This package contains EVERYTHING needed to run the Quality Print Service: + +### āœ… What's Included: +- **Embedded Python {PYTHON_VERSION}** - No system Python required! +- **Complete Print Service** - Zero external dependencies +- **Windows Service Installer** - Automatic installation and recovery +- **Chrome Extension** - Web browser integration +- **Comprehensive Documentation** - Installation and usage guides + +### šŸš€ INSTALLATION (5 Minutes): + +#### Requirements: +- Windows 10/11 or Windows Server 2016+ +- Administrator privileges (for service installation) +- Google Chrome browser + +#### Step 1: Extract Package +- Extract this ZIP file to any location (Desktop, Downloads, etc.) +- No permanent location needed - installer copies files automatically + +#### Step 2: Install Service +- Right-click `INSTALL_ZERO_DEPENDENCIES.bat` +- Select "Run as administrator" +- Follow the installation prompts + +#### Step 3: Install Chrome Extension +- Open Chrome browser +- Navigate to `chrome://extensions/` +- Enable "Developer mode" (toggle in top-right) +- Click "Load unpacked" +- Select the `chrome_extension` folder from extracted package + +#### Step 4: Test Installation +- Visit: http://localhost:8765/health +- Should return: {{"status": "healthy", "service": "Windows Print Service"}} + +### šŸ”§ Technical Details: + +**Service Architecture:** +``` +Quality Web App → Chrome Extension → Windows Service → Printer +``` + +**Printing Methods (automatic fallback):** +1. Adobe Reader (silent printing) +2. SumatraPDF (if Adobe unavailable) +3. PowerShell Print-Document +4. Microsoft Edge (fallback) +5. Windows default printer + +**Service Management:** +- Automatic startup on Windows boot +- Auto-recovery on failure (3 restart attempts) +- Comprehensive logging in: `%USERPROFILE%\\PrintService\\logs\\` + +**Network Configuration:** +- Service runs on: http://localhost:8765 +- Chrome extension communicates via this local endpoint +- No external network access required + +### šŸ“¦ Package Size: ~15MB (includes full Python runtime) +### ā±ļø Installation Time: ~5 minutes +### šŸ”§ Maintenance Required: Zero (auto-starts with Windows) + +Ready to use immediately after installation! +''' + + zipf.writestr("README_ZERO_DEPENDENCIES.md", readme_content) + files_added += 1 + + # Verify ZIP was created successfully + if os.path.exists(zip_path): + zip_size = os.path.getsize(zip_path) + print(f"āœ… Zero-dependency package created: {zip_path}") + print(f"šŸ“„ Total files: {files_added}") + print(f"šŸ“ Size: {zip_size / 1024 / 1024:.1f} MB") + + if zip_size > 0: + return jsonify({ + 'success': True, + 'download_url': f'/static/{zip_filename}', + 'files_included': files_added, + 'zip_size': zip_size, + 'package_type': 'Zero Dependencies - Complete Package', + 'python_version': PYTHON_VERSION, + 'dependencies': 'None - Everything included!', + 'estimated_size_mb': round(zip_size / 1024 / 1024, 1) + }) + else: + return jsonify({ + 'success': False, + 'error': 'ZIP file was created but is empty' + }), 500 + else: + return jsonify({ + 'success': False, + 'error': 'Failed to create zero-dependency ZIP file' + }), 500 + + except Exception as e: + print(f"āŒ Error creating zero-dependency service package: {e}") + import traceback + traceback.print_exc() + return jsonify({ + 'success': False, + 'error': str(e) + }), 500 + @bp.route('/test_extension_files') def test_extension_files(): """Test route to check extension files""" diff --git a/py_app/app/templates/download_extension.html b/py_app/app/templates/download_extension.html index 4a6475a..cc6bf5d 100644 --- a/py_app/app/templates/download_extension.html +++ b/py_app/app/templates/download_extension.html @@ -8,10 +8,10 @@
-

šŸ–Øļø Quality Recticel Print Extension

-

Simple & Robust Chrome Extension for PDF Printing

-
- ✨ NEW SIMPLIFIED APPROACH: No Windows service needed! Just install the Chrome extension and print directly from your browser. +

šŸ–Øļø Quality Recticel Print Solutions

+

Choose Your Printing Method: Chrome Extension or Windows Service

+
+ šŸ†• TWO POWERFUL OPTIONS: Simple browser-based Chrome extension or enterprise-grade Windows service for advanced printing needs.
@@ -22,28 +22,28 @@
-

šŸš€ Simple Chrome Extension Solution

+

šŸš€ Two Printing Solutions Available

-
šŸ† What You Get:
+
ļæ½ Chrome Extension (Recommended)
    -
  • āœ… Direct PDF Printing - Uses browser's print dialog
  • -
  • āœ… Zero Configuration - Works immediately after install
  • -
  • āœ… Cross-Platform - Works on Windows, Mac, Linux
  • -
  • āœ… No External Services - No Windows service needed
  • -
  • āœ… Robust Fallback - Downloads PDF if extension unavailable
  • +
  • āœ… Easy Setup - 2 minutes to install
  • +
  • āœ… Cross-Platform - Windows, Mac, Linux
  • +
  • āœ… User Control - Print dialog for printer selection
  • +
  • āœ… Zero Configuration - Works immediately
  • +
  • āœ… Secure - No external services needed
-
šŸ”§ How It Works:
+
šŸ”§ Windows Service (Enterprise)
    -
  • 🌐 Chrome Extension - Simple browser integration
  • -
  • šŸ“„ Hidden Tab Method - Opens PDF in background tab
  • -
  • ļæ½ļø Native Print Dialog - User controls printer selection
  • -
  • šŸ”„ Auto Cleanup - Closes tab after printing
  • -
  • šŸ›”ļø Secure - No external connections required
  • +
  • ⚔ Silent Printing - No user interaction needed
  • +
  • ļæ½ļø Direct Printer Access - System-level printing
  • +
  • šŸ¢ Enterprise Ready - Service auto-recovery
  • +
  • ļæ½ Advanced Features - Multiple print methods
  • +
  • šŸ›”ļø Self-Contained - Zero external dependencies
@@ -54,21 +54,21 @@
- -
+ +
-

🌐 Chrome Extension - All You Need!

- Simple browser-based printing solution +

🌐 Chrome Extension

+ Browser-based printing solution
- šŸŽ‰ SIMPLIFIED: Just install this Chrome extension - no Windows service needed! + šŸ“‹ RECOMMENDED: Easy setup, works everywhere!
šŸŽÆ Key Features:
    -
  • ļæ½ļø Opens PDF in hidden browser tab and triggers print dialog
  • +
  • šŸ–Øļø Opens PDF in hidden browser tab and triggers print dialog
  • šŸ” Automatic extension detection on web page
  • šŸ“Š Print status feedback and error handling
  • šŸ”„ Graceful fallback to PDF download
  • @@ -103,6 +103,60 @@
+ + +
+
+
+

šŸ”§ Windows Print Service

+ Enterprise-grade silent printing +
+
+
+ šŸ¢ ENTERPRISE: Silent printing with no user interaction! +
+ +
šŸŽÆ Key Features:
+
    +
  • ⚔ Silent printing - no print dialogs
  • +
  • šŸ–Øļø Direct system printer access
  • +
  • šŸ”„ Multiple print methods (Adobe, SumatraPDF, PowerShell)
  • +
  • šŸ›”ļø Windows service with auto-recovery
  • +
  • šŸ“¦ Self-contained - zero dependencies
  • +
  • šŸ¢ Perfect for production environments
  • +
+ +
šŸš€ Quick Install (3 steps):
+
    +
  1. Download and extract the service package
  2. +
  3. Run install_service_complete.bat as Administrator
  4. +
  5. Install Chrome extension (included in package)
  6. +
+ +
+
+ + +
+ +
+ + šŸ“¦ Standard Package (~50KB): Requires Python 3.7+ installed
+ šŸš€ Zero Dependencies (~15MB): Includes everything - no Python needed! +
+
+ +
+ āš ļø Windows Only: Requires Administrator privileges for service installation +
+
+
+
+
@@ -269,6 +323,97 @@ document.getElementById('download-extension-btn').addEventListener('click', func }); }); +// Windows Service Download Handler +document.getElementById('download-service-btn').addEventListener('click', function(e) { + e.preventDefault(); + + // Show loading state + const originalText = this.innerHTML; + this.innerHTML = 'ā³ Preparing Windows Service Package...'; + this.disabled = true; + + // Create the service package + fetch('/create_service_package', {method: 'POST'}) + .then(response => response.json()) + .then(data => { + if (data.success) { + // Start download + window.location.href = data.download_url; + + // Show success message + setTimeout(() => { + this.innerHTML = 'āœ… Download Started!'; + }, 500); + + // Reset button + setTimeout(() => { + this.innerHTML = originalText; + this.disabled = false; + }, 3000); + } else { + alert('Error creating service package: ' + data.error); + this.innerHTML = originalText; + this.disabled = false; + } + }) + .catch(error => { + alert('Error: ' + error.message); + this.innerHTML = originalText; + this.disabled = false; + }); +}); + +// Zero Dependencies Service Download Handler +document.getElementById('download-zero-deps-btn').addEventListener('click', function(e) { + e.preventDefault(); + + // Show loading state + const originalText = this.innerHTML; + this.innerHTML = 'ā³ Creating Zero-Dependency Package (may take 1-2 minutes)...'; + this.disabled = true; + + // Show progress info + const progressInfo = document.createElement('div'); + progressInfo.className = 'alert alert-info mt-2'; + progressInfo.innerHTML = 'šŸ“„ Downloading Python embedded distribution and creating complete package...'; + this.parentElement.appendChild(progressInfo); + + // Create the zero-dependency service package + fetch('/create_zero_dependency_service_package', {method: 'POST'}) + .then(response => response.json()) + .then(data => { + if (data.success) { + // Start download + window.location.href = data.download_url; + + // Show success message + setTimeout(() => { + this.innerHTML = `āœ… Download Started! (${data.estimated_size_mb}MB)`; + progressInfo.innerHTML = `šŸŽ‰ Complete package created with ${data.files_included} files including Python ${data.python_version}!`; + progressInfo.className = 'alert alert-success mt-2'; + }, 500); + + // Reset button + setTimeout(() => { + this.innerHTML = originalText; + this.disabled = false; + progressInfo.remove(); + }, 5000); + } else { + alert('Error creating zero-dependency package: ' + data.error); + this.innerHTML = originalText; + this.disabled = false; + progressInfo.remove(); + } + }) + .catch(error => { + alert('Error: ' + error.message); + this.innerHTML = originalText; + this.disabled = false; + progressInfo.remove(); + }); +}); + // Extension Test Functionality document.getElementById('test-extension-btn').addEventListener('click', function(e) { e.preventDefault(); @@ -375,10 +520,10 @@ async function testExtensionConnection() { // Show installation tips function showInstallationTips() { const tips = [ - 'šŸ’” Tip: This new approach is much simpler - no Windows service needed!', - 'šŸ’” Tip: The extension works on Windows, Mac, and Linux', - 'šŸ’” Tip: Users will see Chrome\'s print dialog for printer selection', - 'šŸ’” Tip: The system gracefully falls back to PDF downloads if needed' + 'šŸ’” Tip: Chrome Extension is recommended for most users - cross-platform and easy!', + 'šŸ’” Tip: Windows Service is perfect for enterprise environments requiring silent printing', + 'šŸ’” Tip: Both solutions work with the same web interface and automatically detected', + 'šŸ’” Tip: The system gracefully falls back to PDF downloads if neither is available' ]; let tipIndex = 0; diff --git a/windows_print_service/create_portable_package.py b/windows_print_service/create_portable_package.py new file mode 100644 index 0000000..7501e84 --- /dev/null +++ b/windows_print_service/create_portable_package.py @@ -0,0 +1,406 @@ +#!/usr/bin/env python3 +""" +Script to create a completely self-contained Windows Print Service package +with embedded Python distribution - Zero external dependencies required! +""" + +import os +import sys +import zipfile +import urllib.request +import tempfile +import shutil +from pathlib import Path + +# Python embeddable version details +PYTHON_VERSION = "3.11.9" +PYTHON_DOWNLOAD_URL = f"https://www.python.org/ftp/python/{PYTHON_VERSION}/python-{PYTHON_VERSION}-embed-amd64.zip" +PYTHON_DIR_NAME = "python_embedded" + +def download_portable_python(temp_dir): + """Download and extract Python embedded distribution""" + print(f"šŸ“„ Downloading Python {PYTHON_VERSION} embedded distribution...") + + python_zip_path = os.path.join(temp_dir, "python-embed.zip") + + try: + # Download Python embedded + urllib.request.urlretrieve(PYTHON_DOWNLOAD_URL, python_zip_path) + print(f"āœ… Downloaded Python to: {python_zip_path}") + + # Create extraction directory + python_extract_dir = os.path.join(temp_dir, PYTHON_DIR_NAME) + os.makedirs(python_extract_dir, exist_ok=True) + + # Extract Python + with zipfile.ZipFile(python_zip_path, 'r') as zip_ref: + zip_ref.extractall(python_extract_dir) + + print(f"āœ… Extracted Python to: {python_extract_dir}") + + # Enable site-packages by modifying pth file + pth_files = [f for f in os.listdir(python_extract_dir) if f.endswith('._pth')] + if pth_files: + pth_file = os.path.join(python_extract_dir, pth_files[0]) + with open(pth_file, 'a') as f: + f.write('\nimport site\n') + print("āœ… Enabled site-packages in embedded Python") + + return python_extract_dir + + except Exception as e: + print(f"āŒ Failed to download Python: {e}") + return None + +def create_complete_package(): + """Create complete self-contained package with embedded Python""" + + # Get current directory (should be windows_print_service) + current_dir = Path(__file__).parent + print(f"šŸ“‚ Working from: {current_dir}") + + # Create temporary directory + with tempfile.TemporaryDirectory() as temp_dir: + print(f"šŸ”§ Using temporary directory: {temp_dir}") + + # Download and extract portable Python + python_dir = download_portable_python(temp_dir) + if not python_dir: + print("āŒ Failed to prepare Python distribution") + return False + + # Create the complete package + package_path = current_dir / "QualityPrintService_COMPLETE_ZERO_DEPENDENCIES.zip" + + print(f"šŸ“¦ Creating complete package: {package_path}") + + with zipfile.ZipFile(package_path, 'w', zipfile.ZIP_DEFLATED) as zipf: + files_added = 0 + + # Add Python embedded distribution + print("šŸ“ Adding Python embedded distribution...") + for root, dirs, files in os.walk(python_dir): + for file in files: + file_path = os.path.join(root, file) + arcname = os.path.join(PYTHON_DIR_NAME, os.path.relpath(file_path, python_dir)) + zipf.write(file_path, arcname) + files_added += 1 + + # Add all service files + print("šŸ“ Adding service files...") + service_files = [ + "print_service_complete.py", + "install_service_complete.bat", + "uninstall_service_complete.bat", + "INSTALLATION_COMPLETE.md", + "PACKAGE_SUMMARY.md", + "README_COMPLETE.md" + ] + + for file_name in service_files: + file_path = current_dir / file_name + if file_path.exists(): + zipf.write(file_path, file_name) + files_added += 1 + print(f" āœ… Added: {file_name}") + + # Add Chrome extension + chrome_ext_dir = current_dir / "chrome_extension" + if chrome_ext_dir.exists(): + print("šŸ“ Adding Chrome extension...") + for root, dirs, files in os.walk(chrome_ext_dir): + for file in files: + if not file.startswith('.'): + file_path = os.path.join(root, file) + arcname = os.path.relpath(file_path, current_dir) + zipf.write(file_path, arcname) + files_added += 1 + + # Create updated installer that uses embedded Python + updated_installer = f'''@echo off +setlocal enabledelayedexpansion + +echo ======================================== +echo Quality Label Print Service Installer +echo ZERO DEPENDENCIES - COMPLETE PACKAGE +echo ======================================== +echo. +echo This package includes EVERYTHING needed: +echo āœ… Embedded Python {PYTHON_VERSION} +echo āœ… Complete Print Service +echo āœ… Windows Service Installer +echo āœ… Chrome Extension +echo āœ… Auto-recovery System +echo. + +REM Check for administrator privileges +net session >nul 2>&1 +if %errorLevel% neq 0 ( + echo āŒ ERROR: Administrator privileges required + echo Please right-click this file and select "Run as administrator" + echo. + pause + exit /b 1 +) + +echo [1/7] Administrator privileges confirmed āœ… +echo. + +REM Set variables +set CURRENT_DIR=%~dp0 +set SERVICE_NAME=QualityPrintService +set SERVICE_DISPLAY_NAME=Quality Label Print Service +set INSTALL_DIR=C:\\QualityPrintService +set PYTHON_EXE=%INSTALL_DIR%\\{PYTHON_DIR_NAME}\\python.exe +set PYTHON_SCRIPT=%INSTALL_DIR%\\print_service_complete.py +set LOG_DIR=%USERPROFILE%\\PrintService\\logs + +echo [2/7] Using embedded Python distribution āœ… +echo Python location: %PYTHON_EXE% +echo. + +REM Stop existing service if running +echo [3/7] Stopping existing service (if any)... +sc query "%SERVICE_NAME%" >nul 2>&1 +if %errorLevel% equ 0 ( + echo Stopping existing service... + net stop "%SERVICE_NAME%" >nul 2>&1 + sc delete "%SERVICE_NAME%" >nul 2>&1 + timeout /t 2 >nul +) +echo Service cleanup completed āœ… +echo. + +REM Create installation directory +echo [4/7] Creating installation directory... +if exist "%INSTALL_DIR%" ( + echo Removing old installation... + rmdir /s /q "%INSTALL_DIR%" >nul 2>&1 +) +mkdir "%INSTALL_DIR%" >nul 2>&1 +echo Installation directory: %INSTALL_DIR% āœ… +echo. + +REM Copy all files to installation directory +echo [5/7] Installing service files... +echo Copying embedded Python... +xcopy "%CURRENT_DIR%{PYTHON_DIR_NAME}" "%INSTALL_DIR%\\{PYTHON_DIR_NAME}\\" /E /I /Y >nul +echo Copying service script... +copy "%CURRENT_DIR%print_service_complete.py" "%INSTALL_DIR%\\" >nul +echo Service files installed āœ… +echo. + +REM Create log directory +echo [6/7] Setting up logging... +mkdir "%LOG_DIR%" >nul 2>&1 +echo Log directory: %LOG_DIR% āœ… +echo. + +REM Install and start Windows service +echo [7/7] Installing Windows service... +sc create "%SERVICE_NAME%" binPath= "\\"%PYTHON_EXE%\\" \\"%PYTHON_SCRIPT%\\"" DisplayName= "%SERVICE_DISPLAY_NAME%" start= auto +if %errorLevel% neq 0 ( + echo āŒ Failed to create Windows service + pause + exit /b 1 +) + +REM Configure service recovery +sc failure "%SERVICE_NAME%" reset= 60 actions= restart/10000/restart/30000/restart/60000 +sc config "%SERVICE_NAME%" depend= "" + +REM Start the service +echo Starting service... +net start "%SERVICE_NAME%" +if %errorLevel% neq 0 ( + echo āš ļø Service created but failed to start immediately + echo This is normal - the service will start automatically on reboot +) else ( + echo Service started successfully āœ… +) + +echo. +echo ======================================== +echo INSTALLATION COMPLETED! šŸŽ‰ +echo ======================================== +echo. +echo āœ… Python embedded distribution installed +echo āœ… Windows Print Service installed and configured +echo āœ… Auto-recovery enabled (restarts on failure) +echo āœ… Service will start automatically on boot +echo. +echo 🌐 Service URL: http://localhost:8765 +echo šŸ“Š Health check: http://localhost:8765/health +echo šŸ“ Logs location: %LOG_DIR% +echo. +echo šŸ“‹ NEXT STEPS: +echo 1. Install Chrome extension from 'chrome_extension' folder +echo 2. Test service: http://localhost:8765/health +echo 3. Configure web application to use service +echo. +echo Press any key to test service connection... +pause >nul + +REM Test service +echo Testing service connection... +timeout /t 3 >nul +curl -s http://localhost:8765/health >nul 2>&1 +if %errorLevel% equ 0 ( + echo āœ… Service is responding correctly! +) else ( + echo āš ļø Service test failed - may need a moment to start + echo Check logs in: %LOG_DIR% +) + +echo. +echo Installation complete! Service is ready to use. +pause +''' + + # Add the updated installer + zipf.writestr("install_service_ZERO_DEPENDENCIES.bat", updated_installer) + files_added += 1 + + # Add comprehensive README + readme_content = f'''# Quality Print Service - ZERO DEPENDENCIES Package + +## šŸŽÆ COMPLETE SELF-CONTAINED INSTALLATION + +This package contains EVERYTHING needed to run the Quality Print Service: + +### āœ… What's Included: +- **Embedded Python {PYTHON_VERSION}** - No system Python required! +- **Complete Print Service** - Zero external dependencies +- **Windows Service Installer** - Automatic installation and recovery +- **Chrome Extension** - Web browser integration +- **Comprehensive Documentation** - Installation and usage guides + +### šŸš€ INSTALLATION (5 Minutes): + +#### Requirements: +- Windows 10/11 or Windows Server 2016+ +- Administrator privileges (for service installation) +- Google Chrome browser + +#### Step 1: Extract Package +- Extract this ZIP file to any location (Desktop, Downloads, etc.) +- No permanent location needed - installer copies files automatically + +#### Step 2: Install Service +- Right-click `install_service_ZERO_DEPENDENCIES.bat` +- Select "Run as administrator" +- Follow the installation prompts + +#### Step 3: Install Chrome Extension +- Open Chrome browser +- Navigate to `chrome://extensions/` +- Enable "Developer mode" (toggle in top-right) +- Click "Load unpacked" +- Select the `chrome_extension` folder from extracted package + +#### Step 4: Test Installation +- Visit: http://localhost:8765/health +- Should return: {{"status": "healthy", "service": "Windows Print Service"}} + +### šŸ”§ Technical Details: + +**Service Architecture:** +``` +Quality Web App → Chrome Extension → Windows Service → Printer +``` + +**Printing Methods (automatic fallback):** +1. Adobe Reader (silent printing) +2. SumatraPDF (if Adobe unavailable) +3. PowerShell Print-Document +4. Microsoft Edge (fallback) +5. Windows default printer + +**Service Management:** +- Automatic startup on Windows boot +- Auto-recovery on failure (3 restart attempts) +- Comprehensive logging in: `%USERPROFILE%\\PrintService\\logs\\` + +**Network Configuration:** +- Service runs on: http://localhost:8765 +- Chrome extension communicates via this local endpoint +- No external network access required + +### šŸ“‚ Package Contents: +``` +QualityPrintService_COMPLETE_ZERO_DEPENDENCIES.zip +ā”œā”€ā”€ python_embedded/ # Python {PYTHON_VERSION} embedded +ā”œā”€ā”€ print_service_complete.py # Main service script +ā”œā”€ā”€ install_service_ZERO_DEPENDENCIES.bat # Installer +ā”œā”€ā”€ chrome_extension/ # Browser extension +│ ā”œā”€ā”€ manifest.json +│ ā”œā”€ā”€ background.js +│ ā”œā”€ā”€ content.js +│ ā”œā”€ā”€ popup.html +│ └── popup.js +└── README.md # This file +``` + +### šŸ› ļø Troubleshooting: + +**Service Won't Start:** +1. Check Windows Event Viewer → Windows Logs → Application +2. Check service logs in: `%USERPROFILE%\\PrintService\\logs\\` +3. Verify Python embedded installation in: `C:\\QualityPrintService\\` + +**Chrome Extension Not Working:** +1. Verify extension is enabled in `chrome://extensions/` +2. Check browser console for error messages +3. Ensure service is running: http://localhost:8765/health + +**Printing Issues:** +1. Verify printer is installed and accessible +2. Check service logs for printing attempts +3. Test manual PDF printing to verify printer functionality + +### šŸ”„ Uninstallation: +```cmd +# Stop and remove service +sc stop QualityPrintService +sc delete QualityPrintService + +# Remove installation directory +rmdir /s /q C:\\QualityPrintService + +# Remove Chrome extension manually from chrome://extensions/ +``` + +### šŸ“ž Support: +- Service logs: `%USERPROFILE%\\PrintService\\logs\\service.log` +- Health check: http://localhost:8765/health +- Printer list: http://localhost:8765/printers + +--- +**Package Version:** Complete Zero Dependencies +**Python Version:** {PYTHON_VERSION} (Embedded) +**Created:** {os.path.basename(__file__)} +''' + + zipf.writestr("README_ZERO_DEPENDENCIES.md", readme_content) + files_added += 1 + + print(f"\nšŸ“¦ Package created successfully!") + print(f"šŸ“„ Total files: {files_added}") + print(f"šŸ“‚ Location: {package_path}") + print(f"šŸ“ Size: {package_path.stat().st_size / 1024 / 1024:.1f} MB") + + return True + +if __name__ == "__main__": + print("šŸš€ Creating Complete Zero-Dependencies Package...") + print("=" * 60) + + if create_complete_package(): + print("\nāœ… SUCCESS: Complete package created!") + print("\nšŸ“‹ Next steps:") + print("1. Test the package on a clean Windows system") + print("2. Verify zero external dependencies") + print("3. Update Flask app to serve this package") + else: + print("\nāŒ FAILED: Package creation failed") + sys.exit(1) \ No newline at end of file