1

I'm having issues with Python finding an available Executable on my Linux machine. My default PATH includes this Executable (svnlook) but when I run the python script the below function fails to find executable. Any ideas on how to fix this?

def command_output(cmd):
    child  = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE)
    output = child.communicate()[0]
    return output, child.returncode


def get_author():
    cmd = "svnlook author %s %s %s" % (svn_opt, svn_txn, svn_repo)
    author, return_code = command_output(cmd)

    return author.strip()

Error:

 Traceback (most recent call last):
  File "/home/user/app/csvn/data/repositories/repo/hooks/pre-commit", line 82, in <module>
    author = get_author()
  File "/home/user/app/csvn/data/repositories/repo/hooks/pre-commit", line 53, in get_author
    author, return_code = command_output(cmd)
  File "/home/user/app/csvn/data/repositories/repo/hooks/pre-commit", line 36, in command_output
    child  = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE)
  File "/home/user/app/activepython-2.7.2.5_x86_64/lib/python2.7/subprocess.py", line 679, in __init__
    errread, errwrite)
  File "/home/user/app/activepython-2.7.2.5_x86_64/lib/python2.7/subprocess.py", line 1228, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory
Error: [Errno 2] No such file or directory
c12
  • 9,557
  • 48
  • 157
  • 253

2 Answers2

1

You probably want to provide the full path to the executable, e.g. /usr/bin/svnlook or /usr/local/bin/svnlook instead of just svnlook.

See this answer to a related question for details.

Community
  • 1
  • 1
Kimvais
  • 38,306
  • 16
  • 108
  • 142
0

Try running it from the console. Make sure the permissions/executability is correct. Try os.system().

Dustin Oprea
  • 9,673
  • 13
  • 65
  • 105