mirror of
https://github.com/kennethreitz-archive/python-build.git
synced 2026-06-05 23:30:18 +00:00
update py command
This commit is contained in:
@@ -15,4 +15,4 @@ def main():
|
||||
parser.error("Unknown command: `%s`" % command)
|
||||
return
|
||||
command = command_dict[command]
|
||||
command.run(args)
|
||||
command.run(args[1:])
|
||||
|
||||
@@ -18,7 +18,7 @@ class Command(object):
|
||||
|
||||
def run(self, args):
|
||||
options, args = self.parser.parse_args(args)
|
||||
self.run_command(options, args[1:])
|
||||
self.run_command(options, args)
|
||||
|
||||
def load_command(name):
|
||||
full_name = 'pythonbrew.commands.%s' % name
|
||||
|
||||
+11
-19
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user