You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
1.3 KiB
Python

import os
import subprocess
class Apt:
env = os.environ.copy()
env['DEBIAN_FRONTEND'] = 'noninteractive'
@staticmethod
def install(packages: list):
subprocess.run(
['sudo', 'apt', 'install'] + packages + ['-y'],
env=Apt.env,
check=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE
)
@staticmethod
def remove(packages: list):
subprocess.run(
['sudo', 'apt', 'remove'] + packages + ['-y'],
env=Apt.env,
check=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE
)
@staticmethod
def purge(packages: list):
subprocess.run(
['sudo', 'apt', 'purge'] + packages + ['-y'],
env=Apt.env,
check=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE
)
@staticmethod
def update():
subprocess.run(
['sudo', 'apt', 'update'],
env=Apt.env,
check=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE
)
@staticmethod
def upgrade():
subprocess.run(
['sudo', 'apt', 'upgrade', '-y'],
env=Apt.env,
check=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE
)