Elevate: Request root privileges
================================
Elevate is a small Python library that re-launches the current process with
root/admin privileges using one of the following mechanisms:
- UAC (Windows)
- AppleScript (macOS)
- ``pkexec``, ``gksudo`` or ``kdesudo`` (Linux)
- ``sudo`` (Linux, macOS)
Usage
-----
To use, call ``elevate.elevate()`` early in your script. When run as root this
function does nothing. When not run as root, this function replaces the current
process (Linux, macOS) or creates a new process, waits, and exits (Windows).
Consider the following example:
.. code-block:: python
import os
from elevate import elevate
def is_root():
return os.getuid() == 0
print("before ", is_root())
elevate()
print("after ", is_root())
This prints::
before False
before True
after True
On Windows, the new process's standard streams are not attached to the parent,
which is an inherent limitation of UAC. By default the new process runs in a
new console window. To suppress this window, use
``elevate(show_console=False)``.
On Linux and macOS, graphical prompts are tried before ``sudo`` by default. To
prevent graphical prompts, use ``elevate(graphical=False)``.
Raw data
{
"_id": null,
"home_page": "https://github.com/barneygale/elevate",
"name": "elevate",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "",
"author": "Barney Gale",
"author_email": "barney.gale@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/81/32/29ba61063ac124632754e26c65e71217f48ce682fbf8762ee9a0bb0d32de/elevate-0.1.3.tar.gz",
"platform": "",
"description": "Elevate: Request root privileges\n================================\n\nElevate is a small Python library that re-launches the current process with\nroot/admin privileges using one of the following mechanisms:\n\n- UAC (Windows)\n- AppleScript (macOS)\n- ``pkexec``, ``gksudo`` or ``kdesudo`` (Linux)\n- ``sudo`` (Linux, macOS)\n\nUsage\n-----\n\nTo use, call ``elevate.elevate()`` early in your script. When run as root this\nfunction does nothing. When not run as root, this function replaces the current\nprocess (Linux, macOS) or creates a new process, waits, and exits (Windows).\nConsider the following example:\n\n.. code-block:: python\n\n import os\n from elevate import elevate\n\n def is_root():\n return os.getuid() == 0\n\n print(\"before \", is_root())\n elevate()\n print(\"after \", is_root())\n\nThis prints::\n\n before False\n before True\n after True\n\nOn Windows, the new process's standard streams are not attached to the parent,\nwhich is an inherent limitation of UAC. By default the new process runs in a\nnew console window. To suppress this window, use\n``elevate(show_console=False)``.\n\nOn Linux and macOS, graphical prompts are tried before ``sudo`` by default. To\nprevent graphical prompts, use ``elevate(graphical=False)``.",
"bugtrack_url": null,
"license": "MIT",
"summary": "Python library for requesting root privileges",
"version": "0.1.3",
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"md5": "33d07ae9cc2f280415179d1075e3e9e2",
"sha256": "53ad19fa1de301fb1de3f8768fb3a5894215716fd96a475690c4d0ff3b1de209"
},
"downloads": -1,
"filename": "elevate-0.1.3.tar.gz",
"has_sig": false,
"md5_digest": "33d07ae9cc2f280415179d1075e3e9e2",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 2897,
"upload_time": "2018-05-22T20:28:25",
"upload_time_iso_8601": "2018-05-22T20:28:25.225762Z",
"url": "https://files.pythonhosted.org/packages/81/32/29ba61063ac124632754e26c65e71217f48ce682fbf8762ee9a0bb0d32de/elevate-0.1.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2018-05-22 20:28:25",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "barneygale",
"github_project": "elevate",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "elevate"
}