From d59bdd07b01c38411272c9999f0f47cd3962f985 Mon Sep 17 00:00:00 2001 From: Philip Henning Date: Wed, 30 Oct 2019 20:23:54 +0100 Subject: [PATCH] Make (--help, --version, ...) work as non root - "root" check will be performed after arpaser - The help message will be automatically show when there are no root rights. Along to the notification that this program need root rights. --- embyupdater/__init__.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/embyupdater/__init__.py b/embyupdater/__init__.py index f1447b0..6ab5957 100644 --- a/embyupdater/__init__.py +++ b/embyupdater/__init__.py @@ -175,12 +175,6 @@ def updater(allow_prereleases, download_path, quiet): def main(): - if os.geteuid() != 0: - print('''You need to have root privileges to run this script. -Please try again, this time using 'sudo'. -Exiting.''', file=sys.stderr) - sys.exit(1) - parser = argparse.ArgumentParser( formatter_class=argparse.RawDescriptionHelpFormatter, description='emby-updater will help you to install Emby (updates) easily.', @@ -199,6 +193,19 @@ def main(): action='store_true') args = parser.parse_args() + if os.geteuid() != 0: + print(''' +########## +# You need to have root privileges to run this script. +# Please try again, this time using 'sudo'. +########## + +''', file=sys.stderr) + parser.print_help() + print(''' +Exiting.''', file=sys.stderr) + sys.exit(1) + if args.update: self_update(args.download_path, args.yes) else: