graphics() and others fix catch errors

This commit is contained in:
Sebastian Hildebrandt 2023-06-28 19:34:14 +02:00
parent 2b99e1e682
commit b75e649a01
7 changed files with 93 additions and 63 deletions

View File

@ -82,6 +82,7 @@ For major (breaking) changes - **version 4, 3 and 2** - see end of page.
| Version | Date | Comment |
| ------- | ---------- | --------------------------------------------------------------------------------------------------- |
| 5.18.6 | 2023-06-28 | `graphics()` fixed catched errors (mac OS) |
| 5.18.5 | 2023-06-26 | `cpu()` fixed parsing (mac OS) |
| 5.18.4 | 2023-06-22 | `graphics()` fixed parsing (mac OS) |
| 5.18.3 | 2023-06-09 | `tests` improved key handling, updated docs |

View File

@ -57,6 +57,11 @@
</tr>
</thead>
<tbody>
<tr>
<th scope="row">5.18.6</th>
<td>2023-06-28</td>
<td><span class="code">graphics()</span> fixed catch errors (mac OS)</td>
</tr>
<tr>
<th scope="row">5.18.5</th>
<td>2023-06-26</td>

View File

@ -170,7 +170,7 @@
<img class="logo" src="assets/logo.png" alt="logo">
<div class="title">systeminformation</div>
<div class="subtitle"><span id="typed"></span>&nbsp;</div>
<div class="version">New Version: <span id="version">5.18.5</span></div>
<div class="version">New Version: <span id="version">5.18.6</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>
</div>
<div class="down">

View File

@ -137,18 +137,26 @@ function fsSize(drive, callback) {
}
}
if (_linux) {
try {
cmd = 'export LC_ALL=C; df -lkPTx squashfs; unset LC_ALL';
execSync('cat /proc/mounts 2>/dev/null').toString().split('\n').filter(line => {
return line.startsWith('/');
}).forEach((line) => {
osMounts[line.split(' ')[0]] = line.toLowerCase().indexOf('rw') >= 0;
});
} catch (e) {
util.noop();
}
}
if (_freebsd || _openbsd || _netbsd) {
try {
cmd = 'df -lkPT';
execSync('mount').toString().split('\n').forEach((line) => {
osMounts[line.split(' ')[0]] = line.toLowerCase().indexOf('read-only') === -1;
});
} catch (e) {
util.noop();
}
}
exec(cmd, { maxBuffer: 1024 * 1024 }, function (error, stdout) {
let lines = filterLines(stdout);
@ -1075,10 +1083,14 @@ function diskLayout(callback) {
}
} catch (e) {
// fallback to older version of lsblk
try {
const out2 = execSync('export LC_ALL=C; lsblk -bPo NAME,TYPE,SIZE,FSTYPE,MOUNTPOINT,UUID,ROTA,RO,RM,LABEL,MODEL,OWNER,GROUP 2>/dev/null; unset LC_ALL').toString();
let lines = blkStdoutToObject(out2).split('\n');
const data = parseBlk(lines);
devices = data.filter(item => { return (item.type === 'disk') && item.size > 0 && ((item.model !== null && item.model !== '') || (item.mount === '' && item.label === '' && item.fsType === '')); });
} catch (e) {
util.noop();
}
}
devices.forEach((device) => {
let mediumType = '';

View File

@ -669,6 +669,7 @@ function graphics(callback) {
} catch (e) {
util.noop();
}
try {
stdout = execSync('defaults read /Library/Preferences/com.apple.windowserver.plist 2>/dev/null;defaults read /Library/Preferences/com.apple.windowserver.displays.plist 2>/dev/null; echo ""', { maxBuffer: 1024 * 20000 });
const output = (stdout || '').toString();
const obj = util.plistReader(output);
@ -701,7 +702,9 @@ function graphics(callback) {
i++;
});
}
} catch (e) {
util.noop();
}
}
if (callback) {
callback(result);

View File

@ -788,6 +788,7 @@ function versions(apps, callback) {
}
if ({}.hasOwnProperty.call(appsObj.versions, 'python')) {
if (_darwin) {
try {
const stdout = execSync('sw_vers');
const lines = stdout.toString().split('\n');
const osVersion = util.getValue(lines, 'ProductVersion', ':');
@ -805,6 +806,10 @@ function versions(apps, callback) {
} else {
functionProcessed();
}
} catch (e) {
functionProcessed();
}
} else {
exec('python -V 2>&1', function (error, stdout) {
if (!error) {

View File

@ -586,8 +586,12 @@ function smartMonToolsInstalled() {
}
}
if (_linux || _darwin || _freebsd || _openbsd || _netbsd) {
try {
const pathArray = execSync('which smartctl 2>/dev/null', execOptsWin).toString().split('\r\n');
_smartMonToolsInstalled = pathArray.length > 0;
} catch (e) {
util.noop();
}
}
return _smartMonToolsInstalled;
}