Allow non-string arguments to python dispatch

This commit is contained in:
Tim Pope 2014-01-09 21:55:21 -05:00
parent 28a6c2c262
commit 40bad28354
2 changed files with 10 additions and 7 deletions

View File

@ -193,17 +193,18 @@ endfunction
let s:keepalive = tempname() let s:keepalive = tempname()
call writefile([getpid()], s:keepalive) call writefile([getpid()], s:keepalive)
function! s:nrepl_command(args) dict abort function! s:nrepl_command(cmd, args) dict abort
return 'python' return 'python'
\ . ' ' . s:shellesc(s:python_dir.'/nrepl_fireplace.py') \ . ' ' . s:shellesc(s:python_dir.'/nrepl_fireplace.py')
\ . ' ' . s:shellesc(self.host) \ . ' ' . s:shellesc(self.host)
\ . ' ' . s:shellesc(self.port) \ . ' ' . s:shellesc(self.port)
\ . ' ' . s:shellesc(s:keepalive) \ . ' ' . s:shellesc(s:keepalive)
\ . ' ' . join(map(copy(a:args), 's:shellesc(v:val)'), ' ') \ . ' ' . s:shellesc(a:cmd)
\ . ' ' . join(map(copy(a:args), 's:shellesc(nrepl#fireplace_connection#bencode(v:val))'), ' ')
endfunction endfunction
function! s:nrepl_dispatch(...) dict abort function! s:nrepl_dispatch(cmd, ...) dict abort
let in = self.command(a:000) let in = self.command(a:cmd, a:000)
let out = system(in) let out = system(in)
if !v:shell_error if !v:shell_error
return eval(out) return eval(out)

View File

@ -1,7 +1,9 @@
import sys import re
import select import select
import socket import socket
import re import sys
from StringIO import StringIO
def noop(): def noop():
pass pass
@ -110,7 +112,7 @@ def dispatch(host, port, poll, keepalive, command, *args):
def main(host, port, keepalive, command, *args): def main(host, port, keepalive, command, *args):
try: try:
sys.stdout.write(vim_encode(dispatch(host, port, noop, keepalive, command, *args))) sys.stdout.write(vim_encode(dispatch(host, port, noop, keepalive, command, *[bdecode(StringIO(arg)) for arg in args])))
except Exception, e: except Exception, e:
print(e) print(e)
exit(1) exit(1)