9 tuerSock = "/run/tuer.sock"
12 # FIXME: Why not ".tyshellhist"?
13 histfile = os.path.join(os.path.expanduser("~"), ".pyshellhist")
15 readline.read_history_file(histfile)
19 atexit.register(readline.write_history_file, histfile)
20 atexit.register(print, "Bye")
24 print("Available commands: %s" % ", ".join(sorted(commands.keys())))
28 ret = subprocess.call(cmd)
30 print("Command returned non-zero exit statis %d" % ret)
33 def sendcmd(addr, cmd):
35 print("Running %s..." % (cmd))
36 s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
43 print("Received unexpected answer %s" % str(data))
52 'open': sendcmd(tuerSock, 'open'),
53 'close': sendcmd(tuerSock, 'close'),
54 'buzz': sendcmd(tuerSock, 'buzz'),
58 print("Welcome to tyshell. Use help to see what you can do.")
65 command = shlex.split(command)
66 if not len(command): continue
68 if command[0] in commands:
70 commands[command[0]](command)
71 except Exception as e:
72 print("Error while executing %s: %s" % (command[0], str(e)))
74 print("Command %s not found. Use help." % command[0])