update py command

This commit is contained in:
utahta
2011-05-19 18:29:31 +09:00
parent a1e3d240ef
commit 91101100a7
2 changed files with 19 additions and 3 deletions
+17 -3
View File
@@ -28,6 +28,18 @@ class PyCommand(Command):
default=False,
help="Show the running python version."
)
self.parser.add_option(
"-b", "--bin",
dest="bin",
default='python',
help="Use the specified script in python's bin directory."
)
self.parser.add_option(
"-o", "--options",
dest="options",
default='',
help="Options passed directly to runs script."
)
def run_command(self, options, args):
if not args:
@@ -37,16 +49,18 @@ class PyCommand(Command):
pythons = self._get_pythons(options.pythons)
for d in pythons:
path = os.path.join(PATH_PYTHONS, d, 'bin', 'python')
path = os.path.join(PATH_PYTHONS, d, 'bin', options.bin)
if os.path.isfile(path) and os.access(path, os.X_OK):
if options.verbose:
logger.info('*** %s ***' % d)
p = Popen("%s %s" % (path, python_file), shell=True)
p = Popen("%s %s %s" % (path, options.options, python_file), shell=True)
p.wait()
else:
logger.info('%s: No such file or directory.' % path)
def _get_pythons(self, _pythons):
pythons = [Package(p).name for p in _pythons]
return [d for d in sorted(os.listdir(PATH_PYTHONS))
return [d for d in sorted(os.listdir(PATH_PYTHONS))
if not pythons or d in pythons]
PyCommand()
+2
View File
@@ -3,6 +3,8 @@ from tests import TESTPY_FILE
class PyOptions(object):
pythons = []
verbose = False
bin = "python"
options = ""
def _create_pyfile():
fp = open(TESTPY_FILE, 'w')