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.0.tar.gz (4.4 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.0-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pyelevate-0.1.0.tar.gz
Algorithm Hash digest
SHA256 7cf1543119d759842912e75f68a5fbf8a1e476a934e6b7834d7a9db0c09e3818
MD5 6cf338b31717a7edc938f8b9a4b3f2c4
BLAKE2b-256 d75161eee363d2eafe1d499a133cfa06fa1de124fe3e69111c768d9b16b29d4a

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyelevate-0.1.0.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.0-py3-none-any.whl.

File metadata

  • Download URL: PyElevate-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for PyElevate-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c3bd7060567bf6d8e7760e0d67226d702bd784b49149475eb045a9d26a423573
MD5 84353f074fee51425e289246a8b3f110
BLAKE2b-256 846c2a1eeee0e70340eeea9ad6a98b7fb51be54777dd37d647ce30760e1a42c0

See more details on using hashes here.

Provenance

The following attestation bundles were made for PyElevate-0.1.0-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