mirror of
https://github.com/Foltik/dotfiles
synced 2024-11-24 04:22:50 -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():
|
||||
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):
|
||||
pacman('-S ' + package)
|
||||
output = pacman(['-S', package], True)
|
||||
|
||||
def install_all(packages):
|
||||
output = pacman(['-S'] + packages, True)
|
||||
|
||||
def pacman(flags, sudo = False):
|
||||
cmd = ['sudo', 'pacman'] if sudo else ['pacman']
|
||||
cmd += ['--noconfirm', flags]
|
||||
proc = subprocess.Popen(cmd, stderr=subprocess.PIPE, stdout=subprocess.PIPE, stdin=subprocess.PIPE)
|
||||
data = proc.communicate()
|
||||
|
||||
if proc.returncode != 0:
|
||||
raise Exception('Command ' + ' '.join(cmd) + ' failed: ' + data[1].decode())
|
||||
|
||||
return data[0].decode()
|
||||
|
||||
cmd = ['pacman', '--noconfirm'] + flags
|
||||
subproc = proc.sudo(cmd) if sudo else proc.exec(cmd)
|
||||
return proc.communicate(subproc, cmd)
|
||||
|
Loading…
Reference in New Issue
Block a user