Skip to content

Commit c921488

Browse files
committed
update py command
1 parent 0dfc0d3 commit c921488

3 files changed

Lines changed: 13 additions & 21 deletions

File tree

pythonbrew/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ def main():
1515
parser.error("Unknown command: `%s`" % command)
1616
return
1717
command = command_dict[command]
18-
command.run(args)
18+
command.run(args[1:])

pythonbrew/basecommand.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def __init__(self):
1818

1919
def run(self, args):
2020
options, args = self.parser.parse_args(args)
21-
self.run_command(options, args[1:])
21+
self.run_command(options, args)
2222

2323
def load_command(name):
2424
full_name = 'pythonbrew.commands.%s' % name

pythonbrew/commands/py.py

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -28,35 +28,27 @@ def __init__(self):
2828
default=False,
2929
help="Show the running python version."
3030
)
31-
self.parser.add_option(
32-
"-b", "--bin",
33-
dest="bin",
34-
default='python',
35-
help="Use the specified script in python's bin directory."
36-
)
37-
self.parser.add_option(
38-
"-o", "--options",
39-
dest="options",
40-
default='',
41-
help="Options passed directly to runs script."
42-
)
31+
self.parser.disable_interspersed_args()
4332

4433
def run_command(self, options, args):
4534
if not args:
4635
logger.info("Unrecognized command line argument: argument not found.")
4736
sys.exit(1)
48-
python_file = args[0]
49-
5037
pythons = self._get_pythons(options.pythons)
5138
for d in pythons:
52-
path = os.path.join(PATH_PYTHONS, d, 'bin', options.bin)
39+
if options.verbose:
40+
logger.info('*** %s ***' % d)
41+
path = os.path.join(PATH_PYTHONS, d, 'bin', args[0])
5342
if os.path.isfile(path) and os.access(path, os.X_OK):
54-
if options.verbose:
55-
logger.info('*** %s ***' % d)
56-
p = Popen("%s %s %s" % (path, options.options, python_file), shell=True)
43+
p = Popen("%s %s" % (path, ' '.join(args[1:])), shell=True)
5744
p.wait()
5845
else:
59-
logger.info('%s: No such file or directory.' % path)
46+
path = os.path.join(PATH_PYTHONS, d, 'bin', 'python')
47+
if os.path.isfile(path) and os.access(path, os.X_OK):
48+
p = Popen("%s %s" % (path, ' '.join(args)), shell=True)
49+
p.wait()
50+
else:
51+
logger.info('%s: No such file or directory.' % path)
6052

6153
def _get_pythons(self, _pythons):
6254
pythons = [Package(p).name for p in _pythons]

0 commit comments

Comments
 (0)