discstation 0.1.6 → 0.1.7

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "discstation",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "DiscStation optical-media appliance host — one cross-OS installer",
5
5
  "bin": {
6
6
  "discstation-setup": "scripts/setup.mjs"
@@ -1110,6 +1110,8 @@ def drive_status(device):
1110
1110
  does not disturb the tray. Never raises."""
1111
1111
  if not device:
1112
1112
  return "unknown"
1113
+ if discstation_host.system_name() != "linux":
1114
+ return discstation_host.drive_status()
1113
1115
  try:
1114
1116
  fd = os.open(device, os.O_RDONLY | os.O_NONBLOCK)
1115
1117
  except OSError:
@@ -144,6 +144,25 @@ def disc_device():
144
144
  raise FileNotFoundError("No optical disc drive found; set DISC_DEVICE explicitly")
145
145
 
146
146
 
147
+ def drive_status():
148
+ """Non-Linux equivalent of the CDROM_DRIVE_STATUS ioctl.
149
+ Returns 'disc' | 'no_disc' | 'unknown'. macOS: parse `drutil status`."""
150
+ if system_name() != "darwin":
151
+ return "unknown"
152
+ try:
153
+ r = subprocess.run(["/usr/bin/drutil", "status"], capture_output=True,
154
+ text=True, check=False, timeout=4)
155
+ except (OSError, subprocess.TimeoutExpired):
156
+ return "unknown"
157
+ text = (r.stdout + r.stderr).lower()
158
+ if "no media" in text or "media is not present" in text:
159
+ return "no_disc"
160
+ if "name: /dev/disk" in text or "type: cd" in text or "type: dvd" in text \
161
+ or "type: bd" in text:
162
+ return "disc"
163
+ return "unknown"
164
+
165
+
147
166
  def _drutil_media_properties():
148
167
  result = subprocess.run(["/usr/bin/drutil", "status"], capture_output=True, text=True, check=False, timeout=3)
149
168
  text = result.stdout + result.stderr