bugfix graphics() vendor and model parsing linux

This commit is contained in:
Sebastian Hildebrandt
2017-10-16 09:50:21 +02:00
parent ad28b165f6
commit fbb614b86b
3 changed files with 18 additions and 8 deletions
+16 -7
View File
@@ -14,7 +14,6 @@
const os = require('os');
const exec = require('child_process').exec;
const fs = require('fs');
const util = require('./util');
let _platform = os.type();
@@ -22,13 +21,12 @@ let _platform = os.type();
const _linux = (_platform === 'Linux');
const _darwin = (_platform === 'Darwin');
const _windows = (_platform === 'Windows_NT');
const NOT_SUPPORTED = 'not supported';
let _resolutionx = 0;
let _resolutiony = 0;
let _pixeldepth = 0;
function toInt(value) {
let result = parseInt(value,10);
let result = parseInt(value, 10);
if (isNaN(result)) {
result = 0;
}
@@ -136,12 +134,23 @@ function graphics(callback) {
let parts = lines[i].substr(vgapos, endpos - vgapos).split(':');
if (parts.length > 1) {
parts[1] = parts[1].trim();
if (parts[1].toLowerCase().indexOf('corporation')) {
if (parts[1].toLowerCase().indexOf('corporation') >= 0) {
currentController.vendor = parts[1].substr(0, parts[1].toLowerCase().indexOf('corporation') + 11).trim();
currentController.model = parts[1].substr(parts[1].toLowerCase().indexOf('corporation') + 11, 200).trim().split('(')[0];
currentController.bus = '';
currentController.vram = -1;
currentController.vramDynamic = false;
} else if (parts[1].toLowerCase().indexOf(' inc.') >= 0) {
if ((parts[1].match(new RegExp("]", "g")) || []).length > 1) {
currentController.vendor = parts[1].substr(0, parts[1].toLowerCase().indexOf(']') + 1).trim();
currentController.model = parts[1].substr(parts[1].toLowerCase().indexOf(']')+1, 200).trim().split('(')[0];
} else {
currentController.vendor = parts[1].substr(0, parts[1].toLowerCase().indexOf(' inc.') + 5).trim();
currentController.model = parts[1].substr(parts[1].toLowerCase().indexOf(' inc.') + 5, 200).trim().split('(')[0];
}
currentController.bus = '';
currentController.vram = -1;
currentController.vramDynamic = false;
}
}
@@ -151,7 +160,7 @@ function graphics(callback) {
}
if (is_vga) { // within VGA details
let parts = lines[i].split(':');
if (parts.length > 1 && parts[0].replace(/ +/g, "").toLowerCase().indexOf('devicename') !== -1 && parts[0].toLowerCase().indexOf('onboard') !== -1) currentController.bus = 'Onboard';
if (parts.length > 1 && parts[0].replace(/ +/g, "").toLowerCase().indexOf('devicename') !== -1 && parts[0].toLowerCase().indexOf('onboard') !== -1) currentController.bus = 'Onboard';
if (parts.length > 1 && parts[0].replace(/ +/g, "").toLowerCase().indexOf('region') !== -1 && parts[1].toLowerCase().indexOf('memory') !== -1) {
let memparts = parts[1].split("=");
if (memparts.length > 1) {
@@ -341,7 +350,7 @@ function graphics(callback) {
});
});
function parseLinesWindowsControllers(sections){
function parseLinesWindowsControllers(sections) {
let controllers = [];
for (let i in sections) {
if (sections.hasOwnProperty(i)) {
@@ -364,7 +373,7 @@ function graphics(callback) {
return controllers;
}
function parseLinesWindowsDisplays(sections){
function parseLinesWindowsDisplays(sections) {
let displays = [];
for (let i in sections) {
if (sections.hasOwnProperty(i)) {