Commit d2d7f92a authored by Nigel Kukard's avatar Nigel Kukard
Browse files

Added pacman support class

parent 4a76711c
# Copyright (c) 2019, AllWorldIT
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
"""Support class for pacman."""
from typing import List
from .asyncsubprocess import AsyncSubprocess
class Pacman:
"""The Pacman class handles running pacman."""
def __init__(self):
"""Initialize our class."""
def get_group_packages(self, group: str) -> List[str]:
"""Get packages from a group."""
# Run pacman
proc = AsyncSubprocess(['pacman', '-Sg', group])
output = proc.run()
# Raise an exception if we didn't get a positive response back
if proc.retcode != 0:
raise OSError(f'Failed to run pacman, return code {proc.retcode}: {output}')
# Return package list, which is the second item in the split
return [x.split()[1] for x in output]
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment