dwipe 1.0.3__tar.gz → 1.0.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dwipe
3
- Version: 1.0.3
3
+ Version: 1.0.4
4
4
  Summary: A tool to wipe disks and partitions for Linux
5
5
  Author-email: Joe Defen <joedef@google.com>
6
6
  License: MIT
@@ -47,7 +47,7 @@ build-backend = "setuptools.build_meta"
47
47
 
48
48
  [project]
49
49
  name = "dwipe"
50
- version = "1.0.3"
50
+ version = "1.0.4"
51
51
  description = "A tool to wipe disks and partitions for Linux"
52
52
  authors = [
53
53
  { name = "Joe Defen", email = "joedef@google.com" }
@@ -79,6 +79,7 @@ class WipeJob:
79
79
  self.total_written = 0
80
80
  self.wr_hists = [] # list of (mono, written)
81
81
  self.done = False
82
+ self.exception = None # in case of issues
82
83
 
83
84
  @staticmethod
84
85
  def start_job(device_path, total_size, opts):
@@ -185,38 +186,43 @@ class WipeJob:
185
186
  self.total_written = 0 # Track total bytes written
186
187
  is_random = self.opts.random
187
188
 
188
- with open(self.device_path, 'wb') as device:
189
- # for loop in range(10000000000):
190
- offset = 0
191
- chunk = memoryview(WipeJob.zero_buffer)
192
- while True:
193
- if self.do_abort:
194
- break
195
- if is_random:
196
- offset = random.randint(0, WipeJob.BUFFER_SIZE - WipeJob.WRITE_SIZE)
197
- # Use memoryview to avoid copying the data
198
- chunk = memoryview(WipeJob.buffer)[offset:offset + WipeJob.WRITE_SIZE]
199
-
200
- if self.opts.dry_run:
201
- bytes_written = self.total_size // 120
202
- time.sleep(0.25)
203
- else:
204
- try:
205
- bytes_written = device.write(chunk)
206
- except Exception:
207
- bytes_written = 0
208
- self.total_written += bytes_written
209
- # Optional: Check for errors or incomplete writes
210
- if bytes_written < WipeJob.WRITE_SIZE:
211
- break
212
- if self.opts.dry_run and self.total_written >= self.total_size:
213
- break
214
- # clear the beginning of device whether aborted or not
215
- # if we have started writing + status in JSON
216
- if not self.opts.dry_run and self.total_written > 0 and is_random:
217
- device.seek(0)
218
- # chunk = memoryview(WipeJob.zero_buffer)
219
- bytes_written = device.write(self.prep_marker_buffer(is_random))
189
+ try:
190
+ with open(self.device_path, 'wb') as device:
191
+ # for loop in range(10000000000):
192
+ offset = 0
193
+ chunk = memoryview(WipeJob.zero_buffer)
194
+ while True:
195
+ # foo = 1/0 # to force exception only
196
+ if self.do_abort:
197
+ break
198
+ if is_random:
199
+ offset = random.randint(0, WipeJob.BUFFER_SIZE - WipeJob.WRITE_SIZE)
200
+ # Use memoryview to avoid copying the data
201
+ chunk = memoryview(WipeJob.buffer)[offset:offset + WipeJob.WRITE_SIZE]
202
+
203
+ if self.opts.dry_run:
204
+ bytes_written = self.total_size // 120
205
+ time.sleep(0.25)
206
+ else:
207
+ try:
208
+ bytes_written = device.write(chunk)
209
+ except Exception:
210
+ bytes_written = 0
211
+ self.total_written += bytes_written
212
+ # Optional: Check for errors or incomplete writes
213
+ if bytes_written < WipeJob.WRITE_SIZE:
214
+ break
215
+ if self.opts.dry_run and self.total_written >= self.total_size:
216
+ break
217
+ # clear the beginning of device whether aborted or not
218
+ # if we have started writing + status in JSON
219
+ if not self.opts.dry_run and self.total_written > 0:
220
+ device.seek(0)
221
+ # chunk = memoryview(WipeJob.zero_buffer)
222
+ bytes_written = device.write(self.prep_marker_buffer(is_random))
223
+ except Exception:
224
+ self.exception = traceback.format_exc()
225
+
220
226
  self.done = True
221
227
 
222
228
  class DeviceInfo:
@@ -755,6 +761,8 @@ class DiskWipe:
755
761
  line += ' Stop' if self.job_cnt > 0 else ''
756
762
  line += f' quit ?:help /{self.prev_filter} Mode='
757
763
  line += f'{"Random" if self.opts.random else "Zeros"}'
764
+ if self.opts.dry_run:
765
+ line += ' DRY-RUN'
758
766
  # for action in self.actions:
759
767
  # line += f' {action[0]}:{action}'
760
768
  return line[1:]
@@ -834,9 +842,17 @@ class DiskWipe:
834
842
  to='s' if partition.job.do_abort else 'W'
835
843
  self.set_state(partition, to=to)
836
844
  partition.dflt = to
837
- partition.job = None
838
845
  partition.mounts = []
839
846
  self.job_cnt -= 1
847
+ if partition.job.exception:
848
+ self.win.stop_curses()
849
+ print('\n\n\n========== ALERT =========\n')
850
+ print(f' FAILED: wipe {repr(partition.name)}')
851
+ print(partition.job.exception)
852
+ input('\n\n===== Press ENTER to continue ====> ')
853
+ self.win._start_curses()
854
+
855
+ partition.job = None
840
856
  if partition.job:
841
857
  elapsed, pct, rate, until = partition.job.get_status()
842
858
  partition.state = pct
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dwipe
3
- Version: 1.0.3
3
+ Version: 1.0.4
4
4
  Summary: A tool to wipe disks and partitions for Linux
5
5
  Author-email: Joe Defen <joedef@google.com>
6
6
  License: MIT
File without changes
File without changes
File without changes
File without changes
File without changes