Merge pull request #383 from shinji-s/devel

Stop catching subprocess.CalledProcessError. (No point in re-raising …
pull/402/head
multibootusb 6 years ago committed by GitHub
commit 9750ec67e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -305,21 +305,16 @@ class Linux(Base):
def gpt_device(self, dev_name):
disk_dev = dev_name.rstrip('0123456789')
try:
cmd = ['parted', disk_dev, '-s', 'print']
with open(os.devnull) as devnull:
p = subprocess.Popen(cmd, stdout=subprocess.PIPE,
stderr=subprocess.PIPE, stdin=devnull)
_cmd_out, _err_out = p.communicate()
p.wait()
if p.returncode != 0:
lang = os.getenv('LANG')
encoding = lang.rsplit('.')[-1] if lang else 'utf-8'
raise RuntimeError(str(_err_out, encoding))
except subprocess.CalledProcessError as e:
# Control is unlikely to reach here because Popen() is not
# supposed to raise this exception.
raise RuntimeError(str(e))
cmd = ['parted', disk_dev, '-s', 'print']
with open(os.devnull) as devnull:
p = subprocess.Popen(cmd, stdout=subprocess.PIPE,
stderr=subprocess.PIPE, stdin=devnull)
_cmd_out, _err_out = p.communicate()
p.wait()
if p.returncode != 0:
lang = os.getenv('LANG')
encoding = lang.rsplit('.')[-1] if lang else 'utf-8'
raise RuntimeError(str(_err_out, encoding))
subprocess.check_call(['partprobe', disk_dev])
if b'msdos' in _cmd_out:
return False

Loading…
Cancel
Save