Added: manifest, directory, binary support#20
Open
mattjackets wants to merge 1 commit intoolivergregorius:mainfrom
Open
Added: manifest, directory, binary support#20mattjackets wants to merge 1 commit intoolivergregorius:mainfrom
mattjackets wants to merge 1 commit intoolivergregorius:mainfrom
Conversation
Added support for file manifest, so firmware files can be changed OTA. Improved support for binary files. Added support for subdirectories (must include a trailing slash in manifest to create directory) Improved error handling for OSErrors
olivergregorius
requested changes
Sep 25, 2023
Owner
olivergregorius
left a comment
There was a problem hiding this comment.
Thanks @mattjackets,
could you please add some tests?
| response.close() | ||
| if response_status_code != 200: | ||
| print(f'Remote manifest file {host}/{project}/{remote_version}{prefix_or_path_separator}manifest not found') | ||
| raise Exception(f"Missing manifest for {remote_version}") |
Owner
There was a problem hiding this comment.
Suggested change
| raise Exception(f"Missing manifest for {remote_version}") | |
| raise Exception(f'Missing manifest for {remote_version}') |
| filenames = fetch_manifest(host, project, remote_version, prefix_or_path_separator, auth=auth, timeout=timeout) | ||
| for filename in filenames: | ||
| if filename.endswith('/'): | ||
| dir_path="tmp" |
Owner
There was a problem hiding this comment.
Suggested change
| dir_path="tmp" | |
| dir_path='tmp' |
Owner
There was a problem hiding this comment.
We could define dir_path at the beginning of the method and reference this var in the uos.mkdir call.
| dir_path="tmp" | ||
| for dir in filename.split('/'): | ||
| if len(dir) > 0: | ||
| built_path=f"{dir_path}/{dir}" |
Owner
There was a problem hiding this comment.
Suggested change
| built_path=f"{dir_path}/{dir}" | |
| built_path=f'{dir_path}/{dir}' |
| for filename in filenames: | ||
| with open(f'tmp/{filename}', 'r') as source_file, open(filename, 'w') as target_file: | ||
| if filename.endswith('/'): | ||
| dir_path="" |
Owner
There was a problem hiding this comment.
Suggested change
| dir_path="" | |
| dir_path='' |
| dir_path="" | ||
| for dir in filename.split('/'): | ||
| if len(dir) > 0: | ||
| built_path=f"{dir_path}/{dir}" |
Owner
There was a problem hiding this comment.
Suggested change
| built_path=f"{dir_path}/{dir}" | |
| built_path=f'{dir_path}/{dir}' |
| except OSError as e: | ||
| if e.errno != 17: | ||
| raise | ||
| dirs.append(f"tmp/{built_path}") |
Owner
There was a problem hiding this comment.
Suggested change
| dirs.append(f"tmp/{built_path}") | |
| dirs.append(f'tmp/{built_path}') |
| raise | ||
| dirs.append(f"tmp/{built_path}") | ||
| continue | ||
| #print(f"tmp/{filename} -> {filename}") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Added support for file manifest, so firmware files can be changed OTA. Improved support for binary files.
Added support for subdirectories (must include a trailing slash in manifest to create directory) Improved error handling for OSErrors