powerShell bugfix error handling
This commit is contained in:
parent
71a140fa84
commit
ee815ede84
20
lib/index.js
20
lib/index.js
@ -91,15 +91,16 @@ function getStaticData(callback) {
|
|||||||
data.system = res[0];
|
data.system = res[0];
|
||||||
data.bios = res[1];
|
data.bios = res[1];
|
||||||
data.baseboard = res[2];
|
data.baseboard = res[2];
|
||||||
data.os = res[3];
|
data.chassis = res[3];
|
||||||
data.uuid = res[4];
|
data.os = res[4];
|
||||||
data.versions = res[5];
|
data.uuid = res[5];
|
||||||
data.cpu = res[6];
|
data.versions = res[6];
|
||||||
data.cpu.flags = res[7];
|
data.cpu = res[7];
|
||||||
data.graphics = res[8];
|
data.cpu.flags = res[8];
|
||||||
data.net = res[9];
|
data.graphics = res[9];
|
||||||
data.memLayout = res[10];
|
data.net = res[10];
|
||||||
data.diskLayout = res[11];
|
data.memLayout = res[11];
|
||||||
|
data.diskLayout = res[12];
|
||||||
if (callback) { callback(data); }
|
if (callback) { callback(data); }
|
||||||
resolve(data);
|
resolve(data);
|
||||||
});
|
});
|
||||||
@ -107,6 +108,7 @@ function getStaticData(callback) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// --------------------------
|
// --------------------------
|
||||||
// get all dynamic data - e.g. for monitoring agents
|
// get all dynamic data - e.g. for monitoring agents
|
||||||
// may take some seconds to get all data
|
// may take some seconds to get all data
|
||||||
|
|||||||
@ -527,7 +527,7 @@ function chassis(callback) {
|
|||||||
|
|
||||||
result.manufacturer = util.getValue(lines, 'manufacturer', '=');
|
result.manufacturer = util.getValue(lines, 'manufacturer', '=');
|
||||||
result.model = util.getValue(lines, 'model', '=');
|
result.model = util.getValue(lines, 'model', '=');
|
||||||
const ctype = parseInt(util.getValue(lines, 'ChassisTypes', '='));
|
const ctype = parseInt(util.getValue(lines, 'ChassisTypes', '=').replace(/\D/g, ''));
|
||||||
result.type = (ctype && !isNaN(ctype) && ctype < chassisTypes.length) ? chassisTypes[ctype] : '';
|
result.type = (ctype && !isNaN(ctype) && ctype < chassisTypes.length) ? chassisTypes[ctype] : '';
|
||||||
result.version = util.getValue(lines, 'version', '=');
|
result.version = util.getValue(lines, 'version', '=');
|
||||||
result.serial = util.getValue(lines, 'serialnumber', '=');
|
result.serial = util.getValue(lines, 'serialnumber', '=');
|
||||||
|
|||||||
30
lib/util.js
30
lib/util.js
@ -225,20 +225,24 @@ function powerShell(cmd) {
|
|||||||
stdio: 'pipe'
|
stdio: 'pipe'
|
||||||
});
|
});
|
||||||
|
|
||||||
child.stdout.on('data', function (data) {
|
if (child) {
|
||||||
result = result + data.toString('utf8');
|
child.stdout.on('data', function (data) {
|
||||||
});
|
result = result + data.toString('utf8');
|
||||||
child.stderr.on('data', function (data) {
|
});
|
||||||
child.kill();
|
child.stderr.on('data', function (data) {
|
||||||
reject(data);
|
child.kill();
|
||||||
});
|
reject(data);
|
||||||
child.on('close', function () {
|
});
|
||||||
child.kill();
|
child.on('close', function () {
|
||||||
resolve(result);
|
child.kill();
|
||||||
});
|
resolve(result);
|
||||||
|
});
|
||||||
|
|
||||||
child.stdin.write(cmd + '\n');
|
child.stdin.write(cmd + '\n');
|
||||||
child.stdin.end();
|
child.stdin.end();
|
||||||
|
} else {
|
||||||
|
reject(result);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user