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 #!/usr/bin/env python3
from subprocess import call, DEVNULL from subprocess import run, DEVNULL, PIPE
PACKAGES = [ PACKAGES = [
"python3-defusedxml", "python3-defusedxml",
...@@ -13,14 +13,19 @@ PACKAGES = [ ...@@ -13,14 +13,19 @@ PACKAGES = [
def main(): def main():
for pkg in PACKAGES: for pkg in PACKAGES:
if call( if run(
["/usr/bin/dpkg", "-s", pkg], shell=False, stdout=DEVNULL, stderr=DEVNULL ["/usr/bin/dpkg", "-s", pkg],
): shell=False,
result = call( stdout=DEVNULL,
["/usr/bin/apt", "install", pkg], stderr=DEVNULL,
stdin=PIPE,
).returncode != 0:
result = run(
["/usr/bin/apt", "install", "-y", pkg],
shell=False, shell=False,
stdout=DEVNULL, stdout=DEVNULL,
stderr=DEVNULL, stderr=DEVNULL,
stdin=PIPE,
) )
if not result: if not result:
print("{} install succeeded".format(pkg)) 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