trouble controlling vim with subprocess on windows machine

Eric_Dexter at msn.com Eric_Dexter at msn.com
Mon Jul 9 04:36:26 EDT 2007


     I am having trouble contolling vim with subprocess on a windows
machine.  It appears that vim comes up on the machine all right and it
sometimes looks like it is doing the searchs what I am asking it to do
but when I am asking it to load a file it doesn't do anything.  Is
there something I need to do to push the data through the pipe??  Here
is a couple different ways I am trying to do it.

def load_instrument(instr_name, csdname):
    "load an instrument using vim a path should be defined for vim
currently I am doing that with the .bat file that loads the program"
    f = open('csdfile.tmp','w')
    my_path = "/dex tracker"
    cmd = ["gvim",csdname]
    vimin = subprocess.Popen(cmd,stdin=subprocess.PIPE)#.comunicate()
[0] #, stdout = f, stderr = f, cwd = my_path )
    #f.close
    #x = subprocess.Popen("clear").communicate(None)[0]
    innum = csr.return_unique_instr_number(csdname) - 1
    cmd = """/;<start""" + str(innum) + '>' +'\n'
    print(cmd)
    vimin.stdin.write(cmd)
    cmd = """/;<endin>""" +'\n'
    vimin.stdin.communicate(cmd)
    cmd = ':r ' + instr_name +'\n'
    print(cmd)
    vimin.stdin.write(cmd)
    #vimin.stdin.write(instr_name + '\n')
    cmd = instr_name + '\n'

    f.close()
def load_instrument2(instr_name, csdname):
  "second try uses comunicate"
  cmd = ["gvim",csdname]
  proc = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE, )
  cmd = """/;start""" + '\n'
  proc.communicate(cmd)[0]
  cmd = """/;<endin>""" + '\n'
  proc.communicate(cmd)[0]
  cmd = ':r ' + instr_name  + '/n'
  proc.communicate(cmd)[0]
  proc.close()

I am calling these with

load_instrument2("""strings.orc""",'bay-at-night.csd')

and I define the path of vim in a batch file befour I call the
routines

path c:\program files\vim\vim71
python_awk_bridge.py
pause




More information about the Python-list mailing list