Skip to content

Commit

Permalink
Merge pull request #22 from erssebaggala/use_gnu_sed_for_cleanup
Browse files Browse the repository at this point in the history
Use GNU sed for GExport cleanup
  • Loading branch information
erssebaggala authored Jun 9, 2019
2 parents b633efd + ffa3133 commit 00955ff
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 6 deletions.
48 changes: 44 additions & 4 deletions background/parse_cm_dumps.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ <h1>Background process</h1>

const {ipcRenderer} = window.require('electron');
const { app, process } = window.require('electron').remote;
const { spawn } = window.require('child_process')
const { spawn, spawnSync } = window.require('child_process')
const path = window.require('path')
const isDev = window.require('electron-is-dev');
const replace = window.require('replace-in-file');
Expand Down Expand Up @@ -127,11 +127,46 @@ <h1>Background process</h1>
],
};

return await replace.stream(replaceOptions)
return await replace.sync(replaceOptions)

}


/*Use gnu sed.exe on windows
*
*/
cleanHuaweiGExportWithSed = (inputFolder) => {
let libPath = app.getAppPath();

if (!isDev) {
libPath = process.resourcesPath;
}

let files = fs.readdirSync(inputFolder, { withFileTypes: true }).filter(dirent => !dirent.isDirectory()).map(dirent => dirent.name);

const sedScript = path.join(libPath,'libraries', 'gexport_cleanup.sed');
const sed = path.join(libPath,'libraries','sed.exe');

for (let i=0; i<files.length; i++) {
f = files[i];
inputFile = path.join(inputFolder,f);

log.info(`Cleaning ${f}...`);
ipcRenderer.send('parse-cm-job', JSON.stringify({status:"info", message: `Uncompressing ${f}...`}));

const child = spawnSync(sed, ['-i', '-r', '-f', sedScript, inputFile]);
log.info(`${sed} -i -r -f ${sedScript} ${inputFile}`);
log.info(child.output);

if(child.error){
log.info(`[parse_cm_job] error:${child.error.toString()}`);
//ipcRenderer.send('parse-cm-job', JSON.stringify({status:"error", message: child.stderr.toString()}));
throw child.error.toString();
}
}

}

/*
* Take the latest file when there is more than one file from the same node .
*
Expand Down Expand Up @@ -229,14 +264,19 @@ <h1>Background process</h1>
ipcRenderer.send('parse-cm-job', JSON.stringify({status:"info", message: `Cleaning GExport XML files...`}))
log.info(`[parse_cm_job] Cleaning GExport XML files...`)

await cleanHuaweiGexportFiles(inputFolder)
if(process.platform === "win32"){
//If windows test, with sed.exe
cleanHuaweiGExportWithSed(inputFolder);
}else{
await cleanHuaweiGexportFiles(inputFolder);
}

ipcRenderer.send('parse-cm-job', JSON.stringify({status:"info", message: `Cleanup of GExport XML files completed.`}))
log.info(`[parse_cm_job] Cleanup of GExport XML files completed.`)

}catch(error){
log.error('[parse_cm_job] Error occurred:', error);
ipcRenderer.send('parse-cm-job', JSON.stringify({status:"error", message: error.toStrong()}))
ipcRenderer.send('parse-cm-job', JSON.stringify({status:"error", message: error.toString()}))
return;
}

Expand Down
8 changes: 8 additions & 0 deletions libraries/gexport_cleanup.sed
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
s/_(BSC6900GSM|BSC6900UMTS|BSC6900GU|BSC6910GSM|BSC6910UMTS|BSC6910GU)//ig;
s/_(BTS3900|PICOBTS3900|BTS3911B|PICOBTS3911B|MICROBTS3900|MICROBTS3911B)//ig;
s/BSC(6910|6900)(UMTS|GSM)Function/FUNCTION/ig;
s/BSC(6910|6900)Equipment/EQUIPMENT/ig;
s/<class name=\"(.*)\"/<class name=\"\U\1\"/ig;
s/<class name=\"(.*)_MSCSERVER/<class name=\"\1/ig;
s/<class name=\"(.*)_ENODEB\"/<class name=\"\1\"/ig;
s/<class name=\"(.*)3900/<class name=\"\1/ig;
Binary file added libraries/msys-2.0.dll
Binary file not shown.
Binary file added libraries/msys-iconv-2.dll
Binary file not shown.
Binary file added libraries/msys-intl-8.dll
Binary file not shown.
Binary file added libraries/sed.exe
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "BTS-CE-Lite",
"version": "0.1.2",
"version": "0.1.3",
"description": "BTS-CE-Lite is a telecommunication network management application",
"private": true,
"homepage": "./",
Expand Down
2 changes: 1 addition & 1 deletion src/modules/layout/UILayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class UILayout extends React.Component {

<Navbar.Group align={Alignment.LEFT}>
<img src={logo} width="50px" alt="BTS-CE-Lite" /> &nbsp;&nbsp;&nbsp;
<Navbar.Heading>BTS-CE-Lite <span className="version bp3-text-muted">v{"0.1.2"}</span></Navbar.Heading>
<Navbar.Heading>BTS-CE-Lite <span className="version bp3-text-muted">v{"0.1.3"}</span></Navbar.Heading>
</Navbar.Group>
<Navbar.Group align={Alignment.RIGHT}>
<Button className={Classes.MINIMAL} icon="home" text="Home"
Expand Down

0 comments on commit 00955ff

Please sign in to comment.