Johann Woelper 10 gadi atpakaļ
vecāks
revīzija
6c74f97996
2 mainītis faili ar 20 papildinājumiem un 3 dzēšanām
  1. 5 1
      pshell/test.py
  2. 15 2
      pshell/ttytest.py

+ 5 - 1
pshell/test.py

@@ -37,6 +37,7 @@ class Interceptor(object):
 
     def __init__(self):
         self.master_fd = None
+        self.buffer = ''
 
     def spawn(self, argv=None):
         '''
@@ -127,6 +128,9 @@ class Interceptor(object):
         '''
         master_fd = self.master_fd
         assert master_fd is not None
+        self.buffer = self.buffer + data
+        if 'echo' in self.buffer:
+            print self.buffer
         while data != '':
             n = os.write(master_fd, data)
             data = data[n:]
@@ -157,7 +161,7 @@ class Interceptor(object):
         Called when there is data to be sent from the user/controlling
                terminal down to the child process.
         '''
-        print data + '_'
+        #print i.write_stdout(data)
         self.write_master(data) 
 
 if __name__ == '__main__':

+ 15 - 2
pshell/ttytest.py

@@ -4,14 +4,27 @@ import tty
 import termios
 import os
 
-print "#> ",
+#print "#> ",
 os.system("stty cbreak -echo")
+
 cmdstring = ''
 while True: 
     #print '---'
     a = sys.stdin.read(1)
     cmdstring = cmdstring + a
-    sys.stdout.write(cmdstring)
+    sys.stdout.write('> ' + cmdstring)
     sys.stdout.write('\r')
     sys.stdout.flush()
+
 os.system("stty -cbreak echo")
+
+
+
+"""
+fd = sys.stdin.fileno()
+old = termios.tcgetattr(fd)
+tty.setcbreak(fd)
+ch = sys.stdin.read(1)
+print "Read", ch
+termios.tcsetattr(fd, termios.TCSADRAIN, old)
+"""