Verified Commit 48ea21f5 authored by Adam Mercer's avatar Adam Mercer
Browse files

move check and register into method

parent 9dc339e4
......@@ -240,6 +240,35 @@ def get_package_name_from_source_rpm(source):
return pkg_name.decode()
def check_and_register_package(args, pkg_name):
# determine if the package is already registered with koji
if args.source_type != "git":
try:
cmd = ['koji', 'list-pkgs', '--quiet', '--package', pkg_name]
subprocess.check_call(cmd, stdout=subprocess.DEVNULL,
stderr=subprocess.STDOUT)
if args.verbose:
print('%s is already registered with koji' % pkg_name)
return
except subprocess.CalledProcessError:
pass
# register package with koji
try:
if args.owner is None:
print('owner not specified')
sys.exit(1)
cmd = ['koji', 'add-pkg', args.owner, pkg_name]
subprocess.check_call(cmd, stdout=subprocess.DEVNULL,
stderr=subprocess.STDOUT)
if args.verbose:
print('%s successfully registered with koji' % pkg_name)
except subprocess.CalledProcessError as e:
print('error registering package: %s' % e)
sys.exit(1)
return
#
# main program
#
......@@ -278,26 +307,8 @@ def main():
# check that we can authenticate to koji
check_connection_to_koji()
# determine if the package is already registered with koji
if args.source_type != "git":
try:
cmd = ['koji', 'list-pkgs', '--quiet', '--package', pkg_name]
subprocess.check_call(cmd, stdout=subprocess.DEVNULL,
stderr=subprocess.STDOUT)
except subprocess.CalledProcessError:
pass
# register package with koji
try:
if args.owner is None:
print('owner not specified')
sys.exit(1)
cmd = ['koji', 'add-pkg', args.owner, pkg_name]
subprocess.check_call(cmd, stdout=subprocess.DEVNULL,
stderr=subprocess.STDOUT)
except subprocess.CalledProcessError as e:
print('error registering package: %s' % e)
sys.exit(1)
# register package with koji
check_and_register_package(args, pkg_name)
#
......
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