Cleaner about tty
authorAlyssa Rosenzweig <alyssa@rosenzweig.io>
Mon, 25 Jun 2018 20:43:18 +0000 (16:43 -0400)
committerAlyssa Rosenzweig <alyssa@rosenzweig.io>
Mon, 25 Jun 2018 20:43:18 +0000 (16:43 -0400)
libremanage

index 315da3ad563a0c955f1c1bf6cb9be39d553eab72..280d1df1ebf660c194105ed4e31565bdc718944e 100755 (executable)
@@ -41,9 +41,9 @@ import json
 import functools
 import subprocess
 
-def open_ssh(server, command):
+def open_ssh(server, command, force_tty=False):
     config = server["ssh"]
-    subprocess.run(["ssh", "-t", config["username"] + "@" + config["host"], "-p", str(config["port"]), command])
+    subprocess.run(["ssh", "-t" if force_tty else "", config["username"] + "@" + config["host"], "-p", str(config["port"]), command])
 
 def die_with_usage(message):
     print(message)
@@ -86,7 +86,7 @@ COMMANDS = {
 
         # TTY access (or keyboard if wired as such)
 
-        "tty": lambda s: open_ssh(s, "screen " + s["tty"]["file"] + " " + str(s["tty"]["baud"])),
+        "tty": lambda s: open_ssh(s, "screen " + s["tty"]["file"] + " " + str(s["tty"]["baud"]), force_tty=True),
 
         # SSH sanity tests