Skip to main content

Python library for requesting root privileges

Project description

Elevate: Request Root Privileges

PyElevate is a small Python library that re-launches the current process with
root/admin. This is essentially a fork of BarneyGale's Elevate with some of the pull requests applied.

Usage

To use, call PyElevate.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).

There is also an elevated() function to check if the program is elevated.
This will output a boolean value, with True meaning the program is elevated and False meaning it's not.

from PyElevate import elevate, elevated

if not elevated():
    input("Before: " + str(elevated()) + "\nPress enter to elevate")

elevate()

input("After:" + str(elevated()) + "\nPress enter to elevate")
exit(0)

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).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyelevate-0.1.2.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyelevate-0.1.2-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

Details for the file pyelevate-0.1.2.tar.gz.

File metadata

  • Download URL: pyelevate-0.1.2.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pyelevate-0.1.2.tar.gz
Algorithm Hash digest
SHA256 60b3b581e3735f83344e9d2d453592e05c36655d1dfad0024097ed38dbdcf7d6
MD5 42b484a46b1cac1a36b88b19799e69be
BLAKE2b-256 a883ce507743f25c5f5aed23c59d9eab4a8e3f0729e8ac436990cab13a9eb03c

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyelevate-0.1.2.tar.gz:

Publisher: python-publish.yml on gabrielzv1233/PyElevate

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyelevate-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: pyelevate-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 5.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pyelevate-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 abac5a164bc496d802a55975f003813e369ffe3d3a03a3f2bbedc69b080c75fb
MD5 9a48b5c81b9b65e8730be3903f98787b
BLAKE2b-256 1a19e60620564d1e18e7b78303f1e7dee84fd23c55c4dbd15c08a5957cc6aa3b

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyelevate-0.1.2-py3-none-any.whl:

Publisher: python-publish.yml on gabrielzv1233/PyElevate

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page