Skip to content

Commit

Permalink
Make GetRepo, handle missing repo options, with out breaking
Browse files Browse the repository at this point in the history
  • Loading branch information
timlau authored and Conan-Kudo committed Oct 1, 2021
1 parent 5bc8e23 commit a8f3591
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions python/dnfdaemon/server/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,14 @@ def get_repo(self, repo_id):
value = json.dumps(None)
repo = self.base.repos.get(repo_id, None) # get the repo object
if repo:
# VectorString is not JSON serializable let's convert to list
repo_conf = dict([(c, getattr(repo, c) if 'VectorString' not in str(type(getattr(repo, c))) else list(getattr(repo, c))) for c in optionKeys])
repo_conf = {}
for c in optionKeys:
if hasattr(repo,c):
value = getattr(repo, c)
# VectorString is not JSON serializable let's convert to list
if 'VectorString' in str(type(value)):
value = list(value)
repo_conf[c] = value

enab = repo.enabled
if not enab:
Expand Down

0 comments on commit a8f3591

Please sign in to comment.