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

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyelevate-0.1.1.tar.gz
  • Upload date:
  • Size: 4.5 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.1.tar.gz
Algorithm Hash digest
SHA256 f3b24e56c24d7248227e269d9c5edfa2e243534a20188cc319e25ba1928a5edd
MD5 7a23e80b80890c5e9c2e851187d1cb44
BLAKE2b-256 541438564f859c89002a8af16b9a3fae5a19a1b3f278fade3acd2fb17f47147a

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: PyElevate-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6779ca20d8a09d26aef14713be55a04265ea5f4270678b6997677161739f9e70
MD5 96d7922de30e24c847539f5d820bb390
BLAKE2b-256 f2354f31d037e8e3fbca6d3b3bcba78ef0853faece4cdde9906206dc3f2f5993

See more details on using hashes here.

Provenance

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