Skip to main content

A cross-platform command launcher for administrator privileges.

Project description

py-admin-launch

A cross-platform Python command/helper to launch a specified program with administrator privileges.

Strategy

  • Linux desktop: pkexec for polkit GUI authentication, falling back to sudo when pkexec is not available.
  • Windows: ShellExecuteW(..., "runas", ...).
  • macOS: osascript + with administrator privileges, falling back to sudo when osascript is not available.

If the current process is already administrator/root, the command is launched directly as the current user.

CLI

Run from source:

python -m py_admin_launch -- your-command arg1 arg2

After installing the package:

py-admin-launch -- your-command arg1 arg2

Useful options:

py-admin-launch --wait --cwd /path/to/workdir -- your-command arg1 arg2

Python API

from py_admin_launch import launch

launch(["python", "-m", "http.server", "80"])

launch() accepts a command list plus optional cwd and wait arguments:

result = launch(["your-command", "arg1"], cwd="/tmp", wait=True)
print(result.elevated, result.returncode)

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

py_admin_launch-0.1.0.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

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

py_admin_launch-0.1.0-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: py_admin_launch-0.1.0.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.11.15 Windows/10

File hashes

Hashes for py_admin_launch-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8a0ddd0c082e030680b2c8a7df230ed27a1386307c89ee7c0c9fd96fa61c570e
MD5 bc6d4f8998b0f1fd0eb51de4a974708b
BLAKE2b-256 0a7463fc0ccd1995565616177b2525fb3320606c2035a5f6ff6cab44d30567fe

See more details on using hashes here.

File details

Details for the file py_admin_launch-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: py_admin_launch-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.11.15 Windows/10

File hashes

Hashes for py_admin_launch-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 affd61c715b746bca2000df6aa25992e126cef4853a7c49a57c2958fe66207ea
MD5 4833cbc8c10833ee9664693276fabc33
BLAKE2b-256 604f21894d1ae3850675c03ad5f83537722124d29211aa63c2e2998a23cd3f62

See more details on using hashes here.

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