Skip to content

Commit

Permalink
Merge pull request aces#14 from maltheism/new_task_today_main
Browse files Browse the repository at this point in the history
New task
  • Loading branch information
maltheism authored Feb 23, 2021
2 parents 7fa8b98 + 278c0a6 commit bbae0b6
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 45 deletions.
17 changes: 9 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
"socket.io-client": "^3.1.1"
},
"devDependencies": {
"@babel/core": "^7.12.17",
"@babel/eslint-parser": "^7.12.17",
"@babel/core": "^7.13.1",
"@babel/eslint-parser": "^7.13.4",
"concurrently": "^6.0.0",
"cross-env": "^7.0.3",
"electron": "^11.2.3",
"electron-builder": "^22.9.0",
"electron": "^11.3.0",
"electron-builder": "^22.8.1",
"electron-devtools-installer": "^3.1.1",
"electron-rebuild": "^2.3.5",
"eslint": "^7.20.0",
Expand All @@ -31,7 +31,7 @@
"wait-on": "^5.2.1"
},
"scripts": {
"rebuild": "rebuild zeromq --runtime=electron --target=11.2.1",
"rebuild": "rebuild --runtime=electron --target=11.2.1",
"react-start": "cross-env BROWSER=NONE react-scripts start",
"electron-start": "cross-env DEV=1 electron .",
"start": "concurrently 'npm run react-start' 'wait-on http://localhost:3000/ && npm run electron-start'",
Expand Down Expand Up @@ -107,11 +107,12 @@
"build/**/*",
"node_modules/**/*",
"utils/**/*",
"python/**/*"
"python/**/*",
"dist/*",
"package.json"
],
"directories": {
"buildResources": "assets"
},
"extends": "zeromq"
}
}
}
26 changes: 16 additions & 10 deletions public/electron.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ const {app} = electron;
const {BrowserWindow} = electron;
const nativeImage = electron.nativeImage;

const PycatService = require('../public/pycatService');
const PycatService = process.env.DEV ?
require('../public/pycatService') :
require(path.join(__dirname, '../build/pycatService'));

// Launch python service.
const pycatService = new PycatService('production'); // production or development
Expand All @@ -21,10 +23,10 @@ if (process.env.DEV) {

app.whenReady().then(() => {
installExtension(REDUX_DEVTOOLS).then((name) =>
console.log(`Added Extension: ${name}`),
console.info(`Added Extension: ${name}`),
);
installExtension(REACT_DEVELOPER_TOOLS).then((name) =>
console.log(`Added Extension: ${name}`),
console.info(`Added Extension: ${name}`),
);
});
}
Expand All @@ -39,11 +41,7 @@ let mainWindow;
const createWindow = () => {
const startUrl = process.env.DEV ?
'http://localhost:3000' :
url.format({
pathname: path.join(__dirname, '/../build/index.html'),
protocol: 'file:',
slashes: true,
});
url.pathToFileURL(path.join(__dirname, '/../build/index.html')).href;
mainWindow = new BrowserWindow({
show: false,
icon,
Expand All @@ -60,11 +58,19 @@ const createWindow = () => {
minHeight: 600,
backgroundColor: '#0A826E',
});
mainWindow.removeMenu(); // Hides menu on Linux & Windows
// mainWindow.maximize();
mainWindow.show();

mainWindow.loadURL(startUrl);
// process.env.DEV && mainWindow.webContents.openDevTools();
mainWindow.loadURL(startUrl).then(() => {
console.info('pyCat ');
});
console.log('LOOK here:');
console.log(startUrl);
console.log(String(Object.assign(new URL('http://localhost:3000'),
{pathname: ''}
)));
process.env.DEV && mainWindow.webContents.openDevTools();

mainWindow.on('closed', function() {
pycatService.shutdown();
Expand Down
21 changes: 2 additions & 19 deletions public/pycatService.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const {spawn} = require('child_process'); // {fork}


/**
* PycatService
*/
Expand All @@ -27,31 +26,15 @@ module.exports = class PycatService {
'dist/pycat-service-windows.exe' :
'dist/pycat-service'
);
console.log(pathToService);
this.process = spawn(pathToService, [], {
// stdio: ['pipe', 'pipe', 'pipe'],
silent: true,
// encoding: 'utf8',
});
this.process.stdout.on('data', (data) => {
console.log('stdout data:');
console.log(`stdout: ${data}`);
});
this.process.stderr.on('data', (data) => {
console.log('stderr data:');
});
this.process.on('close', (code) => {
console.log('close:');
console.log(`child process exited with code ${code}`);
});
this.process = spawn(pathToService);
}
/**
* shutdown the service process
*/
shutdown() {
if (this.mode === 'development') return;
if (this.process) {
console.log('SHUTDOWN of pycatService');
console.info('[SHUTDOWN of pycatService]');
this.process.kill();
this.process = null;
}
Expand Down
3 changes: 0 additions & 3 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,9 @@ const App = () => {
},
setTask: (key, value) => {
task[key] = value;
console.log(task);
setTask(task);
},
getFromTask: (key) => {
console.log('getFromTask:');
console.log(task[key]);
return task[key];
},
}}>
Expand Down
12 changes: 7 additions & 5 deletions src/jsx/Converter.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ const Converter = (props) => {
*/
const beginBidsCreation = () => {
socketContext.emit('ieeg_to_bids', {
file_path: appContext.getFromTask('edfFile').path,
bids_directory: appContext.getFromTask('bidsDirectory'),
file_path: appContext.getFromTask('edfFile') ?
appContext.getFromTask('edfFile').path : '',
bids_directory: appContext.getFromTask('bidsDirectory') ?? '',
read_only: false,
events_tsv: appContext.getFromTask('eventsTSV').path,
line_freq: appContext.getFromTask('lineFreq'),
site_id: appContext.getFromTask('siteID'),
events_tsv: appContext.getFromTask('eventsTSV') ?
appContext.getFromTask('eventsTSV').path : '',
line_freq: appContext.getFromTask('lineFreq') ?? '',
site_id: appContext.getFromTask('siteID') ?? '',
});
};

Expand Down

0 comments on commit bbae0b6

Please sign in to comment.