Clean up and added run any commands
This commit is contained in:
@@ -307,8 +307,6 @@ exports.open_local_file = async function ({local_file_path, filename}) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Check local file cache and download from server if needed.
|
||||
// Updated 2022-03-09
|
||||
// exports.check_file_cache = async function ({host_file_cache_path, event_file_id, hash}) {
|
||||
@@ -365,7 +363,6 @@ exports.check_file_cache = async function ({host_file_cache_path, event_file_id,
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Check local file cache and download from server if needed. Must use IPC to Main to download file. Set a Promise to wait for download_file_reply.
|
||||
// Updated 2022-03-09
|
||||
async function check_file_cache({host_file_cache_path, event_file_id, hash}) {
|
||||
@@ -420,6 +417,7 @@ async function check_file_cache({host_file_cache_path, event_file_id, hash}) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// IPC to Main: Open local file cache if available. Copy to temp directory with given filename first.
|
||||
// Updated 2022-03-09
|
||||
async function open_local_file({host_file_cache_path, hash, host_file_temp_path, filename}) {
|
||||
@@ -464,7 +462,7 @@ exports.check_file_cache_and_open_local_file = async function ({host_file_cache_
|
||||
|
||||
|
||||
// Kill processes
|
||||
// Updated 2022-05-06
|
||||
// Updated 2022-05-07
|
||||
exports.kill_processes = async function ({process_name = null}) {
|
||||
console.log('*** Electron framework export: kill_processes() ***');
|
||||
console.log(process_name); // process_name or grep pattern
|
||||
@@ -481,22 +479,27 @@ exports.kill_processes = async function ({process_name = null}) {
|
||||
if (err) throw err;
|
||||
console.log(stdout);
|
||||
});
|
||||
console.log('Killed processes?');
|
||||
console.log(`Killed processes matching ${process_name}`);
|
||||
|
||||
// let command = `ps -aux | grep ${process_name}`;
|
||||
// child_process.exec(command, (err, stdout, stdin) => {
|
||||
// if (err) throw err;
|
||||
// console.log(stdout);
|
||||
// });
|
||||
|
||||
// console.log(await psList());
|
||||
// console.log(await ps_list());
|
||||
if (os.platform == 'darwin') {
|
||||
if (process_name == 'Parallels:PowerPoint') {
|
||||
// Regular expression: (Parallels).*(PowerPoint)
|
||||
// This will find any process with Parallels and PowerPoint in the name
|
||||
command = `pkill -i -f '(Parallels).*(PowerPoint)'`;
|
||||
|
||||
child_process.exec(command, (err, stdout, stdin) => {
|
||||
if (err) throw err;
|
||||
console.log(stdout);
|
||||
});
|
||||
console.log('Killed Parallels PowerPoint process');
|
||||
}
|
||||
}
|
||||
|
||||
// let signal = 'SIGTERM'; // 'SIGTERM', 'SIGINT', 'SIGHUP'
|
||||
|
||||
// process.kill(pid, signal);
|
||||
|
||||
// process.kill(pid, 0); // Special case test if process exists
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -504,7 +507,7 @@ exports.kill_processes = async function ({process_name = null}) {
|
||||
// Run raw osascript
|
||||
// Updated 2022-05-07
|
||||
exports.run_osascript = async function ({command=null, interactive=false, language=null, flags='h', program_file=null}) {
|
||||
console.log('*** Electron framework export: kill_processes() ***');
|
||||
console.log('*** Electron framework export: run_osascript() ***');
|
||||
console.log(command);
|
||||
|
||||
if (os.platform == 'darwin') {
|
||||
@@ -549,4 +552,22 @@ exports.run_osascript = async function ({command=null, interactive=false, langua
|
||||
|
||||
console.log('Finished');
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Run raw command
|
||||
// Updated 2022-05-07
|
||||
exports.run_command = async function ({command=null}) {
|
||||
console.log('*** Electron framework export: run_command() ***');
|
||||
|
||||
console.log(`Command String: ${command}`);
|
||||
|
||||
child_process.exec(command, (err, stdout, stdin) => {
|
||||
if (err) throw err;
|
||||
console.log(stdout);
|
||||
console.log(stdin);
|
||||
});
|
||||
|
||||
console.log('Finished');
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user