cli: drop unneeded activate_session
Fixes: https://pagure.io/koji/issue/2070
This commit is contained in:
parent
c4b5316cba
commit
637be55ef4
9 changed files with 101 additions and 86 deletions
|
|
@ -35,6 +35,7 @@ from koji_cli.lib import (
|
|||
download_archive,
|
||||
download_file,
|
||||
download_rpm,
|
||||
ensure_connection,
|
||||
error,
|
||||
format_inheritance_flags,
|
||||
get_usage_str,
|
||||
|
|
@ -932,7 +933,7 @@ def anon_handle_mock_config(goptions, session, args):
|
|||
parser.add_option("--yum-proxy", help=_("Specify a yum proxy"))
|
||||
parser.add_option("-o", metavar="FILE", dest="ofile", help=_("Output to a file"))
|
||||
(options, args) = parser.parse_args(args)
|
||||
activate_session(session, goptions)
|
||||
ensure_connection(session)
|
||||
if args:
|
||||
# for historical reasons, we also accept buildroot name as first arg
|
||||
if not options.name:
|
||||
|
|
@ -2349,7 +2350,7 @@ def anon_handle_latest_build(goptions, session, args):
|
|||
(options, args) = parser.parse_args(args)
|
||||
if len(args) == 0:
|
||||
parser.error(_("A tag name must be specified"))
|
||||
activate_session(session, goptions)
|
||||
ensure_connection(session)
|
||||
if options.all:
|
||||
if len(args) > 1:
|
||||
parser.error(_("A package name may not be combined with --all"))
|
||||
|
|
@ -2417,7 +2418,7 @@ def anon_handle_list_api(goptions, session, args):
|
|||
(options, args) = parser.parse_args(args)
|
||||
if len(args) != 0:
|
||||
parser.error(_("This command takes no arguments"))
|
||||
activate_session(session, goptions)
|
||||
ensure_connection(session)
|
||||
for x in sorted(session._listapi(), key=lambda x: x['name']):
|
||||
if 'argdesc' in x:
|
||||
args = x['argdesc']
|
||||
|
|
@ -2463,7 +2464,7 @@ def anon_handle_list_tagged(goptions, session, args):
|
|||
parser.error(_("A tag name must be specified"))
|
||||
elif len(args) > 2:
|
||||
parser.error(_("Only one package name may be specified"))
|
||||
activate_session(session, goptions)
|
||||
ensure_connection(session)
|
||||
pathinfo = koji.PathInfo()
|
||||
package = None
|
||||
if len(args) > 1:
|
||||
|
|
@ -2562,7 +2563,7 @@ def anon_handle_list_buildroot(goptions, session, args):
|
|||
(options, args) = parser.parse_args(args)
|
||||
if len(args) != 1:
|
||||
parser.error(_("Incorrect number of arguments"))
|
||||
activate_session(session, goptions)
|
||||
ensure_connection(session)
|
||||
buildrootID = int(args[0])
|
||||
opts = {}
|
||||
if options.built:
|
||||
|
|
@ -2589,7 +2590,7 @@ def anon_handle_list_untagged(goptions, session, args):
|
|||
(options, args) = parser.parse_args(args)
|
||||
if len(args) > 1:
|
||||
parser.error(_("Only one package name may be specified"))
|
||||
activate_session(session, goptions)
|
||||
ensure_connection(session)
|
||||
package = None
|
||||
if len(args) > 0:
|
||||
package = args[0]
|
||||
|
|
@ -2657,7 +2658,7 @@ def anon_handle_list_groups(goptions, session, args):
|
|||
opts = {}
|
||||
if options.incl_blocked:
|
||||
opts['incl_blocked'] = True
|
||||
activate_session(session, goptions)
|
||||
ensure_connection(session)
|
||||
event = koji.util.eventFromOpts(session, options)
|
||||
if event:
|
||||
opts['event'] = event['id']
|
||||
|
|
@ -2786,7 +2787,7 @@ def anon_handle_list_channels(goptions, session, args):
|
|||
parser.add_option("--quiet", action="store_true", default=goptions.quiet,
|
||||
help=_("Do not print header information"))
|
||||
(options, args) = parser.parse_args(args)
|
||||
activate_session(session, goptions)
|
||||
ensure_connection(session)
|
||||
channels = session.listChannels()
|
||||
channels = sorted(channels, key=lambda x: x['name'])
|
||||
session.multicall = True
|
||||
|
|
@ -2834,7 +2835,7 @@ def anon_handle_list_hosts(goptions, session, args):
|
|||
parser.add_option("--show-channels", action="store_true", help=_("Show host's channels"))
|
||||
(options, args) = parser.parse_args(args)
|
||||
opts = {}
|
||||
activate_session(session, goptions)
|
||||
ensure_connection(session)
|
||||
if options.arch:
|
||||
opts['arches'] = options.arch
|
||||
if options.channel:
|
||||
|
|
@ -2915,7 +2916,7 @@ def anon_handle_list_pkgs(goptions, session, args):
|
|||
(options, args) = parser.parse_args(args)
|
||||
if len(args) != 0:
|
||||
parser.error(_("This command takes no arguments"))
|
||||
activate_session(session, goptions)
|
||||
ensure_connection(session)
|
||||
opts = {}
|
||||
if options.owner:
|
||||
user = session.getUser(options.owner)
|
||||
|
|
@ -3008,7 +3009,7 @@ def anon_handle_list_builds(goptions, session, args):
|
|||
(options, args) = parser.parse_args(args)
|
||||
if len(args) != 0:
|
||||
parser.error(_("This command takes no arguments"))
|
||||
activate_session(session, goptions)
|
||||
ensure_connection(session)
|
||||
opts = {}
|
||||
for key in ('type', 'prefix'):
|
||||
value = getattr(options, key)
|
||||
|
|
@ -3112,7 +3113,7 @@ def anon_handle_rpminfo(goptions, session, args):
|
|||
(options, args) = parser.parse_args(args)
|
||||
if len(args) < 1:
|
||||
parser.error(_("Please specify an RPM"))
|
||||
activate_session(session, goptions)
|
||||
ensure_connection(session)
|
||||
for rpm in args:
|
||||
info = session.getRPM(rpm)
|
||||
if info is None:
|
||||
|
|
@ -3184,7 +3185,7 @@ def anon_handle_buildinfo(goptions, session, args):
|
|||
(options, args) = parser.parse_args(args)
|
||||
if len(args) < 1:
|
||||
parser.error(_("Please specify a build"))
|
||||
activate_session(session, goptions)
|
||||
ensure_connection(session)
|
||||
for build in args:
|
||||
if build.isdigit():
|
||||
build = int(build)
|
||||
|
|
@ -3282,7 +3283,7 @@ def anon_handle_hostinfo(goptions, session, args):
|
|||
(options, args) = parser.parse_args(args)
|
||||
if len(args) < 1:
|
||||
parser.error(_("Please specify a host"))
|
||||
activate_session(session, goptions)
|
||||
ensure_connection(session)
|
||||
for host in args:
|
||||
if host.isdigit():
|
||||
host = int(host)
|
||||
|
|
@ -3967,7 +3968,7 @@ def anon_handle_list_targets(goptions, session, args):
|
|||
(options, args) = parser.parse_args(args)
|
||||
if len(args) != 0:
|
||||
parser.error(_("This command takes no arguments"))
|
||||
activate_session(session, goptions)
|
||||
ensure_connection(session)
|
||||
|
||||
fmt = "%(name)-30s %(build_tag_name)-30s %(dest_tag_name)-30s"
|
||||
if not options.quiet:
|
||||
|
|
@ -4037,7 +4038,7 @@ def anon_handle_list_tag_inheritance(goptions, session, args):
|
|||
(options, args) = parser.parse_args(args)
|
||||
if len(args) != 1:
|
||||
parser.error(_("This command takes exctly one argument: a tag name or ID"))
|
||||
activate_session(session, goptions)
|
||||
ensure_connection(session)
|
||||
event = koji.util.eventFromOpts(session, options)
|
||||
if event:
|
||||
event['timestr'] = time.asctime(time.localtime(event['ts']))
|
||||
|
|
@ -4088,7 +4089,7 @@ def anon_handle_list_tags(goptions, session, args):
|
|||
parser.add_option("--build", help=_("Show tags associated with a build"))
|
||||
parser.add_option("--package", help=_("Show tags associated with a package"))
|
||||
(options, args) = parser.parse_args(args)
|
||||
activate_session(session, goptions)
|
||||
ensure_connection(session)
|
||||
|
||||
pkginfo = {}
|
||||
buildinfo = {}
|
||||
|
|
@ -4162,7 +4163,7 @@ def anon_handle_list_tag_history(goptions, session, args):
|
|||
if not limited and not options.all:
|
||||
parser.error(_("Please specify an option to limit the query"))
|
||||
|
||||
activate_session(session, goptions)
|
||||
ensure_connection(session)
|
||||
|
||||
hist = session.tagHistory(**kwargs)
|
||||
timeline = []
|
||||
|
|
@ -4516,7 +4517,7 @@ def anon_handle_list_history(goptions, session, args):
|
|||
if not limited and not options.all:
|
||||
parser.error(_("Please specify an option to limit the query"))
|
||||
|
||||
activate_session(session, goptions)
|
||||
ensure_connection(session)
|
||||
|
||||
if options.watch:
|
||||
if not kwargs.get('afterEvent') and not kwargs.get('after'):
|
||||
|
|
@ -4837,7 +4838,7 @@ def anon_handle_taskinfo(goptions, session, args):
|
|||
if len(args) < 1:
|
||||
parser.error(_("You must specify at least one task ID"))
|
||||
|
||||
activate_session(session, goptions)
|
||||
ensure_connection(session)
|
||||
|
||||
for arg in args:
|
||||
task_id = int(arg)
|
||||
|
|
@ -4855,7 +4856,7 @@ def anon_handle_taginfo(goptions, session, args):
|
|||
(options, args) = parser.parse_args(args)
|
||||
if len(args) < 1:
|
||||
parser.error(_("Please specify a tag"))
|
||||
activate_session(session, goptions)
|
||||
ensure_connection(session)
|
||||
event = koji.util.eventFromOpts(session, options)
|
||||
event_opts = {}
|
||||
if event:
|
||||
|
|
@ -5346,7 +5347,7 @@ def anon_handle_show_groups(goptions, session, args):
|
|||
parser.error(_("Incorrect number of arguments"))
|
||||
if options.incl_blocked and (options.comps or options.spec):
|
||||
parser.error(_("--show-blocked doesn't make sense for comps/spec output"))
|
||||
activate_session(session, goptions)
|
||||
ensure_connection(session)
|
||||
tag = args[0]
|
||||
callopts = {}
|
||||
if options.incl_blocked:
|
||||
|
|
@ -5381,7 +5382,7 @@ def anon_handle_list_external_repos(goptions, session, args):
|
|||
(options, args) = parser.parse_args(args)
|
||||
if len(args) > 0:
|
||||
parser.error(_("This command takes no arguments"))
|
||||
activate_session(session, goptions)
|
||||
ensure_connection(session)
|
||||
opts = {}
|
||||
event = koji.util.eventFromOpts(session, options)
|
||||
if event:
|
||||
|
|
@ -6462,7 +6463,10 @@ def anon_handle_watch_task(goptions, session, args):
|
|||
if args and selection:
|
||||
parser.error(_("Selection options cannot be combined with a task list"))
|
||||
|
||||
activate_session(session, goptions)
|
||||
if options.mine:
|
||||
activate_session(session, goptions)
|
||||
else:
|
||||
ensure_connection(session)
|
||||
if selection:
|
||||
tasks = [task['id'] for task in _list_tasks(options, session)]
|
||||
if not tasks:
|
||||
|
|
@ -6492,9 +6496,9 @@ def anon_handle_watch_logs(goptions, session, args):
|
|||
"this case."))
|
||||
parser.add_option("--follow", action="store_true", help=_("Follow spawned child tasks"))
|
||||
(options, args) = parser.parse_args(args)
|
||||
activate_session(session, goptions)
|
||||
|
||||
if options.mine:
|
||||
activate_session(session, goptions)
|
||||
if args:
|
||||
parser.error(_("Selection options cannot be combined with a task list"))
|
||||
tasks = _list_tasks(options, session)
|
||||
|
|
@ -6503,6 +6507,7 @@ def anon_handle_watch_logs(goptions, session, args):
|
|||
print(_("You've no active tasks."))
|
||||
return
|
||||
else:
|
||||
ensure_connection(session)
|
||||
tasks = []
|
||||
for task in args:
|
||||
try:
|
||||
|
|
@ -6744,7 +6749,7 @@ def anon_handle_download_build(options, session, args):
|
|||
elif len(args) > 1:
|
||||
parser.error(_("Only a single package N-V-R or build ID may be specified"))
|
||||
|
||||
activate_session(session, options)
|
||||
ensure_connection(session)
|
||||
build = args[0]
|
||||
|
||||
if build.isdigit():
|
||||
|
|
@ -6968,7 +6973,7 @@ def anon_handle_download_task(options, session, args):
|
|||
if len(suboptions.arches) > 0:
|
||||
suboptions.arches = ",".join(suboptions.arches).split(",")
|
||||
|
||||
activate_session(session, options)
|
||||
ensure_connection(session)
|
||||
|
||||
# get downloadable tasks
|
||||
|
||||
|
|
@ -7392,14 +7397,14 @@ def anon_handle_list_notifications(goptions, session, args):
|
|||
if not options.mine and not options.user:
|
||||
parser.error(_("Use --user or --mine."))
|
||||
|
||||
activate_session(session, goptions)
|
||||
|
||||
if options.user:
|
||||
ensure_connection(session)
|
||||
user = session.getUser(options.user)
|
||||
if not user:
|
||||
error("User %s does not exist" % options.user)
|
||||
user_id = user['id']
|
||||
else:
|
||||
activate_session(session, goptions)
|
||||
user_id = None
|
||||
|
||||
mask = "%(id)6s %(tag)-25s %(package)-25s %(email)-20s %(success)-12s"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue