prevent empty env

main
mirkobrombin 2 years ago
parent e4d66fce62
commit bb2fdfe36f

@ -1,13 +1,17 @@
import os
import subprocess import subprocess
class Apt: class Apt:
env = os.environ.copy()
env['DEBIAN_FRONTEND'] = 'noninteractive'
@staticmethod @staticmethod
def install(packages: list): def install(packages: list):
subprocess.run( subprocess.run(
['sudo', 'apt', 'install'] + packages + ['-y'], ['sudo', 'apt', 'install'] + packages + ['-y'],
env={'DEBIAN_FRONTEND': 'noninteractive'}, env=Apt.env,
check=True check=True
) )
@ -15,7 +19,7 @@ class Apt:
def remove(packages: list): def remove(packages: list):
subprocess.run( subprocess.run(
['sudo', 'apt', 'remove'] + packages + ['-y'], ['sudo', 'apt', 'remove'] + packages + ['-y'],
env={'DEBIAN_FRONTEND': 'noninteractive'}, env=Apt.env,
check=True check=True
) )
@ -23,7 +27,7 @@ class Apt:
def purge(packages: list): def purge(packages: list):
subprocess.run( subprocess.run(
['sudo', 'apt', 'purge'] + packages + ['-y'], ['sudo', 'apt', 'purge'] + packages + ['-y'],
env={'DEBIAN_FRONTEND': 'noninteractive'}, env=Apt.env,
check=True check=True
) )
@ -31,7 +35,7 @@ class Apt:
def update(): def update():
subprocess.run( subprocess.run(
['sudo', 'apt', 'update'], ['sudo', 'apt', 'update'],
env={'DEBIAN_FRONTEND': 'noninteractive'}, env=Apt.env,
check=True check=True
) )
@ -39,6 +43,6 @@ class Apt:
def upgrade(): def upgrade():
subprocess.run( subprocess.run(
['sudo', 'apt', 'upgrade', '-y'], ['sudo', 'apt', 'upgrade', '-y'],
env={'DEBIAN_FRONTEND': 'noninteractive'}, env=Apt.env,
check=True check=True
) )

Loading…
Cancel
Save