9 tuerSock = "/run/tuer.sock"
12 histfile = os.path.join(os.path.expanduser("~"), ".tyshellhist")
14 readline.read_history_file(histfile)
18 atexit.register(readline.write_history_file, histfile)
19 atexit.register(print, "Bye")
23 print("Available commands: %s" % ", ".join(sorted(commands.keys())))
27 ret = subprocess.call(cmd)
29 print("Command returned non-zero exit statis %d" % ret)
32 def sendcmd(addr, cmd):
34 print("Running %s..." % (cmd))
35 s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
42 print("Received unexpected answer %s" % str(data))
51 'open': sendcmd(tuerSock, 'open'),
52 'close': sendcmd(tuerSock, 'close'),
53 'buzz': sendcmd(tuerSock, 'buzz'),
57 print("Welcome to tyshell. Use help to see what you can do.")
64 command = shlex.split(command)
65 if not len(command): continue
67 if command[0] in commands:
69 commands[command[0]](command)
70 except Exception as e:
71 print("Error while executing %s: %s" % (command[0], str(e)))
73 print("Command %s not found. Use help." % command[0])