cpuTemperature() fix try catch (linux)

This commit is contained in:
Sebastian Hildebrandt 2020-09-18 20:42:07 +02:00
parent 659f2b1225
commit dfc19f55bb
4 changed files with 138 additions and 116 deletions

View File

@ -30,6 +30,7 @@ For major (breaking) changes - version 3 and 2 see end of page.
| Version | Date | Comment |
| -------------- | -------------- | -------- |
| 4.27.5 | 2020-09-18 | `cpuTemperature()` fix try catch (linux) |
| 4.27.4 | 2020-09-16 | `networkInterfaceDefault()` optimization (macOS) |
| 4.27.3 | 2020-08-26 | updated typescript typings |
| 4.27.2 | 2020-08-26 | fixed issue breaking node v4 compatibility |

View File

@ -83,6 +83,11 @@
</tr>
</thead>
<tbody>
<tr>
<th scope="row">4.27.5</th>
<td>2020-09-18</td>
<td><span class="code">cpuTemperature()</span> fixed try catch (linux)</td>
</tr>
<tr>
<th scope="row">4.27.4</th>
<td>2020-09-16</td>

View File

@ -168,7 +168,7 @@
<img class="logo" src="assets/logo.png">
<div class="title">systeminformation</div>
<div class="subtitle"><span id="typed"></span></div>
<div class="version">Current Version: <span id="version">4.27.4</span></div>
<div class="version">Current Version: <span id="version">4.27.5</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

@ -758,6 +758,7 @@ function cpuTemperature(callback) {
};
if (_linux) {
const cmd = 'cat /sys/class/hwmon/hwmon1/temp*_la*;echo "---";cat /sys/class/hwmon/hwmon1/temp*_i*';
try {
exec(cmd, function (error, stdout) {
if (!error) {
let parts = stdout.toString().split('---');
@ -852,6 +853,10 @@ function cpuTemperature(callback) {
});
});
});
} catch (er) {
if (callback) { callback(result); }
resolve(result);
}
}
if (_freebsd || _openbsd || _netbsd) {
exec('sysctl dev.cpu | grep temp', function (error, stdout) {
@ -962,6 +967,8 @@ function cpuFlags(callback) {
}
}
if (_linux) {
try {
exec('export LC_ALL=C; lscpu; unset LC_ALL', function (error, stdout) {
if (!error) {
let lines = stdout.toString().split('\n');
@ -985,6 +992,10 @@ function cpuFlags(callback) {
resolve(result);
}
});
} catch (e) {
if (callback) { callback(result); }
resolve(result);
}
}
if (_freebsd || _openbsd || _netbsd) {
exec('export LC_ALL=C; dmidecode -t 4 2>/dev/null; unset LC_ALL', function (error, stdout) {
@ -1041,6 +1052,7 @@ function cpuCache(callback) {
l3: -1,
};
if (_linux) {
try {
exec('export LC_ALL=C; lscpu; unset LC_ALL', function (error, stdout) {
if (!error) {
let lines = stdout.toString().split('\n');
@ -1063,6 +1075,10 @@ function cpuCache(callback) {
if (callback) { callback(result); }
resolve(result);
});
} catch (e) {
if (callback) { callback(result); }
resolve(result);
}
}
if (_freebsd || _openbsd || _netbsd) {
exec('export LC_ALL=C; dmidecode -t 7 2>/dev/null; unset LC_ALL', function (error, stdout) {