update py command

This commit is contained in:
Yuta
2011-05-25 01:01:35 +09:00
parent 0dfc0d38f1
commit c92148805d
3 changed files with 13 additions and 21 deletions
+11 -19
View File
@@ -28,35 +28,27 @@ 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."
)
self.parser.disable_interspersed_args()
def run_command(self, options, args):
if not args:
logger.info("Unrecognized command line argument: argument not found.")
sys.exit(1)
python_file = args[0]
pythons = self._get_pythons(options.pythons)
for d in pythons:
path = os.path.join(PATH_PYTHONS, d, 'bin', options.bin)
if options.verbose:
logger.info('*** %s ***' % d)
path = os.path.join(PATH_PYTHONS, d, 'bin', args[0])
if os.path.isfile(path) and os.access(path, os.X_OK):
if options.verbose:
logger.info('*** %s ***' % d)
p = Popen("%s %s %s" % (path, options.options, python_file), shell=True)
p = Popen("%s %s" % (path, ' '.join(args[1:])), shell=True)
p.wait()
else:
logger.info('%s: No such file or directory.' % path)
path = os.path.join(PATH_PYTHONS, d, 'bin', 'python')
if os.path.isfile(path) and os.access(path, os.X_OK):
p = Popen("%s %s" % (path, ' '.join(args)), 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]