Merge pull request #22 from scarabeusiv/master
Make add work with something that is already in
This commit is contained in:
commit
63ce1116d7
17
osc-group.py
17
osc-group.py
@ -149,7 +149,7 @@ def _group_find_sr(self, pkgs, opts):
|
||||
|
||||
def _group_verify_grouping(self, srids, opts, require_grouping = False):
|
||||
"""
|
||||
Verify that none of the SR#s is not part of any other grouping request
|
||||
Verifies if the SRs are part of some GR and if not return list of those remaining.
|
||||
:param srids: list of submit request IDs
|
||||
:param opts: obs options
|
||||
:param require_grouping: if passed return list of GR#s for the SR#s and fail if they are not members of any
|
||||
@ -162,13 +162,20 @@ def _group_verify_grouping(self, srids, opts, require_grouping = False):
|
||||
if group:
|
||||
if require_grouping:
|
||||
grids.append(group)
|
||||
else:
|
||||
raise oscerr.WrongArgs('SR#{0} is already in GR#{1}'.format(sr, group))
|
||||
# # only remove the ID from grouping, we will error out only if we return empty set
|
||||
# else:
|
||||
# #raise oscerr.WrongArgs('SR#{0} is already in GR#{1}'.format(sr, group))
|
||||
else:
|
||||
if require_grouping:
|
||||
# Can't assert as in the automagic group finding we need to pass here
|
||||
#raise oscerr.WrongArgs('SR#{0} is not member of any group request'.format(sr))
|
||||
grids.append(0)
|
||||
else:
|
||||
# package is not in group so we append it for return
|
||||
grids.append(sr)
|
||||
|
||||
if not require_grouping and len(grids) < 1:
|
||||
raise oscerr.WrongArgs('All added submit request already are in groups: {0}'.format(', '.join(srids)))
|
||||
|
||||
return grids
|
||||
|
||||
@ -208,7 +215,7 @@ def _group_create(self, name, pkgs, opts):
|
||||
"""
|
||||
|
||||
srids = self._group_find_sr(pkgs, opts)
|
||||
self._group_verify_grouping(srids, opts)
|
||||
srids = self._group_verify_grouping(srids, opts)
|
||||
|
||||
# compose the xml
|
||||
xml='<request><action type="group">'
|
||||
@ -237,7 +244,7 @@ def _group_add(self, grid, pkgs, opts):
|
||||
returned_group = self._group_verify_type(grid, opts)
|
||||
if returned_group:
|
||||
srids = self._group_find_sr(pkgs, opts)
|
||||
self._group_verify_grouping(srids, opts)
|
||||
srids = self._group_verify_grouping(srids, opts)
|
||||
else:
|
||||
# here we add the grid to pkgs and search among all to get at least one
|
||||
# usefull group request id
|
||||
|
Loading…
x
Reference in New Issue
Block a user