comparison src/testdir/test_channel.py @ 7914:35973ce58c84 v7.4.1253

commit https://github.com/vim/vim/commit/608a8919cae982cb38e38725a843df47b234dae6 Author: Bram Moolenaar <Bram@vim.org> Date: Wed Feb 3 22:39:51 2016 +0100 patch 7.4.1253 Problem: Python test server not displaying second of two commands. Solaris doesn't have "pkill --full". Solution: Also echo the second command. Use "pkill -f".
author Christian Brabandt <cb@256bit.org>
date Wed, 03 Feb 2016 22:45:04 +0100
parents 1c6ef9113556
children 54602dcac207
comparison
equal deleted inserted replaced
7913:a3d82880fca7 7914:35973ce58c84
32 print("=== socket opened ===") 32 print("=== socket opened ===")
33 global thesocket 33 global thesocket
34 thesocket = self.request 34 thesocket = self.request
35 while True: 35 while True:
36 try: 36 try:
37 data = self.request.recv(4096).decode('utf-8') 37 received = self.request.recv(4096).decode('utf-8')
38 except socket.error: 38 except socket.error:
39 print("=== socket error ===") 39 print("=== socket error ===")
40 break 40 break
41 except IOError: 41 except IOError:
42 print("=== socket closed ===") 42 print("=== socket closed ===")
43 break 43 break
44 if data == '': 44 if received == '':
45 print("=== socket closed ===") 45 print("=== socket closed ===")
46 break 46 break
47 print("received: {}".format(data)) 47 print("received: {}".format(received))
48 48
49 # We may receive two messages at once. Take the part up to the 49 # We may receive two messages at once. Take the part up to the
50 # matching "]" (recognized by finding "]["). 50 # matching "]" (recognized by finding "][").
51 while data != '': 51 todo = received
52 splitidx = data.find('][') 52 while todo != '':
53 splitidx = todo.find('][')
53 if splitidx < 0: 54 if splitidx < 0:
54 todo = data 55 used = todo
55 data = '' 56 todo = ''
56 else: 57 else:
57 todo = data[:splitidx + 1] 58 used = todo[:splitidx + 1]
58 data = data[splitidx + 1:] 59 todo = todo[splitidx + 1:]
59 print("using: {}".format(todo)) 60 if used != received:
61 print("using: {}".format(used))
60 62
61 try: 63 try:
62 decoded = json.loads(todo) 64 decoded = json.loads(used)
63 except ValueError: 65 except ValueError:
64 print("json decoding failed") 66 print("json decoding failed")
65 decoded = [-1, ''] 67 decoded = [-1, '']
66 68
67 # Send a response if the sequence number is positive. 69 # Send a response if the sequence number is positive.