From 9089caa191c96ed2961b55404e566ca8f3842053 Mon Sep 17 00:00:00 2001 From: Ghost <62809003+Ghost6446@users.noreply.github.com> Date: Sat, 10 Feb 2024 08:29:31 +0100 Subject: [PATCH] dont check all time admin --- Src/Util/FFmpeg/installer.py | 13 +++++++++++++ run.py | 16 ---------------- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/Src/Util/FFmpeg/installer.py b/Src/Util/FFmpeg/installer.py index 108ecdc..7474b39 100644 --- a/Src/Util/FFmpeg/installer.py +++ b/Src/Util/FFmpeg/installer.py @@ -6,6 +6,14 @@ from Src.Util.Helper.console import console # Import import subprocess, os, requests, zipfile, sys +import ctypes, os, sys + +def isAdmin(): + try: + is_admin = (os.getuid() == 0) + except AttributeError: + is_admin = ctypes.windll.shell32.IsUserAnAdmin() != 0 + return is_admin def download_ffmpeg(): @@ -43,6 +51,11 @@ def check_ffmpeg(): except: try: console.print("[cyan]FFmpeg is not in the PATH. Downloading and adding to the PATH...[/cyan]") + + if not isAdmin(): + console.log("[red]You need to be admin to proceed!") + sys.exit(0) + download_ffmpeg() sys.exit(0) # Exit except: diff --git a/run.py b/run.py index 2e73679..ce6ca7b 100644 --- a/run.py +++ b/run.py @@ -1,21 +1,5 @@ # 10.12.23 -> 31.01.24 -# From https://raccoon.ninja/en/dev/using-python-to-check-if-the-application-is-running-as-an-administrator/ -import ctypes, os, sys - -def isAdmin(): - try: - is_admin = (os.getuid() == 0) - except AttributeError: - is_admin = ctypes.windll.shell32.IsUserAnAdmin() != 0 - return is_admin - -if not isAdmin(): - print("You need to be admin to proceed!") - sys.exit() -else: - print("You're admin! Let's start!") - # Class import import Src.Api.page as Page from Src.Api.film import main_dw_film as download_film