MCPcopy
hub / github.com/corpnewt/gibMacOS / diskpart_flag

Method diskpart_flag

MakeInstall.py:229–265  ·  view source on GitHub ↗
(self, disk, as_efi=False)

Source from the content-addressed store, hash-verified

227 else: return self.get_dl_url_from_json(json_data,suffix="-RELEASE.zip")
228
229 def diskpart_flag(self, disk, as_efi=False):
230 # Sets and unsets the GUID needed for a GPT EFI partition ID
231 self.u.head("Changing ID With DiskPart")
232 print("")
233 print("Setting type as {}...".format("EFI" if as_efi else "Basic Data"))
234 print("")
235 # - EFI system partition: c12a7328-f81f-11d2-ba4b-00a0c93ec93b
236 # - Basic data partition: ebd0a0a2-b9e5-4433-87c0-68b6b72699c7
237 dp_script = "\n".join([
238 "select disk {}".format(disk.get("index",-1)),
239 "sel part 1",
240 "set id={}".format(self.efi_id if as_efi else self.bas_id)
241 ])
242 temp = tempfile.mkdtemp()
243 script = os.path.join(temp, "diskpart.txt")
244 try:
245 with open(script,"w") as f:
246 f.write(dp_script)
247 except:
248 shutil.rmtree(temp)
249 print("Error creating script!")
250 print("")
251 self.u.grab("Press [enter] to return...")
252 return
253 # Let's try to run it!
254 out = self.r.run({"args":[self.diskpart,"/s",script],"stream":True})
255 # Ditch our script regardless of whether diskpart worked or not
256 shutil.rmtree(temp)
257 print("")
258 if out[2] != 0:
259 # Error city!
260 print("DiskPart exited with non-zero status ({}). Aborting.".format(out[2]))
261 else:
262 print("Done - You may need to replug your drive for the")
263 print("changes to take effect.")
264 print("")
265 self.u.grab("Press [enter] to return...")
266
267 def diskpart_erase(self, disk, gpt=False, clover_version = None, local_file = None):
268 # Generate a script that we can pipe to diskpart to erase our disk

Callers 1

mainMethod · 0.95

Calls 4

headMethod · 0.80
writeMethod · 0.80
grabMethod · 0.80
runMethod · 0.80

Tested by

no test coverage detected