Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added suit-generator payload_extract command #147

Merged
merged 1 commit into from
Oct 25, 2024

Conversation

ahasztag
Copy link
Collaborator

The payload allows for extracting/removing/replacing integrated payloads in the envelope.

Ref: NCSDK-29708

+ "If not provided, the payload will not be stored to a file.")

cmd_payload_extract_arg_parser.add_argument(
"--payload-replace-name",
Copy link
Collaborator

Choose a reason for hiding this comment

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

should not that be path not name?
I find it difficult to understand this arg description.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You're absolutely right, should be path, changed this

@NordicBuilder
Copy link
Collaborator

NordicBuilder commented Oct 18, 2024

pytest coverage results

Detailed report:

Type Coverage
lines 91.3% (2048 of 2242 lines)
functions no data found
branches no data found

Note: This message is automatically posted and updated by the CI (latest/test-sdk-dfu/master/204)

:param payload_replace_name: name of the integrated payload to replace the extracted payload with.
None if the payload should be removed from the envelope.
"""
envelope = None
Copy link
Collaborator

Choose a reason for hiding this comment

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

The envelope value is immediately assigned in line 56 as envelope = cbor2.load(fh), so the initial assignment is redundant and could be removed

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed

envelope = cbor2.load(fh)
extracted_payload = envelope.value.pop(payload_name, None)

if extracted_payload == None:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
if extracted_payload == None:
if extracted_payload is None:

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed

if extracted_payload == None:
log.log(logging.ERROR, 'Payload "%s" not found in envelope', payload_name)

if payload_replace_name != None:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
if payload_replace_name != None:
if payload_replace_name is not None:

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed


with open(output_envelope, "wb") as fh:
cbor2.dump(envelope, fh)
if output_payload_file != None:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
if output_payload_file != None:
if output_payload_file is not None:

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed

@ahasztag ahasztag force-pushed the payload_remove_from_envelope branch 2 times, most recently from 52d1ead to 82b6cce Compare October 23, 2024 11:05
The payload allows for extracting/removing/replacing integrated
payloads in the envelope.

Ref: NCSDK-29708

Signed-off-by: Artur Hadasz <artur.hadasz@nordicsemi.no>
@ahasztag ahasztag merged commit e383e6c into nrfconnect:ncs Oct 25, 2024
2 checks passed
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.

6 participants