add requests for arch linux

This commit is contained in:
2025-06-23 14:44:33 +02:00
parent 01bd6ab263
commit ed269af1d2
3 changed files with 431 additions and 428 deletions

View File

@ -3,12 +3,13 @@ import tkinter as tk
from tkinter import ttk
import os
import subprocess
import getpass
from datetime import datetime
import tempfile
import urllib.request
import zipfile
from manager import (
OSDetector,
Detector,
Theme,
LocaleStrings,
LXToolsAppConfig,
@ -75,14 +76,27 @@ class InstallationManager:
raise Exception(f"{LocaleStrings.MSGI["unknow_project"]}{project_key}")
def _create_wirepy_install_script(self):
detected_os = Detector.get_os()
if detected_os == "Arch Linux":
result_unzip = Detector.get_unzip()
result_wget = Detector.get_wget()
"""Create Wire-Py installation script"""
script = f"""#!/bin/bash
set -e
echo "=== Wire-Py Installation ==="
if [ "{detected_os}" = "Arch Linux" ]; then
if [ "{result_unzip}" = "False" ]; then
pacman -S --noconfirm unzip
fi
if [ "{result_wget}" = "False" ]; then
pacman -S --noconfirm wget
fi
fi
{LXToolsAppConfig.TKINTER_INSTALL_COMMANDS[detected_os]} 2>&1 | grep -v "apt does not have a stable CLI interface"
# Create necessary directories
mkdir -p /usr/local/share/shared_libs
mkdir -p {LXToolsAppConfig.SHARED_LIBS_DESTINATION[detected_os]}
mkdir -p /usr/share/icons/lx-icons
mkdir -p /usr/share/locale/de/LC_MESSAGES
mkdir -p /usr/share/applications
@ -118,7 +132,7 @@ done
# Install config
if [ -f "$WIREPY_DIR/wp_app_config.py" ]; then
cp -f "$WIREPY_DIR/wp_app_config.py" /usr/local/share/shared_libs/
cp -f "$WIREPY_DIR/wp_app_config.py" {LXToolsAppConfig.SHARED_LIBS_DESTINATION[detected_os]}/
echo "Installed wp_app_config.py"
fi
@ -126,15 +140,15 @@ fi
echo "Installing shared libraries..."
for file in common_tools.py message.py file_and_dir_ensure.py gitea.py __init__.py logview_app_config.py; do
if [ -f "$SHARED_DIR/$file" ]; then
cp -f "$SHARED_DIR/$file" /usr/local/share/shared_libs/
cp -f "$SHARED_DIR/$file" {LXToolsAppConfig.SHARED_LIBS_DESTINATION[detected_os]}/
echo "Installed shared lib: $file"
fi
done
# Install LogViewer executable
if [ -f "$SHARED_DIR/logviewer.py" ]; then
cp -f "$SHARED_DIR/logviewer.py" /usr/local/share/shared_libs/
chmod 755 /usr/local/share/shared_libs/logviewer.py
cp -f "$SHARED_DIR/logviewer.py" {LXToolsAppConfig.SHARED_LIBS_DESTINATION[detected_os]}/
chmod 755 {LXToolsAppConfig.SHARED_LIBS_DESTINATION[detected_os]}/logviewer.py
echo "Installed logviewer.py (executable)"
fi
@ -171,7 +185,7 @@ fi
# Create symlink for Wirepy
ln -sf /usr/local/bin/wirepy.py /usr/local/bin/wirepy
# Create symlink for LogViewer
ln -sf /usr/local/share/shared_libs/logviewer.py /usr/local/bin/logviewer
ln -sf {LXToolsAppConfig.SHARED_LIBS_DESTINATION[detected_os]}/logviewer.py /usr/local/bin/logviewer
echo "Created Wirepy and LogViewer symlink"
# Install language files if available
@ -197,14 +211,32 @@ echo "Wire-Py installation completed!"
return script
def _create_logviewer_install_script(self):
detected_os = Detector.get_os()
if detected_os == "Arch Linux":
result_unzip = Detector.get_unzip()
result_wget = Detector.get_wget()
result_requests = Detector.get_requests()
"""Create LogViewer installation script"""
script = f"""#!/bin/bash
set -e
{LXToolsAppConfig.TKINTER_INSTALL_COMMANDS[detected_os]} 2>&1 | grep -v "apt does not have a stable CLI interface"
echo "=== LogViewer Installation ==="
if [ "{detected_os}" = "Arch Linux" ]; then
if [ "{result_unzip}" = "False" ]; then
pacman -S --noconfirm unzip
fi
if [ "{result_wget}" = "False" ]; then
pacman -S --noconfirm wget
fi
if [ "{result_requests}" = "False" ]; then
pacman -S --noconfirm python-requests
fi
fi
# Create necessary directories
mkdir -p /usr/local/share/shared_libs
mkdir -p {LXToolsAppConfig.SHARED_LIBS_DESTINATION[detected_os]}
mkdir -p /usr/share/icons/lx-icons
mkdir -p /usr/share/locale/de/LC_MESSAGES
mkdir -p /usr/share/applications
@ -244,36 +276,21 @@ fi
echo "Installing shared libraries..."
for file in common_tools.py message.py file_and_dir_ensure.py gitea.py __init__.py logview_app_config.py; do
if [ -f "$SHARED_DIR/$file" ]; then
cp -f "$SHARED_DIR/$file" /usr/local/share/shared_libs/
cp -f "$SHARED_DIR/$file" {LXToolsAppConfig.SHARED_LIBS_DESTINATION[detected_os]}/
echo "Installed shared lib: $file"
fi
done
# Install LogViewer executable
if [ -f "$SHARED_DIR/logviewer.py" ]; then
cp -f "$SHARED_DIR/logviewer.py" /usr/local/share/shared_libs/
chmod 755 /usr/local/share/shared_libs/logviewer.py
cp -f "$SHARED_DIR/logviewer.py" {LXToolsAppConfig.SHARED_LIBS_DESTINATION[detected_os]}/
chmod 755 {LXToolsAppConfig.SHARED_LIBS_DESTINATION[detected_os]}/logviewer.py
echo "Installed logviewer.py (executable)"
fi
# Create LogViewer desktop file
cat > /usr/share/applications/LogViewer.desktop << 'EOF'
[Desktop Entry]
Version=1.0
Type=Application
Name=LogViewer
Comment=System Log Viewer
Exec=/usr/local/bin/logviewer
Icon=/usr/share/icons/lx-icons/48/log.png
Terminal=false
Categories=System;Utility;
StartupNotify=true
EOF
echo "Created LogViewer desktop file"
# Create symlink for LogViewer
ln -sf /usr/local/share/shared_libs/logviewer.py /usr/local/bin/logviewer
ln -sf {LXToolsAppConfig.SHARED_LIBS_DESTINATION[detected_os]}/logviewer.py /usr/local/bin/logviewer
echo "Created LogViewer symlink"
# Install language files if available
@ -393,8 +410,9 @@ class UninstallationManager:
raise Exception(f"{LocaleStrings.MSGO["unknow_project"]}{project_key}")
def _create_wirepy_uninstall_script(self):
detected_os = Detector.get_os()
"""Create Wire-Py uninstallation script"""
script = """#!/bin/bash
script = f"""#!/bin/bash
set -e
echo "=== Wire-Py Uninstallation ==="
@ -411,7 +429,7 @@ rm -f /usr/local/bin/wirepy
echo "Removed wirepy symlink"
# Remove config
rm -f /usr/local/share/shared_libs/wp_app_config.py
rm -f {LXToolsAppConfig.SHARED_LIBS_DESTINATION[detected_os]}/wp_app_config.py
echo "Removed wp_app_config.py"
# Remove desktop file
@ -427,13 +445,16 @@ rm -f /usr/share/locale/de/LC_MESSAGES/wirepy.mo
echo "Removed language files"
# Remove user config directory
if [ -d "$HOME/.config/wire_py" ]; then
rm -rf "$HOME/.config/wire_py"
if [ -d /home/{getpass.getuser()}/.config/wire_py ]; then
rm -rf /home/{getpass.getuser()}/.config/wire_py
echo "Removed user config directory"
fi
# Remove ssl private key
rm -rf /usr/local/etc/ssl
echo "Removed ssl private key"
# Remove log file
rm -f "$HOME/.local/share/lxlogs/wirepy.log"
rm -f /home/{getpass.getuser()}/.local/share/lxlogs/wirepy.log
echo "Removed log file"
# Check if LogViewer is still installed before removing shared resources
@ -441,15 +462,14 @@ if [ ! -f /usr/local/bin/logviewer ] || [ ! -L /usr/local/bin/logviewer ]; then
echo "No other LX apps found, removing shared resources..."
rm -rf /usr/share/icons/lx-icons
rm -rf /usr/share/TK-Themes
rm -rf /usr/local/etc/ssl
# Remove shared libs
for file in common_tools.py file_and_dir_ensure.py gitea.py __init__.py logview_app_config.py logviewer.py; do
rm -f /usr/local/share/shared_libs/$file
rm -f {LXToolsAppConfig.SHARED_LIBS_DESTINATION[detected_os]}/$file
done
# Try to remove shared_libs directory if empty
rmdir /usr/local/share/shared_libs 2>/dev/null || true
rmdir {LXToolsAppConfig.SHARED_LIBS_DESTINATION[detected_os]} 2>/dev/null || true
else
echo "LogViewer still installed, keeping shared resources"
fi
@ -459,8 +479,9 @@ echo "Wire-Py uninstallation completed!"
return script
def _create_logviewer_uninstall_script(self):
detected_os = Detector.get_os()
"""Create LogViewer uninstallation script"""
script = """#!/bin/bash
script = f"""#!/bin/bash
set -e
echo "=== LogViewer Uninstallation ==="
@ -469,22 +490,18 @@ echo "=== LogViewer Uninstallation ==="
rm -f /usr/local/bin/logviewer
echo "Removed logviewer symlink"
# Remove desktop file
rm -f /usr/share/applications/LogViewer.desktop
echo "Removed desktop file"
# Remove language files
rm -f /usr/share/locale/de/LC_MESSAGES/logviewer.mo
echo "Removed language files"
# Remove user config directory
if [ -d "$HOME/.config/logviewer" ]; then
rm -rf "$HOME/.config/logviewer"
if [ -d /home/{getpass.getuser()}/.config/logviewer ]; then
rm -rf /home/{getpass.getuser()}/.config/logviewer
echo "Removed user config directory"
fi
# Remove log file
rm -f "$HOME/.local/share/lxlogs/logviewer.log"
rm -f /home/{getpass.getuser()}/.local/share/lxlogs/logviewer.log
echo "Removed log file"
# Check if Wire-Py is still installed before removing shared resources
@ -495,19 +512,19 @@ if [ ! -f /usr/local/bin/wirepy ] || [ ! -L /usr/local/bin/wirepy ]; then
# Remove shared libs (but keep logviewer.py if we're only uninstalling logviewer)
for file in common_tools.py file_and_dir_ensure.py gitea.py __init__.py logview_app_config.py; do
rm -f /usr/local/share/shared_libs/$file
rm -f {LXToolsAppConfig.SHARED_LIBS_DESTINATION[detected_os]}/$file
done
# Remove logviewer.py last
rm -f /usr/local/share/shared_libs/logviewer.py
rm -f {LXToolsAppConfig.SHARED_LIBS_DESTINATION[detected_os]}/logviewer.py
# Try to remove shared_libs directory if empty
rmdir /usr/local/share/shared_libs 2>/dev/null || true
rmdir LXToolsAppConfig.SHARED_LIBS_DESTINATION[detected_os] 2>/dev/null || true
else
echo "Wire-Py still installed, keeping shared resources"
# Only remove logviewer-specific files
rm -f /usr/local/share/shared_libs/logview_app_config.py
rm -f /usr/local/share/shared_libs/logviewer.py
rm -f {LXToolsAppConfig.SHARED_LIBS_DESTINATION[detected_os]}/logview_app_config.py
rm -f {LXToolsAppConfig.SHARED_LIBS_DESTINATION[detected_os]}/logviewer.py
fi
echo "LogViewer uninstallation completed!"
@ -614,7 +631,7 @@ class LXToolsGUI:
self.image_manager = Image()
# Detect OS
self.detected_os = OSDetector.detect_os()
self.detected_os = Detector.get_os()
# Color scheme
self.colors = {
@ -746,8 +763,9 @@ class LXToolsGUI:
# Checks:
internet_ok = NetworkChecker.check_internet_connection()
repo_ok = NetworkChecker.check_repository_access()
result = Detector.get_host_python_version()
if internet_ok and repo_ok:
if internet_ok and repo_ok and result is not None:
self.update_header_status(LocaleStrings.MSGO["ready"], "#1abc9c") # Green
elif not internet_ok:
self.update_header_status(
@ -757,6 +775,10 @@ class LXToolsGUI:
self.update_header_status(
LocaleStrings.MSGO["repo_unavailable"], "#f39c12"
) # Orange
elif result is None:
self.update_header_status(
LocaleStrings.MSGO["python_check"], "#e74c3c"
) # Red
else:
self.update_header_status(
LocaleStrings.MSGO["system_check"], "#3498db"