Support Python 2.4

This commit is contained in:
Tim Pope 2013-04-17 13:35:47 -04:00
parent 93df7ca18f
commit 77444275fd
1 changed files with 17 additions and 16 deletions

View File

@ -216,7 +216,7 @@ def fireplace_string_encode(input):
str_list = [] str_list = []
for c in input: for c in input:
if (000 <= ord(c) and ord(c) <= 037) or c == '"' or c == "\\": if (000 <= ord(c) and ord(c) <= 037) or c == '"' or c == "\\":
str_list.append("\\{0:03o}".format(ord(c))) str_list.append("\\{0:03o}" % ord(c))
else: else:
str_list.append(c) str_list.append(c)
return '"' + ''.join(str_list) + '"' return '"' + ''.join(str_list) + '"'
@ -231,21 +231,22 @@ def fireplace_repl_interact():
port = int(vim.eval('self.port')) port = int(vim.eval('self.port'))
s.settimeout(8) s.settimeout(8)
try: try:
s.connect((host, port)) try:
s.setblocking(1) s.connect((host, port))
s.sendall(vim.eval('payload')) s.setblocking(1)
while True: s.sendall(vim.eval('payload'))
while len(select.select([s], [], [], 0.1)[0]) == 0: while True:
vim.eval('getchar(1)') while len(select.select([s], [], [], 0.1)[0]) == 0:
body = s.recv(8192) vim.eval('getchar(1)')
if re.search("=> $", body) != None: body = s.recv(8192)
raise Exception("not an nREPL server: upgrade to Leiningen 2") if re.search("=> $", body) != None:
buffer += body raise Exception("not an nREPL server: upgrade to Leiningen 2")
if string.find(body, '6:statusl4:done') != -1: buffer += body
break if string.find(body, '6:statusl4:done') != -1:
fireplace_let('out', buffer) break
except Exception, e: fireplace_let('out', buffer)
fireplace_let('err', str(e)) except Exception, e:
fireplace_let('err', str(e))
finally: finally:
s.close() s.close()
EOF EOF