Skip to content

Commit

Permalink
add null check
Browse files Browse the repository at this point in the history
  • Loading branch information
Buxdehuda authored Feb 5, 2024
1 parent de5c51f commit 5710e2e
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions certbotstratoapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,13 @@ def get_package_id(self) -> None:
return
else:
# Old page layout: still relevant?
customer_link = package_element.find_next('a', class_='customer-link')['href']
query_parameters = urllib.parse.parse_qs(customer_link)
if 'cID' in query_parameters:
self.package_id = query_parameters['cID'][0]
print(f'INFO: strato package id (cID): {self.package_id}')
return
customer_link = package_element.find_next('a', class_='customer-link')
if customer_link is not None and customer_link.has_attr('href'):
query_parameters = urllib.parse.parse_qs(customer_link['href'])
if 'cID' in query_parameters:
self.package_id = query_parameters['cID'][0]
print(f'INFO: strato package id (cID): {self.package_id}')
return

print(f'ERROR: Domain {self.second_level_domain_name} not '
'found in strato packages. Using fallback cID=1')
Expand Down

0 comments on commit 5710e2e

Please sign in to comment.