Skip to content

Added: manifest, directory, binary support#20

Open
mattjackets wants to merge 1 commit into
olivergregorius:mainfrom
mattjackets:main
Open

Added: manifest, directory, binary support#20
mattjackets wants to merge 1 commit into
olivergregorius:mainfrom
mattjackets:main

Conversation

@mattjackets

Copy link
Copy Markdown

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

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 olivergregorius left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks @mattjackets,
could you please add some tests?

Comment thread micropython_ota.py
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}")

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Suggested change
raise Exception(f"Missing manifest for {remote_version}")
raise Exception(f'Missing manifest for {remote_version}')

Comment thread micropython_ota.py
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"

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Suggested change
dir_path="tmp"
dir_path='tmp'

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

We could define dir_path at the beginning of the method and reference this var in the uos.mkdir call.

Comment thread micropython_ota.py
dir_path="tmp"
for dir in filename.split('/'):
if len(dir) > 0:
built_path=f"{dir_path}/{dir}"

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Suggested change
built_path=f"{dir_path}/{dir}"
built_path=f'{dir_path}/{dir}'

Comment thread micropython_ota.py
for filename in filenames:
with open(f'tmp/{filename}', 'r') as source_file, open(filename, 'w') as target_file:
if filename.endswith('/'):
dir_path=""

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Suggested change
dir_path=""
dir_path=''

Comment thread micropython_ota.py
dir_path=""
for dir in filename.split('/'):
if len(dir) > 0:
built_path=f"{dir_path}/{dir}"

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Suggested change
built_path=f"{dir_path}/{dir}"
built_path=f'{dir_path}/{dir}'

Comment thread micropython_ota.py
except OSError as e:
if e.errno != 17:
raise
dirs.append(f"tmp/{built_path}")

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Suggested change
dirs.append(f"tmp/{built_path}")
dirs.append(f'tmp/{built_path}')

Comment thread micropython_ota.py
raise
dirs.append(f"tmp/{built_path}")
continue
#print(f"tmp/{filename} -> {filename}")

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Leftover?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants