From ef893d601d3b5e6a6242310712f3e61c34fc309f Mon Sep 17 00:00:00 2001 From: daboynb <106079917+daboynb@users.noreply.github.com> Date: Fri, 9 Feb 2024 01:15:18 +0100 Subject: [PATCH] Update run.py Added an admin check, otherwise the script will always fail if launched by a normal user when attempting to add ffmpeg to the system path --- run.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/run.py b/run.py index ce6ca7b..2e73679 100644 --- a/run.py +++ b/run.py @@ -1,5 +1,21 @@ # 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