Skip to content

Commit d91b8b4

Browse files
yangbolu1991kartben
authored andcommitted
scripts: blobs: add click-through property
Added a click-through property. Some downloading may need to accept license to continue. Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
1 parent 5357013 commit d91b8b4

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

scripts/west_commands/blobs.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ def do_add_parser(self, parser_adder):
5555
- type: type of blob
5656
- version: version string
5757
- license_path: path to the license file for the blob
58+
- license-abspath: absolute path to the license file for the blob
59+
- click-through: need license click-through or not
5860
- uri: URI to the remote location of the blob
5961
- description: blob text description
6062
- doc-url: URL to the documentation for this blob
@@ -151,6 +153,33 @@ def fetch(self, args):
151153
self.dbg('Blob {module}: {abspath} is up to date'.format(**blob))
152154
continue
153155
self.inf('Fetching blob {module}: {abspath}'.format(**blob))
156+
157+
if blob['click-through']:
158+
while True:
159+
user_input = input("For this blob, need to read and accept "
160+
"license to continue. Read it?\n"
161+
"Please type 'y' or 'n' and press enter to confirm: ")
162+
if user_input.upper() == "Y" or user_input.upper() == "N":
163+
break
164+
165+
if user_input.upper() != "Y":
166+
self.wrn('Skip fetching this blob.')
167+
continue
168+
169+
with open(blob['license-abspath']) as license_file:
170+
license_content = license_file.read()
171+
print(license_content)
172+
173+
while True:
174+
user_input = input("Accept license to continue?\n"
175+
"Please type 'y' or 'n' and press enter to confirm: ")
176+
if user_input.upper() == "Y" or user_input.upper() == "N":
177+
break
178+
179+
if user_input.upper() != "Y":
180+
self.wrn('Skip fetching this blob.')
181+
continue
182+
154183
self.fetch_blob(blob['url'], blob['abspath'])
155184
if not self.verify_blob(blob):
156185
bad_checksum_count += 1

scripts/zephyr_module.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,10 @@
143143
license-path:
144144
required: true
145145
type: str
146+
click-through:
147+
required: false
148+
type: bool
149+
default: false
146150
url:
147151
required: true
148152
type: str
@@ -341,6 +345,7 @@ def process_blobs(module, meta):
341345
for blob in mblobs:
342346
blob['module'] = meta.get('name', None)
343347
blob['abspath'] = blobs_path / Path(blob['path'])
348+
blob['license-abspath'] = Path(module) / Path(blob['license-path'])
344349
blob['status'] = get_blob_status(blob['abspath'], blob['sha256'])
345350
blobs.append(blob)
346351

0 commit comments

Comments
 (0)