blockdevices() catching errors

This commit is contained in:
Sebastian Hildebrandt 2020-11-09 07:04:03 +01:00
parent e46e77570d
commit b0d6e968ec
5 changed files with 43 additions and 23 deletions

View File

@ -30,6 +30,7 @@ For major (breaking) changes - version 3 and 2 see end of page.
| Version | Date | Comment | | Version | Date | Comment |
| -------------- | -------------- | -------- | | -------------- | -------------- | -------- |
| 4.29.2 | 2020-11-09 | `blockdevices()` catch errors |
| 4.29.1 | 2020-11-08 | `cpu()`, `system()` better parsing Raspberry Pi revision codes | | 4.29.1 | 2020-11-08 | `cpu()`, `system()` better parsing Raspberry Pi revision codes |
| 4.29.0 | 2020-11-08 | `fsSize()` correct fs type detection macOS (HFS, APFS, NFS) | | 4.29.0 | 2020-11-08 | `fsSize()` correct fs type detection macOS (HFS, APFS, NFS) |
| 4.28.1 | 2020-11-05 | code cleanup, removing debug console.log() | | 4.28.1 | 2020-11-05 | code cleanup, removing debug console.log() |

View File

@ -83,6 +83,11 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr>
<th scope="row">4.29.2</th>
<td>2020-11-09</td>
<td><span class="code">blockdevices()</span> catch error</td>
</tr>
<tr> <tr>
<th scope="row">4.29.1</th> <th scope="row">4.29.1</th>
<td>2020-11-08</td> <td>2020-11-08</td>

View File

@ -168,7 +168,7 @@
<img class="logo" src="assets/logo.png"> <img class="logo" src="assets/logo.png">
<div class="title">systeminformation</div> <div class="title">systeminformation</div>
<div class="subtitle"><span id="typed"></span></div> <div class="subtitle"><span id="typed"></span></div>
<div class="version">Current Version: <span id="version">4.29.1</span></div> <div class="version">Current Version: <span id="version">4.29.2</span></div>
<button class="btn btn-light" onclick="location.href='https://github.com/sebhildebrandt/systeminformation'">View on Github <i class=" fab fa-github"></i></button> <button class="btn btn-light" onclick="location.href='https://github.com/sebhildebrandt/systeminformation'">View on Github <i class=" fab fa-github"></i></button>
</div> </div>
<div class="down"> <div class="down">

View File

@ -135,6 +135,16 @@
<td></td> <td></td>
<td>SKU number</td> <td>SKU number</td>
</tr> </tr>
<tr>
<td></td>
<td>raspberry</td>
<td>X</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td>Additional Raspberry-specific information<br>manufacturer, processor, type, revision<br>Raspberry only</td>
</tr>
<tr class="example"> <tr class="example">
<td></td> <td></td>
<td colspan="7"> <td colspan="7">

View File

@ -268,30 +268,34 @@ function parseDevices(lines) {
function parseBlk(lines) { function parseBlk(lines) {
let data = []; let data = [];
lines.filter(line => line !== '').forEach((line) => { try {
line = decodeURIComponent(line.replace(/\\x/g, '%')); lines.filter(line => line !== '').forEach((line) => {
line = line.replace(/\\/g, '\\\\'); line = decodeURIComponent(line.replace(/\\x/g, '%'));
let disk = JSON.parse(line); line = line.replace(/\\/g, '\\\\');
data.push({ let disk = JSON.parse(line);
'name': disk.name, data.push({
'type': disk.type, 'name': disk.name,
'fstype': disk.fstype, 'type': disk.type,
'mount': disk.mountpoint, 'fstype': disk.fstype,
'size': parseInt(disk.size), 'mount': disk.mountpoint,
'physical': (disk.type === 'disk' ? (disk.rota === '0' ? 'SSD' : 'HDD') : (disk.type === 'rom' ? 'CD/DVD' : '')), 'size': parseInt(disk.size),
'uuid': disk.uuid, 'physical': (disk.type === 'disk' ? (disk.rota === '0' ? 'SSD' : 'HDD') : (disk.type === 'rom' ? 'CD/DVD' : '')),
'label': disk.label, 'uuid': disk.uuid,
'model': disk.model, 'label': disk.label,
'serial': disk.serial, 'model': disk.model,
'removable': disk.rm === '1', 'serial': disk.serial,
'protocol': disk.tran, 'removable': disk.rm === '1',
'group': disk.group, 'protocol': disk.tran,
'group': disk.group,
});
}); });
}); data = util.unique(data);
data = util.sortByKey(data, ['type', 'name']);
return data;
} catch (e) {
return [];
}
data = util.unique(data);
data = util.sortByKey(data, ['type', 'name']);
return data;
} }
function blkStdoutToObject(stdout) { function blkStdoutToObject(stdout) {