From a60b2f9afbce71ab93f0c9648ba9e9bf3c8571eb Mon Sep 17 00:00:00 2001 From: blinry Date: Sat, 27 Feb 2021 15:07:35 +0100 Subject: [PATCH] Directly run the command in the shell --- scenes/game.gd | 8 ++++++-- scenes/shell.gd | 4 ++-- scenes/tcp_server_shell.gd | 4 ++-- scripts/net-test | 20 +++++++------------- 4 files changed, 17 insertions(+), 19 deletions(-) diff --git a/scenes/game.gd b/scenes/game.gd index 71710c1..8e63dd9 100644 --- a/scenes/game.gd +++ b/scenes/game.gd @@ -141,8 +141,12 @@ func toggle_music(): func shell_test(command): mutex.lock() - print("go") + #print("go") + print(command) + var before = OS.get_ticks_msec() var response = $ShellServer.send(command) - print("stop") + var after = OS.get_ticks_msec() + print("took " + str(after-before)+" ms") + #print("stop") mutex.unlock() return response diff --git a/scenes/shell.gd b/scenes/shell.gd index 8394ab4..9039cd4 100644 --- a/scenes/shell.gd +++ b/scenes/shell.gd @@ -53,11 +53,11 @@ func run_async_thread(shell_command): for variable in env: hacky_command += "export %s='%s';" % [variable, env[variable]] - hacky_command += "export PATH=\'"+game.tmp_prefix+":'\"$PATH\";" + #hacky_command += "export PATH=\'"+game.tmp_prefix+":'\"$PATH\";" hacky_command += "cd '%s' || exit 1;" % _cwd hacky_command += command - print(hacky_command) + #print(hacky_command) var result var shell_command_internal = game.shell_test(hacky_command) diff --git a/scenes/tcp_server_shell.gd b/scenes/tcp_server_shell.gd index b5511a3..1756170 100644 --- a/scenes/tcp_server_shell.gd +++ b/scenes/tcp_server_shell.gd @@ -44,8 +44,8 @@ func send(text): var shell_command = ShellCommand.new() shell_command.command = text shell_command.output = response - print("response:") - print(response) + #print("response:") + #print(response) shell_command.exit_code = exit_code return shell_command else: diff --git a/scripts/net-test b/scripts/net-test index 1021eae..0bfbcf5 100755 --- a/scripts/net-test +++ b/scripts/net-test @@ -23,24 +23,18 @@ while(true) { $socket->recv($len, 4); my $actual_len = unpack("L", $len); if ($actual_len == 0) { - print("not connected"); + #print("not connected"); exit; } - print("still connected"); + #print("still connected"); my $s2; $socket->recv($s2, $actual_len); - print($s2); + #print($s2); STDOUT->flush(); - my $script; - open($script, ">", "/tmp/omgscript") or die $!; - #$s3 = 'export HOME=\'/home/blinry/.local/share/Oh My Git/tmp/\';export PATH=\'/home/blinry/.local/share/Oh My Git/tmp/:\'"$PATH";cd \'/home/blinry/.local/share/Oh My Git/tmp/repos/yours/\' || exit 1;find . -type f -not -path \'*/\\.git/*\''; - print $script $s2; - close($script); - $s = ""; - $command = ". /tmp/omgscript" . "\necho MAGIC\n"; + $command = $s2 . "\necho MAGIC\n"; print $in $command; inner_while: while (true) { @@ -51,10 +45,10 @@ while(true) { } $s = $s . $line; } - print "got complete output"; - print $s; + #print "got complete output"; + #print $s; - print length($s); + #print length($s); STDOUT->flush(); my $send_length = pack("L", length($s)); $socket->send($send_length);