From: Zooko O'Whielacronx Date: Wed, 23 Jan 2008 17:04:26 +0000 (-0700) Subject: setup: make find_trial self-contained so that we don't have a bootstrapping problem... X-Git-Url: https://git.rkrishnan.org/FOOURL?a=commitdiff_plain;h=284c1652a9cff1055d92d3daba2f015df2f2e947;p=tahoe-lafs%2Ftahoe-lafs.git setup: make find_trial self-contained so that we don't have a bootstrapping problem -- if allmydata can't be imported we still want to be able to run find_trial --- diff --git a/misc/find_trial.py b/misc/find_trial.py index 2a6d817e..120d01b4 100644 --- a/misc/find_trial.py +++ b/misc/find_trial.py @@ -1,9 +1,36 @@ import sys -from allmydata.util import find_exe +import os, sys +from twisted.python.procutils import which + +def find_exe(exename): + """ + Look for something named exename or exename + ".py". + + This is a kludge. + + @return: a list containing one element which is the path to the exename + (if it is thought to be executable), or else the first element being + sys.executable and the second element being the path to the + exename + ".py", or else return False if one can't be found + """ + exes = which(exename) + exe = exes and exes[0] + if not exe: + exe = os.path.join(sys.prefix, 'scripts', exename + '.py') + if os.path.exists(exe): + path, ext = os.path.splitext(exe) + if ext.lower() in [".exe", ".bat",]: + cmd = [exe,] + else: + cmd = [sys.executable, exe,] + return cmd + else: + return False + if __name__ == "__main__": - cmd = find_exe.find_exe("trial") + cmd = find_exe("trial") if cmd: print " ".join(cmd).replace("\\", "/") else: