Skip to content

Commit

Permalink
Make (--help, --version, ...) work as non root
Browse files Browse the repository at this point in the history
- "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.
  • Loading branch information
shokinn committed Oct 30, 2019
1 parent 9c3aaa7 commit d59bdd0
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions embyupdater/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.',
Expand All @@ -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:
Expand Down

0 comments on commit d59bdd0

Please sign in to comment.