2013-09-04 15:11:27 +02:00
|
|
|
#!/usr/bin/env python
|
2014-01-31 10:29:44 +01:00
|
|
|
# -*- coding: utf-8 -*-
|
2013-09-04 15:11:27 +02:00
|
|
|
#
|
2014-02-10 10:19:37 +01:00
|
|
|
# (C) 2014 mhrusecky@suse.cz, openSUSE.org
|
|
|
|
# (C) 2014 tchvatal@suse.cz, openSUSE.org
|
2014-03-06 18:37:33 +01:00
|
|
|
# (C) 2014 aplanas@suse.de, openSUSE.org
|
|
|
|
# (C) 2014 coolo@suse.de, openSUSE.org
|
2013-09-04 15:11:27 +02:00
|
|
|
# Distribute under GPLv2 or GPLv3
|
|
|
|
|
2014-02-25 14:12:28 +01:00
|
|
|
import os
|
2014-02-12 13:15:49 +01:00
|
|
|
import os.path
|
|
|
|
import sys
|
2014-02-12 18:34:17 +01:00
|
|
|
|
|
|
|
from osc import cmdln, oscerr
|
2014-02-12 13:15:49 +01:00
|
|
|
|
|
|
|
# Expand sys.path to search modules inside the pluging directory
|
|
|
|
_plugin_dir = os.path.expanduser('~/.osc-plugins')
|
|
|
|
sys.path.append(_plugin_dir)
|
2014-03-06 18:50:59 +01:00
|
|
|
|
2014-02-12 17:58:19 +01:00
|
|
|
from osclib.stagingapi import StagingAPI
|
2014-02-17 13:32:34 +01:00
|
|
|
from osclib.request_finder import RequestFinder
|
2014-03-04 09:39:14 +01:00
|
|
|
from osclib.select_command import SelectCommand
|
2014-03-25 11:55:11 +01:00
|
|
|
from osclib.unselect_command import UnselectCommand
|
2014-03-04 09:39:14 +01:00
|
|
|
from osclib.accept_command import AcceptCommand
|
|
|
|
from osclib.cleanup_rings import CleanupRings
|
|
|
|
from osclib.list_command import ListCommand
|
2014-03-06 18:50:59 +01:00
|
|
|
from osclib.freeze_command import FreezeCommand
|
|
|
|
from osclib.check_command import CheckCommand
|
2014-03-04 09:39:14 +01:00
|
|
|
|
2014-03-03 17:20:40 +01:00
|
|
|
OSC_STAGING_VERSION = '0.0.1'
|
|
|
|
|
2014-03-11 09:38:27 +01:00
|
|
|
|
2013-09-04 15:11:27 +02:00
|
|
|
def _print_version(self):
|
|
|
|
""" Print version information about this extension. """
|
2014-03-03 17:20:40 +01:00
|
|
|
print(self.OSC_STAGING_VERSION)
|
2013-09-04 15:11:27 +02:00
|
|
|
quit(0)
|
|
|
|
|
2014-03-11 09:38:27 +01:00
|
|
|
|
2014-03-04 09:39:14 +01:00
|
|
|
@cmdln.option('--move', action='store_true',
|
2014-03-03 17:20:40 +01:00
|
|
|
help='force the selection to become a move')
|
2014-02-25 14:12:28 +01:00
|
|
|
@cmdln.option('-f', '--from', dest='from_', metavar='FROMPROJECT',
|
|
|
|
help='manually specify different source project during request moving')
|
2013-09-04 15:11:27 +02:00
|
|
|
@cmdln.option('-v', '--version', action='store_true',
|
|
|
|
help='show version of the plugin')
|
|
|
|
def do_staging(self, subcmd, opts, *args):
|
|
|
|
"""${cmd_name}: Commands to work with staging projects
|
|
|
|
|
2014-03-06 18:50:59 +01:00
|
|
|
"accept" will accept all requests in
|
|
|
|
openSUSE:Factory:Staging:<LETTER> (into Factory)
|
|
|
|
|
2013-09-04 15:11:27 +02:00
|
|
|
"check" will check if all packages are links without changes
|
|
|
|
|
2014-03-06 18:50:59 +01:00
|
|
|
"cleanup_rings" will try to cleanup rings content and print
|
|
|
|
out problems
|
|
|
|
|
2014-03-03 17:20:40 +01:00
|
|
|
"freeze" will freeze the sources of the project's links (not
|
|
|
|
affecting the packages actually in)
|
2014-02-10 10:19:37 +01:00
|
|
|
|
2014-01-31 10:29:44 +01:00
|
|
|
"list" will pick the requests not in rings
|
|
|
|
|
2014-02-12 13:36:41 +01:00
|
|
|
"select" will add requests to the project
|
2014-03-06 18:50:59 +01:00
|
|
|
|
2014-03-05 09:24:07 +01:00
|
|
|
"unselect" will remove from the project - pushing them back to the backlog
|
2014-02-10 10:20:16 +01:00
|
|
|
|
2013-09-04 15:11:27 +02:00
|
|
|
Usage:
|
2014-03-06 18:50:59 +01:00
|
|
|
osc staging accept LETTER
|
2013-09-04 15:11:27 +02:00
|
|
|
osc staging check [--everything] REPO
|
2014-03-06 18:50:59 +01:00
|
|
|
osc staging cleanup_rings
|
|
|
|
osc staging freeze PROJECT...
|
2014-01-31 10:29:44 +01:00
|
|
|
osc staging list
|
2014-03-03 17:20:40 +01:00
|
|
|
osc staging select [--move [-from PROJECT]] LETTER REQUEST...
|
2014-03-05 09:24:07 +01:00
|
|
|
osc staging unselect REQUEST...
|
2013-09-04 15:11:27 +02:00
|
|
|
"""
|
|
|
|
if opts.version:
|
|
|
|
self._print_version()
|
|
|
|
|
|
|
|
# verify the argument counts match the commands
|
2014-02-10 19:59:45 +01:00
|
|
|
if len(args) == 0:
|
|
|
|
raise oscerr.WrongArgs('No command given, see "osc help staging"!')
|
2013-09-04 15:11:27 +02:00
|
|
|
cmd = args[0]
|
2014-03-06 18:50:59 +01:00
|
|
|
if cmd in ('accept', 'freeze'):
|
2013-09-04 15:11:27 +02:00
|
|
|
min_args, max_args = 1, 1
|
2014-03-03 17:20:40 +01:00
|
|
|
elif cmd == 'check':
|
2014-02-17 15:13:27 +01:00
|
|
|
min_args, max_args = 0, 2
|
2014-03-04 16:50:49 +01:00
|
|
|
elif cmd == 'select':
|
2014-02-11 15:23:34 +01:00
|
|
|
min_args, max_args = 2, None
|
2014-03-04 16:50:49 +01:00
|
|
|
elif cmd == 'unselect':
|
|
|
|
min_args, max_args = 1, None
|
2014-03-04 15:23:15 +01:00
|
|
|
elif cmd in ('list', 'cleanup_rings'):
|
2014-01-31 10:29:44 +01:00
|
|
|
min_args, max_args = 0, 0
|
2013-09-04 15:11:27 +02:00
|
|
|
else:
|
2014-03-03 17:20:40 +01:00
|
|
|
raise oscerr.WrongArgs('Unknown command: %s' % cmd)
|
2013-09-04 15:11:27 +02:00
|
|
|
if len(args) - 1 < min_args:
|
|
|
|
raise oscerr.WrongArgs('Too few arguments.')
|
2014-03-28 11:46:14 +01:00
|
|
|
if max_args is not None and len(args) - 1 > max_args:
|
2013-09-04 15:11:27 +02:00
|
|
|
raise oscerr.WrongArgs('Too many arguments.')
|
|
|
|
|
|
|
|
# init the obs access
|
2014-01-31 10:29:44 +01:00
|
|
|
opts.apiurl = self.get_api_url()
|
|
|
|
opts.verbose = False
|
2014-02-12 17:58:19 +01:00
|
|
|
api = StagingAPI(opts.apiurl)
|
2014-01-31 10:29:44 +01:00
|
|
|
|
2013-09-04 15:11:27 +02:00
|
|
|
# call the respective command and parse args by need
|
2014-03-06 18:50:59 +01:00
|
|
|
if cmd == 'check':
|
|
|
|
project = args[1] if len(args) > 1 else None
|
|
|
|
if project:
|
|
|
|
project = api.prj_from_letter(project)
|
|
|
|
CheckCommand(api).perform(project)
|
2014-03-04 09:39:14 +01:00
|
|
|
elif cmd == 'freeze':
|
2014-02-24 11:49:46 +01:00
|
|
|
for prj in args[1:]:
|
2014-03-06 18:50:59 +01:00
|
|
|
FreezeCommand(api).perform(api. prj_from_letter(prj))
|
2014-03-04 09:39:14 +01:00
|
|
|
elif cmd == 'accept':
|
2014-03-05 15:49:48 +01:00
|
|
|
return AcceptCommand(api).perform(api. prj_from_letter(args[1]))
|
2014-03-04 09:39:14 +01:00
|
|
|
elif cmd == 'unselect':
|
2014-03-24 14:46:50 +01:00
|
|
|
return UnselectCommand(api).perform(args[1:])
|
2014-03-04 09:39:14 +01:00
|
|
|
elif cmd == 'select':
|
2014-03-04 16:50:49 +01:00
|
|
|
tprj = api.prj_from_letter(args[1])
|
2014-03-04 15:30:49 +01:00
|
|
|
return SelectCommand(api).perform(tprj, args[2:], opts.move, opts.from_)
|
2014-03-04 15:23:15 +01:00
|
|
|
elif cmd == 'cleanup_rings':
|
2014-03-04 09:39:14 +01:00
|
|
|
return CleanupRings(opts.apiurl).perform()
|
2014-03-04 15:23:15 +01:00
|
|
|
elif cmd == 'list':
|
2014-03-04 09:39:14 +01:00
|
|
|
return ListCommand(api).perform()
|