Skip to content
This repository has been archived by the owner on Sep 23, 2024. It is now read-only.

Commit

Permalink
Unify get_patch_by_id
Browse files Browse the repository at this point in the history
Throw an exception if the requested patch can't be retrieved. This was
already done for PatchworkV2Project but not PatchworkV1Project. Being
unable to retrieve a patch previously known as existing signals a
possible problem in sktm's logic, and it should be handled as such. The
unification also allows to remove the return value checks when this
method is used.

Signed-off-by: Veronika Kabatova <[email protected]>
  • Loading branch information
veruu authored and spbnick committed Sep 4, 2018
1 parent 2b798b5 commit 4194368
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 19 deletions.
3 changes: 0 additions & 3 deletions sktm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,6 @@ def get_patch_info_from_url(self, interface, patch_url):
baseurl = match.group(1)
patch_id = int(match.group(2))
patch = interface.get_patch_by_id(patch_id)
if patch is None:
raise Exception('Can\'t get data for %s' % patch_url)

logging.info('patch: [%d] %s', patch_id, patch.get('name'))

if isinstance(interface, sktm.patchwork.PatchworkV2Project):
Expand Down
29 changes: 13 additions & 16 deletions sktm/patchwork.py
Original file line number Diff line number Diff line change
Expand Up @@ -762,16 +762,15 @@ def get_patchsets(self, patchlist):
# For each patch ID
for pid in patchlist:
patch = self.get_patch_by_id(pid)
if patch:
# For each series the patch belongs to
for series in patch.get("series"):
sid = series.get("id")
if sid not in seen:
series_list += self.__get_series_from_url(
join_with_slash(self.apiurls.get("series"),
str(sid))
)
seen.add(sid)
# For each series the patch belongs to
for series in patch.get("series"):
sid = series.get("id")
if sid not in seen:
series_list += self.__get_series_from_url(
join_with_slash(self.apiurls.get("series"),
str(sid))
)
seen.add(sid)

return series_list

Expand Down Expand Up @@ -908,8 +907,7 @@ def get_patch_by_id(self, pid):
patch = self.rpc.patch_get(pid, self.fields)

if patch is None or patch == {}:
logging.warning("Failed to get data for patch %d", pid)
patch = None
raise Exception('Can\'t get patch by id %d)'.format(pid))

self.__update_patch_name(patch)

Expand Down Expand Up @@ -1169,8 +1167,7 @@ def get_patchsets(self, patchlist):
logging.debug("get_patchsets: %s", patchlist)
for pid in patchlist:
patch = self.get_patch_by_id(pid)
if patch:
pset = self.__parse_patch(patch)
if pset:
series_list.append(pset)
pset = self.__parse_patch(patch)
if pset:
series_list.append(pset)
return series_list

0 comments on commit 4194368

Please sign in to comment.