skyeye-sdk-js 1.4.5 → 1.4.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/SkyEyeClient.js +18 -4
- package/package.json +1 -1
- package/src/SkyEyeClient.ts +21 -7
package/dist/src/SkyEyeClient.js
CHANGED
|
@@ -146,6 +146,8 @@ class SkyEyeClient extends skyeye_rpc_grpc_pb_1.JSONTransmissionClient {
|
|
|
146
146
|
// console.log("res:",res)
|
|
147
147
|
const ackObj = JSON.parse(response.toString()).ack;
|
|
148
148
|
// this.printResponseLog(ackObj)
|
|
149
|
+
if (ackObj.result === 'false')
|
|
150
|
+
ackObj.result = false;
|
|
149
151
|
return ackObj;
|
|
150
152
|
}
|
|
151
153
|
catch (error) {
|
|
@@ -1095,10 +1097,22 @@ class SkyEyeClient extends skyeye_rpc_grpc_pb_1.JSONTransmissionClient {
|
|
|
1095
1097
|
try {
|
|
1096
1098
|
console.log('runExample');
|
|
1097
1099
|
this.childProcess = yield this.startSkyEye(port, skyeyeDir);
|
|
1100
|
+
let response;
|
|
1101
|
+
let ackObj;
|
|
1098
1102
|
yield this.checkState();
|
|
1099
1103
|
yield this.checkModule();
|
|
1100
|
-
yield this.setWorkingDirectory(pathSkyEye, port);
|
|
1101
|
-
|
|
1104
|
+
response = yield this.setWorkingDirectory(pathSkyEye, port);
|
|
1105
|
+
ackObj = JSON.parse(response.toString()).ack;
|
|
1106
|
+
if (ackObj.result === "false") {
|
|
1107
|
+
ackObj.result = false;
|
|
1108
|
+
throw new Error(ackObj.error);
|
|
1109
|
+
}
|
|
1110
|
+
response = yield this.runScript(fileName, port);
|
|
1111
|
+
ackObj = JSON.parse(response.toString()).ack;
|
|
1112
|
+
if (ackObj.result === "false") {
|
|
1113
|
+
ackObj.result = false;
|
|
1114
|
+
throw new Error(ackObj.error);
|
|
1115
|
+
}
|
|
1102
1116
|
return true;
|
|
1103
1117
|
}
|
|
1104
1118
|
catch (error) {
|
|
@@ -1209,7 +1223,7 @@ class SkyEyeClient extends skyeye_rpc_grpc_pb_1.JSONTransmissionClient {
|
|
|
1209
1223
|
}
|
|
1210
1224
|
else {
|
|
1211
1225
|
console.log("chdir res:", response);
|
|
1212
|
-
resolve();
|
|
1226
|
+
resolve(response);
|
|
1213
1227
|
}
|
|
1214
1228
|
});
|
|
1215
1229
|
});
|
|
@@ -1226,7 +1240,7 @@ class SkyEyeClient extends skyeye_rpc_grpc_pb_1.JSONTransmissionClient {
|
|
|
1226
1240
|
}
|
|
1227
1241
|
else {
|
|
1228
1242
|
console.log("run_script res:", response);
|
|
1229
|
-
resolve();
|
|
1243
|
+
resolve(response);
|
|
1230
1244
|
}
|
|
1231
1245
|
});
|
|
1232
1246
|
});
|
package/package.json
CHANGED
package/src/SkyEyeClient.ts
CHANGED
|
@@ -111,6 +111,7 @@ export class SkyEyeClient extends JSONTransmissionClient {
|
|
|
111
111
|
// console.log("res:",res)
|
|
112
112
|
const ackObj = JSON.parse(response.toString()).ack;
|
|
113
113
|
// this.printResponseLog(ackObj)
|
|
114
|
+
if (ackObj.result === 'false') ackObj.result = false
|
|
114
115
|
return ackObj;
|
|
115
116
|
} catch (error) {
|
|
116
117
|
// console.error("Error during gRPC request:", JSON.stringify(request));
|
|
@@ -1012,11 +1013,24 @@ export class SkyEyeClient extends JSONTransmissionClient {
|
|
|
1012
1013
|
public async initSkyEyeAndRun2(pathSkyEye: string, fileName: string, port: string, skyeyeDir: string) {
|
|
1013
1014
|
try {
|
|
1014
1015
|
console.log('runExample');
|
|
1016
|
+
|
|
1015
1017
|
this.childProcess = await this.startSkyEye(port, skyeyeDir);
|
|
1018
|
+
let response
|
|
1019
|
+
let ackObj
|
|
1016
1020
|
await this.checkState();
|
|
1017
1021
|
await this.checkModule();
|
|
1018
|
-
await this.setWorkingDirectory(pathSkyEye, port);
|
|
1019
|
-
|
|
1022
|
+
response = await this.setWorkingDirectory(pathSkyEye, port);
|
|
1023
|
+
ackObj = JSON.parse(response.toString()).ack;
|
|
1024
|
+
if (ackObj.result === "false") {
|
|
1025
|
+
ackObj.result = false
|
|
1026
|
+
throw new Error(ackObj.error)
|
|
1027
|
+
}
|
|
1028
|
+
response = await this.runScript(fileName, port);
|
|
1029
|
+
ackObj = JSON.parse(response.toString()).ack;
|
|
1030
|
+
if (ackObj.result === "false") {
|
|
1031
|
+
ackObj.result = false
|
|
1032
|
+
throw new Error(ackObj.error)
|
|
1033
|
+
}
|
|
1020
1034
|
return true;
|
|
1021
1035
|
} catch (error) {
|
|
1022
1036
|
console.error("initSkyEyeAndRun error:", error);
|
|
@@ -1126,7 +1140,7 @@ export class SkyEyeClient extends JSONTransmissionClient {
|
|
|
1126
1140
|
}
|
|
1127
1141
|
|
|
1128
1142
|
|
|
1129
|
-
private setWorkingDirectory(pathSkyEye: string, port: string): Promise<
|
|
1143
|
+
private setWorkingDirectory(pathSkyEye: string, port: string): Promise<JSONResponse> {
|
|
1130
1144
|
const client = new JSONTransmissionClient(`127.0.0.1:${port}`, grpc.credentials.createInsecure());
|
|
1131
1145
|
const Jr = new JSONRequest();
|
|
1132
1146
|
Jr.setRequest(`{"request": {"name": "chdir", "args": {"path":"${pathSkyEye}"}}}`);
|
|
@@ -1138,25 +1152,25 @@ export class SkyEyeClient extends JSONTransmissionClient {
|
|
|
1138
1152
|
reject(error);
|
|
1139
1153
|
} else {
|
|
1140
1154
|
console.log("chdir res:", response);
|
|
1141
|
-
resolve();
|
|
1155
|
+
resolve(response);
|
|
1142
1156
|
}
|
|
1143
1157
|
});
|
|
1144
1158
|
});
|
|
1145
1159
|
}
|
|
1146
1160
|
|
|
1147
|
-
private runScript(fileName: string, port: string): Promise<
|
|
1161
|
+
private runScript(fileName: string, port: string): Promise<JSONResponse> {
|
|
1148
1162
|
const client = new JSONTransmissionClient(`127.0.0.1:${port}`, grpc.credentials.createInsecure());
|
|
1149
1163
|
const Jr = new JSONRequest();
|
|
1150
1164
|
Jr.setRequest(`{"request": {"name": "run_script", "args": {"filename":"${fileName}"}}}`);
|
|
1151
1165
|
|
|
1152
|
-
return new Promise((resolve, reject) => {
|
|
1166
|
+
return new Promise<JSONResponse>((resolve, reject) => {
|
|
1153
1167
|
client.callSkyEye(Jr, (error: ServiceError | null, response: JSONResponse) => {
|
|
1154
1168
|
if (error) {
|
|
1155
1169
|
console.log("run_script error res:", error);
|
|
1156
1170
|
reject(error);
|
|
1157
1171
|
} else {
|
|
1158
1172
|
console.log("run_script res:", response);
|
|
1159
|
-
resolve();
|
|
1173
|
+
resolve(response);
|
|
1160
1174
|
}
|
|
1161
1175
|
});
|
|
1162
1176
|
});
|