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): def gpt_device(self, dev_name):
disk_dev = dev_name.rstrip('0123456789') disk_dev = dev_name.rstrip('0123456789')
try: cmd = ['parted', disk_dev, '-s', 'print']
cmd = ['parted', disk_dev, '-s', 'print'] with open(os.devnull) as devnull:
with open(os.devnull) as devnull: p = subprocess.Popen(cmd, stdout=subprocess.PIPE,
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=devnull)
stderr=subprocess.PIPE, stdin=devnull) _cmd_out, _err_out = p.communicate()
_cmd_out, _err_out = p.communicate() p.wait()
p.wait() if p.returncode != 0:
if p.returncode != 0: lang = os.getenv('LANG')
lang = os.getenv('LANG') encoding = lang.rsplit('.')[-1] if lang else 'utf-8'
encoding = lang.rsplit('.')[-1] if lang else 'utf-8' raise RuntimeError(str(_err_out, encoding))
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))
subprocess.check_call(['partprobe', disk_dev]) subprocess.check_call(['partprobe', disk_dev])
if b'msdos' in _cmd_out: if b'msdos' in _cmd_out:
return False return False

Loading…
Cancel
Save