From 9ae88102828c9ab72a8ea5968f785c241b51afd3 Mon Sep 17 00:00:00 2001 From: 2Shirt <2xShirt@gmail.com> Date: Thu, 2 Jan 2020 21:22:47 -0700 Subject: [PATCH] Added real disk format section * --dry-run=True safety wheels still engaged --- scripts/wk/exe.py | 2 +- scripts/wk/hw/ddrescue.py | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/scripts/wk/exe.py b/scripts/wk/exe.py index b1d1927c..fe2f1b0d 100644 --- a/scripts/wk/exe.py +++ b/scripts/wk/exe.py @@ -78,7 +78,7 @@ def build_cmd_kwargs(cmd, minimized=False, pipe=True, shell=False, **kwargs): } # Add additional kwargs if applicable - for key in ('check', 'cwd', 'encoding', 'errors', 'stderr', 'stdout'): + for key in 'check cwd encoding errors stderr stdin stdout'.split(): if key in kwargs: cmd_kwargs[key] = kwargs[key] diff --git a/scripts/wk/hw/ddrescue.py b/scripts/wk/hw/ddrescue.py index a80d158b..c84eafb7 100644 --- a/scripts/wk/hw/ddrescue.py +++ b/scripts/wk/hw/ddrescue.py @@ -701,10 +701,20 @@ class State(): with open(script_path, 'w') as _f: _f.write('\n'.join(sfdisk_script)) + # Skip real format for dry runs + if dry_run: + return + # Format disk - if not dry_run: - # TODO - pass + with open(script_path, 'r') as _f: + proc = exe.run_program( + cmd=['sudo', 'sfdisk', self.destination.path], + stdin=_f, + check=False, + ) + if proc.returncode != 0: + std.print_error('Error(s) encoundtered while formatting destination') + raise std.GenericAbort() # Update settings settings['Needs Format'] = not dry_run