Skip to content

Commit

Permalink
Don't blow up in the decorator if not on Windows; just run the functi…
Browse files Browse the repository at this point in the history
…on even if not root.
  • Loading branch information
Preston-Landers committed Nov 8, 2020
1 parent 72aab6b commit 03b36a4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Changes

## 0.0.1
## 0.0.2

- Initial package release based on a cleaned up version of my Gist originally published here:
- Initial public release of a package based on a cleaned up version of my Gist that
was originally published here:

https://gist.github.com/Preston-Landers/267391562bc96959eb41

Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# PyUAC - Python User Access Control
# PyUAC - Python User Access Control for Windows

This package provides a way to invoke User Access Control (UAC) in Windows from Python.

Expand All @@ -22,7 +22,9 @@ See also [tests/example_usage.py](tests/example_usage.py)
### Decorator

The decorator is an easy way to ensure your script's main() function will respawn itself
as Admin if necessary.
as Admin if necessary. Note that the decorator has no effect unless on the Windows platform.
It does NOT currently relaunch the script with 'sudo' on Linux or other POSIX platforms.
On non-Windows platforms, it's a no-op.

#### Decorator usage example

Expand Down
3 changes: 3 additions & 0 deletions pyuac/decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ def main_requires_admin(
If return_output is True, the output of the decorated function is a 2-tuple
of (stdout, stderr) strings.
"""
if os.name != 'nt':
log.debug("Invoked main_requires_admin on a non-Windows platform; doing nothing!")
return run_function(*args, **kwargs)

# Should we add another function parameter to run the in the "not-admin" case?

Expand Down

0 comments on commit 03b36a4

Please sign in to comment.