This commit is contained in:
2025-09-26 21:56:06 +03:00
parent c17812a0c1
commit 2216f21c47
17 changed files with 3361 additions and 631 deletions

View File

@@ -1063,16 +1063,54 @@ For support, contact your system administrator.
@bp.route('/create_service_package', methods=['POST'])
def create_service_package():
"""Create and serve ZIP package of Complete Windows Print Service with all dependencies"""
"""Create and serve the Enhanced Windows Print Service package with Error 1053 fixes"""
import os
import zipfile
from flask import current_app, jsonify
from flask import current_app, jsonify, send_file
try:
# Path to the windows_print_service directory
service_dir = os.path.join(os.path.dirname(os.path.dirname(current_app.root_path)), 'windows_print_service')
print(f"Looking for service files in: {service_dir}")
# Check if the enhanced package already exists
enhanced_package_path = os.path.join(service_dir, 'QualityPrintService_COMPLETE_ZERO_DEPENDENCIES.zip')
if os.path.exists(enhanced_package_path):
# Serve the pre-built enhanced package with Error 1053 fixes
print(f"Serving pre-built enhanced package: {enhanced_package_path}")
# Copy to static directory for download
static_dir = os.path.join(current_app.root_path, 'static')
os.makedirs(static_dir, exist_ok=True)
zip_filename = 'quality_print_service_enhanced_with_error_1053_fixes.zip'
static_zip_path = os.path.join(static_dir, zip_filename)
# Copy the enhanced package to static directory
import shutil
shutil.copy2(enhanced_package_path, static_zip_path)
zip_size = os.path.getsize(static_zip_path)
return jsonify({
'success': True,
'download_url': f'/static/{zip_filename}',
'package_type': 'Enhanced with Error 1053 fixes',
'features': [
'Embedded Python 3.11.9 (zero dependencies)',
'Multiple installation methods with automatic fallback',
'Windows Service Error 1053 comprehensive fixes',
'Enhanced service wrapper with SCM communication',
'Task Scheduler and Startup Script fallbacks',
'Diagnostic and troubleshooting tools',
'Complete Chrome extension integration'
],
'zip_size': zip_size,
'installation_methods': 4
})
# Fallback: create basic package if enhanced one not available
if not os.path.exists(service_dir):
return jsonify({
'success': False,
@@ -1298,7 +1336,7 @@ def create_zero_dependency_service_package():
if not os.path.exists(service_dir):
return jsonify({
'success': False,
'error': f'Windows service directory not found: {service_dir}'
'error': f'Windows service directory not found: {service_dir}'
}), 500
# Create static directory if it doesn't exist
@@ -1367,8 +1405,11 @@ def create_zero_dependency_service_package():
print("📁 Adding service files...")
service_files = [
"print_service_complete.py",
"service_wrapper.py",
"install_service_complete.bat",
"uninstall_service_complete.bat",
"test_service.bat",
"TROUBLESHOOTING_1053.md",
"INSTALLATION_COMPLETE.md",
"PACKAGE_SUMMARY.md",
"README_COMPLETE.md"
@@ -1916,7 +1957,8 @@ def get_unprinted_orders():
return jsonify({'error': str(e)}), 500
@bp.route('/generate_labels_pdf/<int:order_id>', methods=['POST'])
def generate_labels_pdf(order_id):
@bp.route('/generate_labels_pdf/<int:order_id>/<paper_saving_mode>', methods=['POST'])
def generate_labels_pdf(order_id, paper_saving_mode='true'):
"""Generate PDF labels for a specific order"""
print(f"DEBUG: generate_labels_pdf called for order_id: {order_id}")
@@ -1970,8 +2012,12 @@ def generate_labels_pdf(order_id):
print(f"DEBUG: Generating PDF for order {order_id} with quantity {order_data['cantitate']}")
# Generate PDF
pdf_buffer = generate_order_labels_pdf(order_id, order_data)
# Check if paper-saving mode is enabled (default: true)
use_paper_saving = paper_saving_mode.lower() == 'true'
print(f"DEBUG: Paper-saving mode: {use_paper_saving}")
# Generate PDF with paper-saving option
pdf_buffer = generate_order_labels_pdf(order_id, order_data, paper_saving_mode=use_paper_saving)
# Update printed status in database
update_success = update_order_printed_status(order_id)