@@ -108,22 +108,9 @@ def get_individuals(self):
108108
109109 # Fetch accounts pages
110110 for account in client .fetch_accounts (epoch = epoch ):
111- try :
112- ef_profile = client .fetch_account_profile (account ['name' ])
113- except requests .exceptions .HTTPError as error :
114- # Ignore 5xx errors
115- if 500 <= error .response .status_code < 600 :
116- msg = (
117- f"Unable to fetch { account ['name' ]} profile."
118- f"Server error: { error .response .status_code } - { error .response .reason } ."
119- "Skipping"
120- )
121- logger .error (msg )
122- continue
123- else :
124- raise error
125-
126- if not ef_profile ['eca' ]['signed' ]:
111+ ef_profile = client .fetch_account_profile (account ['name' ])
112+
113+ if not ef_profile :
127114 continue
128115
129116 individual = Individual (uuid = ef_profile ['uid' ])
@@ -154,21 +141,22 @@ def get_individuals(self):
154141 )
155142 individual .identities .append (idt )
156143
157- employment_history = client .fetch_employment_history (account ['name' ])
158-
159144 # Fetch enrollments for the identity. If no enrollment is set
160145 # use the organization field from the profile, if set.
161- for employment in employment_history :
162- org = Organization (name = employment ['organization_name' ])
163- start , end = None , None
146+ employment_history = client .fetch_employment_history (account ['name' ])
164147
165- if employment [ 'start' ] :
166- start = str_to_datetime ( employment [ 'start' ])
167- if employment ['end' ]:
168- end = str_to_datetime ( employment [ 'end' ])
148+ if employment_history :
149+ for employment in employment_history :
150+ org = Organization ( name = employment ['organization_name' ])
151+ start , end = None , None
169152
170- enr = Enrollment (org , start = start , end = end )
171- individual .enrollments .append (enr )
153+ if employment ['start' ]:
154+ start = str_to_datetime (employment ['start' ])
155+ if employment ['end' ]:
156+ end = str_to_datetime (employment ['end' ])
157+
158+ enr = Enrollment (org , start = start , end = end )
159+ individual .enrollments .append (enr )
172160
173161 if not individual .enrollments :
174162 company = ef_profile .get ('org' , None )
@@ -292,8 +280,21 @@ def fetch_employment_history(self, eclipsefdn_id):
292280 def _fetch (self , url , params = None ):
293281 """Generic query to Eclipse usr API."""
294282
295- response = requests .get (url , params = params , auth = self .token )
296- response .raise_for_status ()
283+ try :
284+ response = requests .get (url , params = params , auth = self .token )
285+ response .raise_for_status ()
286+ except requests .exceptions .HTTPError as error :
287+ # Ignore 5xx errors
288+ if 500 <= error .response .status_code < 600 :
289+ msg = (
290+ f"Unable to fetch { url } "
291+ f"Server error: { error .response .status_code } - { error .response .reason } ."
292+ "Skipping"
293+ )
294+ logger .error (msg )
295+ return None
296+ else :
297+ raise error
297298
298299 return response .json ()
299300
0 commit comments