import tarfile
import tempfile
-__version__ = "1.1.3"
+__version__ = "1.1.4"
Format = False
Device = ""
argv = ["sfdisk", "-s", device]
logging.debug(" ".join(argv))
proc = subprocess.run(argv,
- stdout=subprocess.PIPE)
- size = int(proc.stdout.decode('utf-8').strip()) >> 10
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
+ stdout = proc.stdout.decode('utf-8')
+ try:
+ size = int(stdout.strip()) >> 10
+ except ValueError:
+ stderr = proc.stderr.decode('utf-8')
+ logging.error(f"Unexpected sfdisk output:\n{stdout}\n{stderr}\n")
+ sys.exit(1)
+
logging.debug(f"{device} size {size}MiB")
return size