move rpm methods into rpm.py

parent cdfe8f2f
......@@ -32,6 +32,7 @@ import tempfile
from . import (
__version__,
koji,
rpm,
)
from .build import build_src_rpm
from .utils import source_type
......@@ -142,17 +143,6 @@ def parse_options():
return args
# method to get the package name from the source
def get_package_name_from_source_rpm(source):
try:
cmd = ['rpm', '--queryformat', '%{NAME}', '-qp', source]
pkg_name = subprocess.check_output(cmd)
except subprocess.CalledProcessError as e:
print('Unable to determine package name, %s' % e)
sys.exit(1)
return pkg_name.decode()
#
# main program
#
......@@ -187,10 +177,14 @@ def main():
logger.info("temporary src.rpm generated as '{0}'".format(args.source))
# get pkg name from source rpm
try:
if args.source_type != "git":
pkg_name = get_package_name_from_source_rpm(args.source)
pkg_name = rpm.get_package_name_from_source_rpm(args.source)
logger.info('package name = %s' % pkg_name)
# how do we determine this when source is from git?
except subprocess.CalledProcessError as e:
logger.critical("unable to determine package name, %s" % e)
raise
# check that we can authenticate to koji
try:
......
# -*- coding: utf-8 -*-
# Copyright(C) 2019 Adam Mercer <adam.mercer@ligo.org>
#
# This file is part of gwkoji.
#
# gwkoji 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/>.
"""Interactions with rpm
"""
import subprocess
# method to get the package name from the source
def get_package_name_from_source_rpm(source):
cmd = ['rpm', '--queryformat', '%{NAME}', '-qp', source]
return subprocess.check_output(cmd).decode()
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