Skip to content
Snippets Groups Projects
Commit b6351ed7 authored by Stéphane Diemer's avatar Stéphane Diemer
Browse files

Avoid prompting user in packages check

parent 6e029157
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/env python3
from subprocess import call, DEVNULL
from subprocess import run, DEVNULL, PIPE
PACKAGES = [
"python3-defusedxml",
......@@ -13,14 +13,19 @@ PACKAGES = [
def main():
for pkg in PACKAGES:
if call(
["/usr/bin/dpkg", "-s", pkg], shell=False, stdout=DEVNULL, stderr=DEVNULL
):
result = call(
["/usr/bin/apt", "install", pkg],
if run(
["/usr/bin/dpkg", "-s", pkg],
shell=False,
stdout=DEVNULL,
stderr=DEVNULL,
stdin=PIPE,
).returncode != 0:
result = run(
["/usr/bin/apt", "install", "-y", pkg],
shell=False,
stdout=DEVNULL,
stderr=DEVNULL,
stdin=PIPE,
)
if not result:
print("{} install succeeded".format(pkg))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment