Skip to content

Conversation

@mattjackets
Copy link

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
Copy link
Owner

@olivergregorius olivergregorius left a comment

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?

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
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}')

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
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
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.

dir_path="tmp"
for dir in filename.split('/'):
if len(dir) > 0:
built_path=f"{dir_path}/{dir}"
Copy link
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}'

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
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=''

dir_path=""
for dir in filename.split('/'):
if len(dir) > 0:
built_path=f"{dir_path}/{dir}"
Copy link
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}'

except OSError as e:
if e.errno != 17:
raise
dirs.append(f"tmp/{built_path}")
Copy link
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}')

raise
dirs.append(f"tmp/{built_path}")
continue
#print(f"tmp/{filename} -> {filename}")
Copy link
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