pull/29/head
Matthew 2020-12-02 00:33:14 -05:00
parent 2f4a5fe5f9
commit 856a8b5de4
No known key found for this signature in database
GPG Key ID: 210AF32ADE3B5C4B
1 changed files with 11 additions and 4 deletions

View File

@ -2,6 +2,7 @@
import nodemailer from 'nodemailer'; import nodemailer from 'nodemailer';
import GoogleTTS, { TextToSpeechClient } from '@google-cloud/text-to-speech'; import GoogleTTS, { TextToSpeechClient } from '@google-cloud/text-to-speech';
import childProcess from 'child_process'; import childProcess from 'child_process';
import { promisify } from 'util';
import ARIClient from 'ari-client'; import ARIClient from 'ari-client';
import AMIClient from 'asterisk-manager'; import AMIClient from 'asterisk-manager';
import signale from 'signale'; import signale from 'signale';
@ -48,7 +49,7 @@ export default class Util {
this.ari = await ARIClient.connect('http://10.8.0.1:8088/ari', 'cr0', this.client.config.ariClientKey); this.ari = await ARIClient.connect('http://10.8.0.1:8088/ari', 'cr0', this.client.config.ariClientKey);
this.ari.start(['cr-zero', 'page-dtmf']); this.ari.start(['cr-zero', 'page-dtmf']);
this.ami = new AMIClient(5038, '10.8.0.1', this.client.config.amiClientKey); this.ami = new AMIClient(5038, '10.8.0.1', 'cr', this.client.config.amiClientKey);
process.env.GOOGLE_APPLICATION_CREDENTIALS = `${__dirname}/../../google.json`; process.env.GOOGLE_APPLICATION_CREDENTIALS = `${__dirname}/../../google.json`;
this.tts = new GoogleTTS.TextToSpeechClient(); this.tts = new GoogleTTS.TextToSpeechClient();
@ -84,8 +85,14 @@ export default class Util {
} }
*/ */
public async exec(command: string, options: childProcess.ExecOptions = {}): Promise<string> { public async exec(command: string, _options: childProcess.ExecOptions = {}): Promise<string> {
return new Promise((res, rej) => { const ex = promisify(childProcess.exec);
try {
return (await ex(command)).stdout;
} catch (err) {
return err;
}
/* return new Promise((res, rej) => {
let output = ''; let output = '';
const writeFunction = (data: string|Buffer|Error) => { const writeFunction = (data: string|Buffer|Error) => {
output += `${data}`; output += `${data}`;
@ -102,7 +109,7 @@ export default class Util {
if (code !== 0) rej(new Error(`Command failed: ${command}\n${output}`)); if (code !== 0) rej(new Error(`Command failed: ${command}\n${output}`));
res(output); res(output);
}); });
}); }); */
} }
/** /**