开发者

Python OSError: [Errno 2] No such file or directory

I am trying to write this script to my linux terminal and I am recieving the following error message: "OSError: [Errno 2] No such file or directory". Can anyone help, Thanks

开发者_JAVA百科#!/home/build/test/Python-2.6.4

import os, subprocess

   # Create a long command line
cmd =[\
 "si createsandbox --yes --hostname=be", \
 " --port=70", \
 " --user=gh", \
 " --password=34", \
 "  --populate --project=e:/project.pj", \
 " --lineTerminator=lf new_sandbox"\
 ]

outFile = os.path.join(os.curdir, "output.log")
outptr = file(outFile, "w")

errFile = os.path.join(os.curdir, "error.log")
errptr = file(errFile, "w")

retval = subprocess.call(cmd, 0, None, None, outptr, errptr)

errptr.close()
outptr.close()

if not retval == 0:
  errptr = file(errFile, "r")
  errData = errptr.read()
  errptr.close()
  raise Exception("Error executing command: " + repr(errData))


If the error is in your script, May be you got error on this line

errptr = file(errFile, "r")

you can do like

if os.path.exists(errFile):
  errptr = file(errFile, "r")
  errData = errptr.read()
  errptr.close()
  raise Exception("Error executing command: " + repr(errData))

And also try with fullpath for command "si" like /usr/bin/si instead of just si


try modify like this:

cmd =[\
  "si", \
  " createsandbox --yes --hostname=be", \
  " --port=70", \
  " --user=gh", \
  " --password=34", \
  "  --populate --project=e:/project.pj", \
  " --lineTerminator=lf new_sandbox"\
]

I guset subprocess.call will think that the first parameter which in "" is a command

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