Created
March 31, 2020 11:52
-
-
Save GreatBahram/c8644026f5feb520f78ffa6422a5d969 to your computer and use it in GitHub Desktop.
Revisions
-
GreatBahram revised this gist
Mar 31, 2020 . No changes.There are no files selected for viewing
-
GreatBahram created this gist
Mar 31, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ import os from functools import wraps def sudo_required(func): """Check sudo permission, if it hasn't, it'll exit non-zero.""" @wraps(func) def wrapper(*args, **kwargs): if os.getuid() != 0: print("Sudo access is required!", file=sys.stderr) raise SystemExit(1) return func(*args, **kwargs) return wrapper