MCPcopy Create free account
hub / github.com/TactilityProject/Tactility / process_device

Function process_device

Buildscripts/CDN/generate-firmware-files.py:132–174  ·  view source on GitHub ↗
(in_path: str, out_path: str, device_directory: str, device_id: str, device_properties: RawConfigParser, version: str)

Source from the content-addressed store, hash-verified

130
131
132def process_device(in_path: str, out_path: str, device_directory: str, device_id: str, device_properties: RawConfigParser, version: str):
133 in_device_path = os.path.join(in_path, device_directory)
134 in_device_binaries_path = os.path.join(in_device_path, "Binaries")
135 if not os.path.isdir(in_device_binaries_path):
136 exit_with_error(f"Could not find directory {in_device_binaries_path}")
137 flasher_args_path = os.path.join(in_device_binaries_path, "flasher_args.json")
138 if not os.path.isfile(flasher_args_path):
139 exit_with_error(f"Could not find flasher arguments path {flasher_args_path}")
140 with open(flasher_args_path) as json_data:
141 flasher_args = json.load(json_data)
142 flash_files = flasher_args["flash_files"]
143 device_vendor = get_property_or_exit(device_properties, "general", "vendor")
144 device_name = get_property_or_exit(device_properties, "general", "name")
145 manifest = Manifest(
146 name=f"Tactility for {device_vendor} {device_name}",
147 version=version,
148 new_install_prompt_erase="true",
149 funding_url="https://github.com/sponsors/ByteWelder",
150 builds=[
151 ManifestBuild(
152 chipFamily=to_manifest_chip_name(flasher_args["extra_esptool_args"]["chip"]),
153 parts=[]
154 )
155 ]
156 )
157 for offset in flash_files:
158 flash_file_entry = flash_files[offset]
159 flash_file_entry_name = os.path.basename(flash_file_entry)
160 in_flash_file_path = os.path.join(in_device_binaries_path, flash_file_entry)
161 out_flash_file_name = f"{device_id}-{flash_file_entry_name}"
162 out_flash_file_path = os.path.join(out_path, out_flash_file_name)
163 if VERBOSE:
164 print(f"Copying {in_flash_file_path} -> {out_flash_file_path}")
165 shutil.copy(in_flash_file_path, out_flash_file_path)
166 manifest.builds[0].parts.append(
167 ManifestBuildPart(
168 path=out_flash_file_name,
169 offset=int(offset, 16)
170 )
171 )
172 json_manifest_path = os.path.join(out_path, f"{device_id}.json")
173 with open(json_manifest_path, 'w') as json_manifest_file:
174 json.dump(asdict(manifest), json_manifest_file, indent=2)
175
176
177def get_git_commit_hash():

Callers 1

mainFunction · 0.85

Calls 9

openFunction · 0.85
ManifestClass · 0.85
ManifestBuildClass · 0.85
to_manifest_chip_nameFunction · 0.85
ManifestBuildPartClass · 0.85
joinMethod · 0.80
loadMethod · 0.80
exit_with_errorFunction · 0.70
get_property_or_exitFunction · 0.70

Tested by

no test coverage detected