dwipe 1.0.3__tar.gz → 1.0.5__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.
dwipe-1.0.5/.gitignore ADDED
@@ -0,0 +1,6 @@
1
+ .vscode/
2
+ */__pycache/
3
+ venv.zd/
4
+ *.pyc
5
+ *egg-info*
6
+ dist/
@@ -1,20 +1,18 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: dwipe
3
- Version: 1.0.3
3
+ Version: 1.0.5
4
4
  Summary: A tool to wipe disks and partitions for Linux
5
- Author-email: Joe Defen <joedef@google.com>
6
- License: MIT
7
- Project-URL: Homepage, https://github.com/joedefen/dwipe
8
- Project-URL: Bug Tracker, https://github.com/joedefen/dwipe/issues
9
5
  Keywords: disk,partition,wipe,clean,scrub
6
+ Author-email: Joe Defen <joedef@google.com>
7
+ Requires-Python: >=3.8
8
+ Description-Content-Type: text/markdown
10
9
  Classifier: Programming Language :: Python :: 3
11
10
  Classifier: License :: OSI Approved :: MIT License
12
11
  Classifier: Operating System :: POSIX :: Linux
13
- Requires-Python: >=3.8
14
- Description-Content-Type: text/markdown
15
12
  License-File: LICENSE
16
- Requires-Dist: importlib-metadata; python_version < "3.8"
17
- Requires-Dist: psutil>=5.9
13
+ Requires-Dist: importlib-metadata; python_version<"3.8"
14
+ Project-URL: Bug Tracker, https://github.com/joedefen/dwipe/issues
15
+ Project-URL: Homepage, https://github.com/joedefen/dwipe
18
16
 
19
17
  # dwipe
20
18
  `dwipe` is tool to wipe disks and partitions for Linux helps secure you data. `dwipes` aims to reduce mistakes by providing ample information about your devices during selection.
