mirror of
https://github.com/Foltik/dotfiles
synced 2024-11-27 21:19:51 -05:00
Refactor pacman for new proc stuff
This commit is contained in:
parent
38364ab681
commit
40edbf18fe
@ -1,19 +1,15 @@
|
|||||||
import subprocess
|
import lib.proc as proc
|
||||||
|
|
||||||
def get_installed():
|
def get_installed():
|
||||||
return [line.split(' ')[0] for line in pacman('-Q').split('\n')[:-1]]
|
return [line.split(' ')[0] for line in pacman(['-Q']).split('\n')[:-1]]
|
||||||
|
|
||||||
def install(package):
|
def install(package):
|
||||||
pacman('-S ' + package)
|
output = pacman(['-S', package], True)
|
||||||
|
|
||||||
|
def install_all(packages):
|
||||||
|
output = pacman(['-S'] + packages, True)
|
||||||
|
|
||||||
def pacman(flags, sudo = False):
|
def pacman(flags, sudo = False):
|
||||||
cmd = ['sudo', 'pacman'] if sudo else ['pacman']
|
cmd = ['pacman', '--noconfirm'] + flags
|
||||||
cmd += ['--noconfirm', flags]
|
subproc = proc.sudo(cmd) if sudo else proc.exec(cmd)
|
||||||
proc = subprocess.Popen(cmd, stderr=subprocess.PIPE, stdout=subprocess.PIPE, stdin=subprocess.PIPE)
|
return proc.communicate(subproc, cmd)
|
||||||
data = proc.communicate()
|
|
||||||
|
|
||||||
if proc.returncode != 0:
|
|
||||||
raise Exception('Command ' + ' '.join(cmd) + ' failed: ' + data[1].decode())
|
|
||||||
|
|
||||||
return data[0].decode()
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user