code cleanup

This commit is contained in:
Sebastian Hildebrandt 2017-11-09 23:06:55 +01:00
parent b7bf83f3ae
commit c183037128
3 changed files with 20 additions and 8 deletions

View File

@ -99,6 +99,7 @@ Other changes
| Version | Date | Comment |
| -------------- | -------------- | -------- |
| 3.33.5 | 2017-11-09 | code cleanup |
| 3.33.4 | 2017-11-09 | bugfix graphics controller win (bytes) |
| 3.33.3 | 2017-11-08 | bugfix cpu speed arm - type |
| 3.33.2 | 2017-11-08 | bugfix cpu speed arm |

View File

@ -327,7 +327,7 @@ function graphics(callback) {
if (!error) {
let csections = stdout.split(/\n\s*\n/);
result.controllers = parseLinesWindowsControllers(csections);
exec('wmic path win32_desktopmonitor get MonitorManufacturer, ScreenWidth, ScreenHeight /value', function (error, stdout) {
exec('wmic path win32_desktopmonitor get Caption, MonitorManufacturer, MonitorType, ScreenWidth, ScreenHeight /value', function (error, stdout) {
let dsections = stdout.split(/\n\s*\n/);
if (!error) {
result.displays = parseLinesWindowsDisplays(dsections);
@ -385,8 +385,13 @@ function graphics(callback) {
let lines = sections[i].trim().split('\r\n');
displays.push({
model: util.getValue(lines, 'MonitorManufacturer', '='),
main: false,
builtin: false,
connection: '',
resolutionx: toInt(util.getValue(lines, 'ScreenWidth', '=')),
resolutiony: toInt(util.getValue(lines, 'ScreenHeight', '=')),
sizex: -1,
sizey: -1
});
}
}

View File

@ -40,8 +40,8 @@ function inetChecksite(url, callback) {
url = url.toLowerCase();
let t = Date.now();
if (_linux || _darwin) {
let args = " -I --connect-timeout 5 -m 5 " + url + " 2>/dev/null | head -n 1 | cut -d ' ' -f2";
let cmd = "curl";
let args = ' -I --connect-timeout 5 -m 5 ' + url + ' 2>/dev/null | head -n 1 | cut -d " " -f2';
let cmd = 'curl';
exec(cmd + args, function (error, stdout) {
let statusCode = parseInt(stdout.toString());
result.status = statusCode || 404;
@ -66,12 +66,12 @@ function inetChecksite(url, callback) {
if (callback) { callback(result); }
resolve(result);
} else {
res.on('data', (chunk) => { });
// res.on('data', (chunk) => { });
res.on('end', () => {
result.ms = (result.ok ? Date.now() - t : -1);
if (callback) { callback(result); }
resolve(result);
})
});
}
}).on('error', err => {
if (callback) { callback(result); }
@ -110,16 +110,22 @@ function inetLatency(host, callback) {
let cmd;
if (_linux || _darwin) {
if (_linux) {
cmd = "ping -c 2 -w 3 " + host + " | grep rtt | cut -d'/' -f4 | awk '{ print $3 }'";
cmd = 'ping -c 2 -w 3 ' + host + ' | grep rtt';
}
if (_darwin) {
cmd = "ping -c 2 -t 3 " + host + " | grep avg | cut -d'/' -f4 | awk '{ print $3 }'";
cmd = 'ping -c 2 -t 3 ' + host + ' | grep avg';
}
exec(cmd, function (error, stdout) {
let result = -1;
if (!error) {
result = parseFloat(stdout.toString());
const line = stdout.toString().split('=');
if (line.length > 1) {
const parts = line[1].split('/');
if (parts.length > 1) {
result = parseFloat(parts[1]);
}
}
}
if (callback) { callback(result); }
resolve(result);