dwipe-1.0.5/deploy ADDED
@@ -0,0 +1,9 @@
1
+ #!/bin/bash
2
+ script_dir=$(dirname "$0")
3
+ set -ex
4
+ cd ${script_dir}
5
+ rm -rf ./dist
6
+ python3 -m pip install build --break-system-packages
7
+ python3 -m build
8
+ pip install -e . --break-system-packages
9
+
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env python3
2
- """ TBD
3
-
4
-
2
+ """
3
+ dwipe: curse based tool to wipe physical disks or partitions including
4
+ markers to know their state when wiped.
5
5
  """
6
6
  # pylint: disable=too-many-branches,too-many-statements,import-outside-toplevel
7
7
  # pylint: disable=too-many-instance-attributes,invalid-name
@@ -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:
@@ -284,6 +290,7 @@ class DeviceInfo:
284
290
  entry.fstype = device.get('fstype', '')
285
291
  if entry.fstype is None:
286
292
  entry.fstype = ''
293
+ entry.type = device.get('type', '')
287
294
  entry.label = device.get('label', '')
288
295
  if not entry.label:
289
296
  entry.label=device.get('partlabel', '')
@@ -313,7 +320,7 @@ class DeviceInfo:
313
320
 
314
321
  # Run the `lsblk` command and get its output in JSON format with additional columns
315
322
  result = subprocess.run(['lsblk', '-J', '--bytes', '-o',
316
- 'NAME,MAJ:MIN,FSTYPE,LABEL,PARTLABEL,FSUSE%,SIZE,MOUNTPOINTS', ],
323
+ 'NAME,MAJ:MIN,FSTYPE,TYPE,LABEL,PARTLABEL,FSUSE%,SIZE,MOUNTPOINTS', ],
317
324
  stdout=subprocess.PIPE, text=True, check=False)
318
325
  parsed_data = json.loads(result.stdout)
319
326
  entries = {}
@@ -407,47 +414,10 @@ class DeviceInfo:
407
414
 
408
415
  def get_disk_partitions(self, nss):
409
416
  """ Determine which partitions we want some are bogus like zram """
410
-
411
- def whitelisted(device_name):
412
- """Check if device_name matches any pattern in whitelist
413
- which are the disk devices."""
414
- WHITELIST = ['nvme*', 'sd*', 'hd*', 'mmcblk*']
415
- for pattern in WHITELIST:
416
- if fnmatch(device_name, pattern):
417
- return True
418
- return False
419
-
420
- def blacklisted(device_name):
421
- """Check if device_name matches any pattern in black list
422
- which are know not to be physical disks."""
423
- BLACKLIST = ['zram*', 'ram*', 'dm-*', 'loop*', 'sr*']
424
- for pattern in BLACKLIST:
425
- if fnmatch(device_name, pattern):
426
- return 'blkLst'
427
- return ''
428
-
429
- def writable(device_name):
430
- """Check if the device is writable."""
431
- device_path = f'/dev/{device_name}'
432
- try: # Check if the device file exists and is writable
433
- return os.access(device_path, os.W_OK)
434
- except FileNotFoundError:
435
- return False
436
-
437
417
  ok_nss = {}
438
418
  for name, ns in nss.items():
439
- if ns.major in self.disk_majors or whitelisted(name):
419
+ if ns.type in ('disk', 'part'):
440
420
  ok_nss[name] = ns
441
- continue
442
- if blacklisted(name):
443
- continue
444
- if writable(name):
445
- if self.DB:
446
- print(r'DB:include {repr(name)} [not white/black but writable]')
447
- ok_nss[name] = ns
448
- continue
449
- if self.DB:
450
- print(r'DB:exclude {repr(name)} [not white/black but unwritable]')
451
421
  return ok_nss
452
422
 
453
423
  def compute_field_widths(self, nss):
@@ -755,6 +725,8 @@ class DiskWipe:
755
725
  line += ' Stop' if self.job_cnt > 0 else ''
756
726
  line += f' quit ?:help /{self.prev_filter} Mode='
757
727
  line += f'{"Random" if self.opts.random else "Zeros"}'
728
+ if self.opts.dry_run:
729
+ line += ' DRY-RUN'
758
730
  # for action in self.actions:
759
731
  # line += f' {action[0]}:{action}'
760
732
  return line[1:]
@@ -834,15 +806,24 @@ class DiskWipe:
834
806
  to='s' if partition.job.do_abort else 'W'
835
807
  self.set_state(partition, to=to)
836
808
  partition.dflt = to
837
- partition.job = None
838
809
  partition.mounts = []
839
810
  self.job_cnt -= 1
811
+ if partition.job.exception:
812
+ self.win.stop_curses()
813
+ print('\n\n\n========== ALERT =========\n')
814
+ print(f' FAILED: wipe {repr(partition.name)}')
815
+ print(partition.job.exception)
816
+ input('\n\n===== Press ENTER to continue ====> ')
817
+ self.win._start_curses()
818
+
819
+ partition.job = None
840
820
  if partition.job:
841
821
  elapsed, pct, rate, until = partition.job.get_status()
842
822
  partition.state = pct
843
823
  partition.mounts = [f'{elapsed} {rate} REM:{until}']
844
824
 
845
- if partition.parent and self.partitions[partition.parent].state == 'Lock':
825
+ if partition.parent and partition.parent in self.partitions and (
826
+ self.partitions[partition.parent].state == 'Lock'):
846
827
  continue
847
828
 
848
829
  if wanted(name) or partition.job:
@@ -0,0 +1,30 @@
1
+ [build-system]
2
+ requires = ["flit_core>=3.4"]
3
+ build-backend = "flit_core.buildapi"
4
+
5
+ [project]
6
+ name = "dwipe"
7
+ version = "1.0.5"
8
+ description = "A tool to wipe disks and partitions for Linux"
9
+ authors = [
10
+ { name = "Joe Defen", email = "joedef@google.com" }
11
+ ]
12
+ readme = "README.md"
13
+ license = { text = "MIT" }
14
+ requires-python = ">=3.8"
15
+ keywords = ["disk", "partition", "wipe", "clean", "scrub"]
16
+ classifiers = [
17
+ "Programming Language :: Python :: 3",
18
+ "License :: OSI Approved :: MIT License",
19
+ "Operating System :: POSIX :: Linux"
20
+ ]
21
+ dependencies = [
22
+ 'importlib-metadata; python_version<"3.8"',
23
+ ]
24
+
25
+ [project.urls]
26
+ "Homepage" = "https://github.com/joedefen/dwipe"
27
+ "Bug Tracker" = "https://github.com/joedefen/dwipe/issues"
28
+
29
+ [project.scripts]
30
+ dwipe = "dwipe.main:main"
dwipe-1.0.5/run.sh ADDED
@@ -0,0 +1,9 @@
1
+ #!/bin/bash
2
+
3
+ SRC="$(dirname "$0")/src"
4
+
5
+ set -x
6
+ ##### choose one:
7
+
8
+ PYTHONPATH="$SRC" python3 -m dwipe.main "$@"
9
+ # PYTHONPATH="$SRC" python3 src/dwipe/main.py "$@"
dwipe-1.0.3/PKG-INFO DELETED
@@ -1,74 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: dwipe
3
- Version: 1.0.3
4
- Summary: A tool to wipe disks and partitions for Linux
5
- Author-email: Joe Defen <joedef@google.com>
6
- License: MIT
7
- Project-URL: Homepage, https://github.com/joedefen/dwipe
8
- Project-URL: Bug Tracker, https://github.com/joedefen/dwipe/issues
9
- Keywords: disk,partition,wipe,clean,scrub
10
- Classifier: Programming Language :: Python :: 3
11
- Classifier: License :: OSI Approved :: MIT License
12
- Classifier: Operating System :: POSIX :: Linux
13
- Requires-Python: >=3.8
14
- Description-Content-Type: text/markdown
15
- License-File: LICENSE
16
- Requires-Dist: importlib-metadata; python_version < "3.8"
17
- Requires-Dist: psutil>=5.9
18
-
19
- # dwipe
20
- `dwipe` is tool to wipe disks and partitions for Linux helps secure you data. `dwipes` aims to reduce mistakes by providing ample information about your devices during selection.
21
-
22
- > **Quick Start:**
23
- > * Install `dwipe` using `pipx install dwipe`, or however you install python scripts from PyPi.org.
24
- > * Run `dwipe` from a terminal and observe the context sensitive help on the 1st line.
25
-
26
- To help with your disk scrubbing, `dwipe`:
27
- * shows disks and partitions that can be wiped along with selected information to help choose them (i.e.,; labels, sizes, and types); disallowed are mounted devices and overlapping wipes and manually "locked" disks.
28
- * updates the device list when it changes; newly added devices are marked differently to make it easier to see them.
29
- * supports starting multiple wipes, shows their progress, and shows completion states.
30
- * supports either zeroing devices or filling with random data.
31
- * supports filtering for devices by name/pattern in case of too many for one screen, etc.
32
- * supports stopping wipes in progress.
33
-
34
- `dwipe` shows file system labels, and if not the partition label. It is best practice to label partitions and file systems well to make selection easier.
35
-
36
- ## Usage
37
- > Simply run `dwipe` from the command line w/o arguments normally. Its command line arguments mostly for debugging including "--dry-run" which lets you test/practice the interface w/o risk.
38
-
39
- Here is a typical screen:
40
-
41
- ![dwipe-help](https://raw.githubusercontent.com/joedefen/dwipe/master/resources/dwipe-main-screen.png?raw=true)
42
-
43
- The possible state values and meanings are:
44
- * **-** : indicates the device is ready for wiping if desired.
45
- * **^** : similar to **-**, but also indicates the device was added after `dwipe` started
46
- * **Mnt** : the partition is mounted or the disk has partitions that are mounted. You cannot wipe the device in this state.
47
- * **N%** : if a percent is seen, then a wipe is in progress.
48
- * **STOP** : indicates that a wipe is being stopped.
49
- * **s** : indicates that a wipe was stopped (so the device is partly wiped) and wiping can be restarted.
50
- * **W** : indicates that a wipe was completed and wiping can be restarted.
51
- * **Lock** : indicates that the disk is manually locked, its partitions are hidden, and you cannot wipe the disk or its partitions.
52
- * **Unlk** : indicates that the disk was manually unlocked after a manual lock; this is a transitory state.
53
-
54
- The top line shows available actions and other info. Some actions are context sensitive:
55
- * **w** : **wipe** : wipe the selected device; before starting, you must confirm your intent.
56
- * **s** : **stop** : stops the selected wipe in progress (can take a while).
57
- * **S** : **Stop** : stops all wipes in progress (can take a while).
58
- * **q** : **quit** : quits the app after stopping wipes in progress.
59
- * **?** : **help** : bring up help screen with all actions and navigation keys explained.
60
- * **/** : **search** : limits the show devices to those matching the given regex plus all wipes in progress.
61
-
62
- The top line shows the "Mode" which is Random or Zeros. For some disks, zeroing may be faster than random. Typing **r** toggles the mode (this is seen on the help screen). When Random, a wiped device is filled with random data and then the first 16KB is zeroed.
63
-
64
- The write rate and estimating remaining times are shown when wiping a device. Due to write queueing, the initial rates may be inflated, final rates are deflated, and the times are optimistic.
65
-
66
- The 'W' (Wiped) and 's' (partly wiped) states are disk persistent. For those states, more information is provided about the wipe including when and percent complete.
67
-
68
-
69
- ### The Help Screen
70
- When **?** is typed, the help screen looks like:
71
-
72
- ![dwipe-help](https://raw.githubusercontent.com/joedefen/dwipe/master/resources/dwipe-help-screen.png?raw=true)
73
-
74
- You can navigate the list of devices with arrow keys and vi-like keys.
@@ -1,89 +0,0 @@
1
- # HOW TO DEVELOP
2
-
3
- #
4
- # Prep Work (ensure need modules are up-to-date):
5
- # sudo apt install python3-pip
6
- # sudo apt install python3-pip-whl
7
- # pip install build --break-system-packages
8
- # sudo apt install twine
9
- # -- antiquated way
10
- # sudo pacman -Syu python-pip
11
- # sudo pacman -Syu python-build
12
- # sudo pacman -Syu python-twine
13
- # -- antiquated way
14
- # python3 -m pip install --upgrade pip
15
- # python3 -m pip install --upgrade build
16
- # python3 -m pip install --upgrade twine
17
- #
18
- # Optionally, `python3 -m venv venv`, and then
19
- # - source env/bin/activate # to activate
20
- # - deactivate # to deactivate
21
- #
22
- # For a "live" local install:
23
- # ./deploy # uninstall: pip uninstall dwipe # to remove
24
- # To run: ./run.sh
25
-
26
- # HOW TO PUBLISH...
27
- # PUBLIC Build and deploy (from project directory):
28
- # ## BUMP the version (below in [project])
29
- # rm -rf dist && python3 -m build; ls dist/. && python3 -m twine upload dist/*
30
- # NOTE: # keyring --disable # may be required
31
- # ## Enter __token__ and the saved TOKEN (in bitwarden)
32
- # pipx upgrade dwipe || pipx install dwipe # >= python3.11
33
- # --OR-- sudo python3 -m pip install dwipe # <= python3.10
34
- # ## VISIT https://pypi.org/project/dwipe and delete old versions
35
- #
36
- # TEST Build and test (from project directory):
37
- # ## BUMP the version (below in [project])
38
- # rm -r dist; python3 -m build
39
- # python3 -m twine upload --repository testpypi dist/* # keyring --disable # may be required
40
- # ## Enter __token__ and the saved TOKEN (in bitwarden)
41
- # sudo python3 -m pip install --upgrade --index-url https://test.pypi.org/simple/ --no-deps --break-system-packages dwipe
42
- # ## VISIT https://test.pypi.org/project/dwipe and delete old versions
43
-
44
- [build-system]
45
- requires = ["setuptools>=42", "wheel"]
46
- build-backend = "setuptools.build_meta"
47
-
48
- [project]
49
- name = "dwipe"
50
- version = "1.0.3"
51
- description = "A tool to wipe disks and partitions for Linux"
52
- authors = [
53
- { name = "Joe Defen", email = "joedef@google.com" }
54
- ]
55
- readme = "README.md"
56
- license = { text = "MIT" }
57
- requires-python = ">=3.8"
58
-
59
- keywords = ["disk", "partition", "wipe", "clean", "scrub" ]
60
-
61
- classifiers = [
62
- "Programming Language :: Python :: 3",
63
- "License :: OSI Approved :: MIT License",
64
- "Operating System :: POSIX :: Linux"
65
- ]
66
- dependencies = [
67
- 'importlib-metadata; python_version<"3.8"',
68
- 'psutil>=5.9',
69
- ]
70
-
71
- [project.urls]
72
- "Homepage" = "https://github.com/joedefen/dwipe"
73
- "Bug Tracker" = "https://github.com/joedefen/dwipe/issues"
74
-
75
- [project.scripts]
76
- dwipe = "dwipe.main:main"
77
-
78
- [tool.setuptools]
79
- package-dir = {"" = "src"}
80
-
81
- [tool.setuptools.packages.find]
82
- where = ["src"]
83
-
84
- [tool.setuptools.package-data]
85
-
86
- exclude = [
87
- "__pycache__",
88
- ]
89
-
dwipe-1.0.3/setup.cfg DELETED
@@ -1,4 +0,0 @@
1
- [egg_info]
2
- tag_build =
3
- tag_date = 0
4
-
@@ -1,12 +0,0 @@
1
- LICENSE
2
- README.md
3
- pyproject.toml
4
- src/dwipe/PowerWindow.py
5
- src/dwipe/__init__.py
6
- src/dwipe/main.py
7
- src/dwipe.egg-info/PKG-INFO
8
- src/dwipe.egg-info/SOURCES.txt
9
- src/dwipe.egg-info/dependency_links.txt
10
- src/dwipe.egg-info/entry_points.txt
11
- src/dwipe.egg-info/requires.txt
12
- src/dwipe.egg-info/top_level.txt
@@ -1,2 +0,0 @@
1
- [console_scripts]
2
- dwipe = dwipe.main:main
@@ -1,4 +0,0 @@
1
- psutil>=5.9
2
-
3
- [:python_version < "3.8"]
4
- importlib-metadata
@@ -1 +0,0 @@
1
- dwipe
File without changes
File without changes
File without changes
File without changes