Commit 9acafb945c5f796bd3f1d9cd0fda73b05a9dfc65

Authored by Charles Oliveira
1 parent b086563a

Making sure 'lists' is not just a string

Showing 1 changed file with 5 additions and 3 deletions   Show diff stats
colab/accounts/utils/mailman.py
@@ -75,18 +75,20 @@ def mailing_lists(**kwargs): @@ -75,18 +75,20 @@ def mailing_lists(**kwargs):
75 url = get_url('lists/') 75 url = get_url('lists/')
76 76
77 try: 77 try:
78 - lists = requests.get(url, timeout=TIMEOUT, params=kwargs) 78 + lists = requests.get(url, timeout=TIMEOUT, params=kwargs).json()
  79 + if not isinstance(lists, (list, tuple)):
  80 + raise
79 except: 81 except:
80 LOGGER.exception('Unable to list mailing lists') 82 LOGGER.exception('Unable to list mailing lists')
81 return [] 83 return []
82 84
83 if kwargs.get('names_only'): 85 if kwargs.get('names_only'):
84 names_only = [] 86 names_only = []
85 - for l in lists.json(): 87 + for l in lists:
86 names_only.append(l['listname']) 88 names_only.append(l['listname'])
87 return names_only 89 return names_only
88 else: 90 else:
89 - return lists.json() 91 + return lists
90 92
91 93
92 def is_private_list(name): 94 def is_private_list(name):