Skip to content

Commit

Permalink
Make it easy to test contexts for superuser privileges
Browse files Browse the repository at this point in the history
  • Loading branch information
xolox committed Apr 13, 2016
1 parent f8b8ad8 commit 90bde8f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions executor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Programmer friendly subprocess wrapper.
#
# Author: Peter Odding <peter@peterodding.com>
# Last Change: April 9, 2016
# Last Change: April 13, 2016
# URL: https://executor.readthedocs.org

"""
Expand Down Expand Up @@ -64,7 +64,7 @@
unicode = str

# Semi-standard module versioning.
__version__ = '9.7'
__version__ = '9.8'

# Initialize a logger.
logger = logging.getLogger(__name__)
Expand Down
8 changes: 7 additions & 1 deletion executor/contexts.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Programmer friendly subprocess wrapper.
#
# Author: Peter Odding <peter@peterodding.com>
# Last Change: April 9, 2016
# Last Change: April 13, 2016
# URL: https://executor.readthedocs.org

r"""
Expand Down Expand Up @@ -284,6 +284,12 @@ def start_interactive_shell(self, **options):
cmd.start()
return cmd

@property
def have_superuser_privileges(self):
""":data:`True` if the context has superuser privileges, :data:`False` otherwise."""
prototype = self.prepare('true')
return prototype.have_superuser_privileges or prototype.sudo

@property
def cpu_count(self):
"""
Expand Down

0 comments on commit 90bde8f

Please sign in to comment.