A Python class to handle executing system commands using sudo
Project description
configure_with_sudo
Description
A Python module to handle executing system commands using sudo.
Usage
Extend GenericConfigure
, setting at a minimum an appropriate argv
command & argument list.
Example
The following class will check if pip
is installed and, if not, install it system-wide using sudo easy_install pip
:
from configure_with_sudo import GenericConfigure
class InstallPip(GenericConfigure):
def __init__(self, user="root", kill_sudo_cred=True):
# Initial argv is simply to check if 'pip' is installed
argv = ["/usr/local/bin/pip", "-V"]
super(InstallPip, self).__init__(
argv, use_sudo=True, kill_sudo_cred=kill_sudo_cred)
try:
# Execute to check if pip is already installed
# if it is, self.configured will be set to True
# and subsequent calls to execute() will do nothing
self.execute(use_sudo=False)
except Exception:
# If pip -V failed, assume pip is not installed.
# Replace self.argv with the installation command.
self.argv = ["/usr/bin/easy_install", "pip"]
pip_installer = InstallPip()
pip_installer.execute()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for configure_with_sudo-0.1.0.dev1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5967b014dc37f9f8c5679099f98dfc1f17bffac38648b361e7cf2d7f82c74a5f |
|
MD5 | 41ceb6a46a45bd35c5f2b8a9840e5456 |
|
BLAKE2b-256 | b4a2d8a4fd774d3e7b8dc9a5dcb2e514b5fbe9126035d96a223a2956edb048ec |
Close
Hashes for configure_with_sudo-0.1.0.dev1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bcb1722d3e17079daeadbb123bdc41f706d2f1e63d017f00ee51a6375962ff66 |
|
MD5 | 03c1fdd013d328744f6edbc9866406c6 |
|
BLAKE2b-256 | 8804d0203e556c2067720f519932c3446522e322ce09dae2a7ed0ee2d9aa59ab |