Skip to content

build_parameters.py: fix htmlparser#7597

Open
khancyr wants to merge 1 commit intoArduPilot:masterfrom
khancyr:parameter_fix
Open

build_parameters.py: fix htmlparser#7597
khancyr wants to merge 1 commit intoArduPilot:masterfrom
khancyr:parameter_fix

Conversation

@khancyr
Copy link
Copy Markdown
Contributor

@khancyr khancyr commented Mar 31, 2026

fix class (python use capitalize name, links was missing from class but use in exception handling)
fix error handling
fix parsing element
simplify elements parsed and return: get the href directly as that is what interest us and simplify the parsing, pre-filter links to keep only the necessary, do better return to avoid broad exception on missing directory

image

@khancyr
Copy link
Copy Markdown
Contributor Author

khancyr commented Apr 14, 2026

rebased on #7650

@khancyr
Copy link
Copy Markdown
Contributor Author

khancyr commented Apr 16, 2026

rebased after #7659

Comment thread build_parameters.py
if tag == 'a':
attr = dict(attrs)
self.links.append(attr)
href = attr.get('href')
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we just need the link so no need to capture the whole section

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

attr : {'href': '/Copter/stable-4.4.2'}
href : /Copter/stable-4.4.2

Comment thread build_parameters.py
for folder in page_links: # Non clever way to filter the strings insert by makehtml.py, unwanted folders, and so.
version_folder = str(folder)
firmware_link = f"{firmware_url[:-1]}{version_folder[10:-2]}"
firmware_version_url = f"{firmware_url[:-1]}{version_folder}"
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as we got on the href, we don't need to discard the marking

Copy link
Copy Markdown
Contributor Author

@khancyr khancyr Apr 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

master:
version folder: {'href': '/Copter/stable-4.6.2'}
firmware version url: https://firmware.ardupilot.org/Copter/stable-4.6.2

PR:
version folder: /Copter/stable-4.6.3
firmware version url: https://firmware.ardupilot.org/Copter/stable-4.6.3

Comment thread build_parameters.py
last_folder = last_item['href']
debug(f"Returning link of the last board folder ({last_folder[last_folder.rindex('/')+1:]})")
return last_folder[last_folder.rindex('/')+1:] # clean the partial link
if len(html_parser.links) == 0:
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix the case of empty list (that shouldn't happens but ...)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't this happen any time the server returns HTTP 500 Still dividing by zero?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes but that would need to be handled on the Exception level. This just handle the fact the sever respond by with empty or not well formatted page and prevent raising an exception.

Unless you prefer to raise on such case ? But if that happens how do we get notification as this happens on the server ? (no CI for parameter versionning yet)

Comment thread build_parameters.py
error(f"No board folders found in {url}, skipping this release.")
return ""
last_folder = html_parser.links.pop()
board_name = os.path.basename(last_folder)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is simpler to get the last part of the url

Comment thread build_parameters.py
fetch_link = f"{version_link}/{board}/{file}"

progress(f"Processing link...\t{fetch_link}")
if board == "":
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

handle the empty list error

fix class
fix error handling
fix parsing element
simplify elements parsed and return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants