Refactor: Move modules to module package, translate messages to English, and update main runner

This commit is contained in:
2026-09-01 16:11:06 +03:30
parent bafae4b212
commit 51585dbe52
9 changed files with 109 additions and 96 deletions

1
module/__init__.py Normal file
View File

@@ -0,0 +1 @@
# Module package

View File

@@ -0,0 +1,63 @@
import os
import shutil
def get_non_c_drive() -> str:
"""
Find the first available non-C drive on the target system.
"""
possible_drives = [f"{letter}:\\" for letter in "DEFGH"]
for drive in possible_drives:
if os.path.exists(drive):
return drive
return r"C:\\"
def setup_directories_and_copy(source_dir: str = r"C:\SoftwareNP",
target_drive: str = None) -> str:
"""
Create directories on a non-C drive and copy files from source to NovinSoft.
"""
if not target_drive:
base_drive = get_non_c_drive()
else:
base_drive = target_drive
# Base target directory set to NovinPardazOne
base_target_dir = os.path.join(base_drive, "NovinPardazOne")
acc_dir = os.path.join(base_target_dir, "NovinAcc")
soft_dir = os.path.join(base_target_dir, "NovinSoft")
print(f"[+] Selected target drive: {base_drive}")
print(f"[+] Creating directory structure at {base_target_dir} ...")
# Create NovinAcc and NovinSoft directories
os.makedirs(acc_dir, exist_ok=True)
os.makedirs(soft_dir, exist_ok=True)
print(" [+] NovinAcc and NovinSoft directories created successfully.")
# Copy contents of source directory to NovinSoft
if os.path.exists(source_dir):
print(f"[+] Copying files from {source_dir} to {soft_dir} ...")
for item in os.listdir(source_dir):
s = os.path.join(source_dir, item)
d = os.path.join(soft_dir, item)
if os.path.isdir(s):
shutil.copytree(s, d, dirs_exist_ok=True)
else:
shutil.copy2(s, d)
print(f" [+] All files copied successfully to {soft_dir}.")
return soft_dir
else:
raise FileNotFoundError(f"[-] Source directory not found at {source_dir}!")
if __name__ == "__main__":
os.system("chcp 65001 > nul")
print("[+] Testing directory creation and software copy module ...")
try:
target_path = setup_directories_and_copy(target_drive=r"D:\\")
print(f"\n[+] Operation completed successfully. Software path: {target_path}")
except Exception as e:
print(f"\n[-] Error: {e}")

50
module/extract_acc.py Normal file
View File

@@ -0,0 +1,50 @@
import os
import shutil
import zipfile
def extract_acc_archive(base_drive: str = r"D:\\") -> str:
# Base directory set to NovinPardazOne
base_dir = os.path.join(base_drive, "NovinPardazOne")
soft_dir = os.path.join(base_dir, "NovinSoft")
acc_dir = os.path.join(base_dir, "NovinAcc")
target_zip_name = "NovinAcc.zip"
source_zip_path = os.path.join(soft_dir, target_zip_name)
target_zip_path = os.path.join(acc_dir, target_zip_name)
# 1. Check if NovinSoft directory exists
if not os.path.exists(soft_dir):
raise FileNotFoundError(f"[-] Directory not found: {soft_dir}")
# 2. Check if zip file exists
if not os.path.exists(source_zip_path):
raise FileNotFoundError(f"[-] File {target_zip_name} was not found in {soft_dir}!")
# 3. Create NovinAcc directory if it doesn't exist
os.makedirs(acc_dir, exist_ok=True)
# 4. Move zip file to NovinAcc
print(f"[+] Moving {target_zip_name} to NovinAcc directory...")
shutil.move(source_zip_path, target_zip_path)
print(" [+] Zip file moved successfully.")
# 5. Extract archive
print(f"[+] Extracting archive to {acc_dir}...")
with zipfile.ZipFile(target_zip_path, 'r') as zip_ref:
zip_ref.extractall(acc_dir)
print(" [+] All files extracted successfully.")
# 6. Remove temporary zip file
if os.path.exists(target_zip_path):
os.remove(target_zip_path)
print(" [+] Temporary zip file deleted.")
return acc_dir
if __name__ == "__main__":
os.system("chcp 65001 > nul")
print("[+] Running move and extract module ...")
try:
extract_acc_archive(base_drive=r"D:\\")
except Exception as e:
print(f"[-] Error: {e}")

View File

@@ -0,0 +1,71 @@
import os
import zipfile
import subprocess
import time
def install_novindesk(base_drive: str = r"D:\\") -> str:
"""
Extract and automatically install NovinDesk by navigating the installer UI.
"""
base_dir = os.path.join(base_drive, "NovinPardazOne")
soft_dir = os.path.join(base_dir, "NovinSoft")
zip_filename = "NovinDesk.zip"
source_zip_path = os.path.join(soft_dir, zip_filename)
extract_target_dir = os.path.join(soft_dir, "NovinDesk")
if not os.path.exists(source_zip_path):
raise FileNotFoundError(f"[-] File {zip_filename} was not found in {soft_dir}!")
os.makedirs(extract_target_dir, exist_ok=True)
print(f"[+] Extracting {zip_filename} ...")
with zipfile.ZipFile(source_zip_path, 'r') as zip_ref:
zip_ref.extractall(extract_target_dir)
print(" [+] Extraction completed successfully.")
exe_file = None
for root, dirs, files in os.walk(extract_target_dir):
for file in files:
if file.lower().endswith(".exe"):
exe_file = os.path.join(root, file)
break
if not exe_file:
raise FileNotFoundError("[-] No executable file (.exe) found!")
print(f"[+] Launching installer {os.path.basename(exe_file)} ...")
# Launch application for installation
subprocess.Popen([exe_file, "--install"])
# Wait 5 seconds for the window to fully load
time.sleep(5)
try:
import pyautogui
# 1. Close any secondary/side dialogs
pyautogui.press('escape')
time.sleep(0.5)
# 2. Press Tab 4 times to navigate directly to the 'Accept & Install' button
for _ in range(4):
pyautogui.press('tab')
time.sleep(0.2)
# 3. Press Enter on the install button
pyautogui.press('enter')
print(" [+] Confirmation sent and automated installation started.")
except Exception as err:
print(f" [-] Automation error: {err}")
return exe_file
if __name__ == "__main__":
os.system("chcp 65001 > nul")
print("[+] Running NovinDesk installation module ...")
try:
install_novindesk(base_drive=r"D:\\")
except Exception as e:
print(f"[-] Error: {e}")