source file: /home/buildslave/tahoe/edgy/build/src/allmydata/util/find_exe.py
file stats: 14 lines, 11 executed: 78.6% covered
1. import os, sys 2. from twisted.python.procutils import which 3. 4. def find_exe(exename): 5. """ 6. Look for something named exename or exename + ".py". 7. 8. This is a kludge. 9. 10. @return: a list containing one element which is the path to the exename 11. (if it is thought to be executable), or else the first element being 12. sys.executable and the second element being the path to the 13. exename + ".py", or else return False if one can't be found 14. """ 15. exes = which(exename) 16. exe = exes and exes[0] 17. if not exe: 18. exe = os.path.join(sys.prefix, 'scripts', exename + '.py') 19. if os.path.exists(exe): 20. path, ext = os.path.splitext(exe) 21. if ext.lower() in [".exe", ".bat",]: 22. cmd = [exe,] 23. else: 24. cmd = [sys.executable, exe,] 25. return cmd 26. else: 27. return False 28.