Update disk setup step to use context manager

Signed-off-by: brianherrera <briher@amazon.com>
monroegm-disable-blank-issue-2
brianherrera 4 years ago
parent 56f0ea68a6
commit ac8201a2fa
No known key found for this signature in database
GPG Key ID: FC67BB5F533BAE04

@ -325,24 +325,22 @@ def mount_volume_to_device(created):
# Verify drive is in an offline state.
# Some Windows configs will automatically set new drives as online causing diskpart setup script to fail.
offline_drive()
f = tempfile.NamedTemporaryFile(delete=False)
f.write("""
select disk 1
online disk
attribute disk clear readonly
""".encode('utf-8')) # assume disk # for now
with tempfile.NamedTemporaryFile(delete=False) as f:
f.write("""
select disk 1
online disk
attribute disk clear readonly
""".encode('utf-8')) # assume disk # for now
if created:
print('Creating filesystem on new volume')
f.write("""create partition primary
select partition 1
format quick fs=ntfs
assign
active
""".encode('utf-8'))
f.close()
select partition 1
format quick fs=ntfs
assign
active
""".encode('utf-8'))
subprocess.call(['diskpart', '/s', f.name])

Loading…
Cancel
Save