Skip to content

Commit f706ffc

Browse files
committed
Fixed correct import and excute of mirte.py
1 parent d013c60 commit f706ffc

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

vue-frontend/src/components/Xterm.vue

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,13 +157,15 @@ export default {
157157
this.shell_socket.send("cd /home/mirte/workdir\n");
158158
this.shell_socket.send("ps aux | grep 'python3 -i -c' | awk '{print $2}' | xargs kill -9\n"); // TODO: this should be fixed in the backend
159159
this.shell_socket.send("history -c\n");
160-
this.shell_socket.send("python3 -i -c 'from mirte_robot import robot; mirte=robot.createRobot()'\n");
160+
this.shell_socket.send("python3 -i -c 'from mirte_robot import robot; import importlib.util; mirte=robot.createRobot()'\n");
161161
}
162162
else if (this.$store.getters.getExecution == "initializing" && ev.data.slice(-4) == ">>> "){
163163
this.shell_socket.send('def run():\n');
164164
this.shell_socket.send(' try:\n');
165165
this.shell_socket.send(' print("\\033[38;2;0;0;0m", end="")\n');
166-
this.shell_socket.send(' exec(open("/home/mirte/workdir/mirte.py").read())\n');
166+
this.shell_socket.send(' spec = importlib.util.spec_from_file_location("mirte", "/home/mirte/workdir/mirte.py")\n');
167+
this.shell_socket.send(' mod = importlib.util.module_from_spec(spec)\n');
168+
this.shell_socket.send(' spec.loader.exec_module(mod)\n');
167169
this.shell_socket.send(' print("\\033[38;2;254;250;247m", end="")\n');
168170
this.shell_socket.send(' except:\n');
169171
this.shell_socket.send(' print("\\r", end="")\n');

0 commit comments

Comments
 (0)