Commit 8f570a76 authored by Kurt B. Kaiser's avatar Kurt B. Kaiser

1. Add a command line switch to run without the subprocess

2. Remove the shell menu and associated bindings when running
   without the subprocess.
3. Update the IDLE Help and usage text.
4. Update display_port_binding_error to suggest using -n

M PyShell.py
M help.txt
parent 5db4843c
...@@ -332,7 +332,7 @@ class ModifiedInterpreter(InteractiveInterpreter): ...@@ -332,7 +332,7 @@ class ModifiedInterpreter(InteractiveInterpreter):
self.rpcclt = rpc.RPCClient(addr) self.rpcclt = rpc.RPCClient(addr)
break break
except socket.error, err: except socket.error, err:
print>>sys.__stderr__,"Idle socket error: " + err[1]\ print>>sys.__stderr__,"IDLE socket error: " + err[1]\
+ ", retrying..." + ", retrying..."
else: else:
display_port_binding_error() display_port_binding_error()
...@@ -650,7 +650,6 @@ class PyShell(OutputWindow): ...@@ -650,7 +650,6 @@ class PyShell(OutputWindow):
menu_specs = [ menu_specs = [
("file", "_File"), ("file", "_File"),
("edit", "_Edit"), ("edit", "_Edit"),
("shell", "_Shell"),
("debug", "_Debug"), ("debug", "_Debug"),
("options", "_Options"), ("options", "_Options"),
("windows", "_Windows"), ("windows", "_Windows"),
...@@ -661,6 +660,8 @@ class PyShell(OutputWindow): ...@@ -661,6 +660,8 @@ class PyShell(OutputWindow):
from IdleHistory import History from IdleHistory import History
def __init__(self, flist=None): def __init__(self, flist=None):
if use_subprocess:
self.menu_specs.insert(2, ("shell", "_Shell"))
self.interp = ModifiedInterpreter(self) self.interp = ModifiedInterpreter(self)
if flist is None: if flist is None:
root = Tk() root = Tk()
...@@ -686,8 +687,9 @@ class PyShell(OutputWindow): ...@@ -686,8 +687,9 @@ class PyShell(OutputWindow):
text.bind("<<toggle-debugger>>", self.toggle_debugger) text.bind("<<toggle-debugger>>", self.toggle_debugger)
text.bind("<<open-python-shell>>", self.flist.open_shell) text.bind("<<open-python-shell>>", self.flist.open_shell)
text.bind("<<toggle-jit-stack-viewer>>", self.toggle_jit_stack_viewer) text.bind("<<toggle-jit-stack-viewer>>", self.toggle_jit_stack_viewer)
text.bind("<<view-restart>>", self.view_restart_mark) if use_subprocess:
text.bind("<<restart-shell>>", self.restart_shell) text.bind("<<view-restart>>", self.view_restart_mark)
text.bind("<<restart-shell>>", self.restart_shell)
# #
self.save_stdout = sys.stdout self.save_stdout = sys.stdout
self.save_stderr = sys.stderr self.save_stderr = sys.stderr
...@@ -810,7 +812,7 @@ class PyShell(OutputWindow): ...@@ -810,7 +812,7 @@ class PyShell(OutputWindow):
return self.shell_title return self.shell_title
COPYRIGHT = \ COPYRIGHT = \
'Type "copyright", "credits" or "license" for more information.' 'Type "copyright", "credits" or "license()" for more information.'
def begin(self): def begin(self):
self.resetoutput() self.resetoutput()
...@@ -1072,6 +1074,7 @@ USAGE: idle [-deis] [-t title] [file]* ...@@ -1072,6 +1074,7 @@ USAGE: idle [-deis] [-t title] [file]*
idle [-ds] [-t title] - [arg]* idle [-ds] [-t title] - [arg]*
-h print this help message and exit -h print this help message and exit
-n run IDLE without a subprocess (see Help/IDLE Help for details)
The following options will override the IDLE 'settings' configuration: The following options will override the IDLE 'settings' configuration:
...@@ -1120,6 +1123,7 @@ echo "import sys; print sys.argv" | idle - "foobar" ...@@ -1120,6 +1123,7 @@ echo "import sys; print sys.argv" | idle - "foobar"
def main(): def main():
global flist, root, use_subprocess global flist, root, use_subprocess
use_subprocess = True
enable_shell = False enable_shell = False
enable_edit = False enable_edit = False
debug = False debug = False
...@@ -1131,7 +1135,7 @@ def main(): ...@@ -1131,7 +1135,7 @@ def main():
except AttributeError: except AttributeError:
sys.ps1 = '>>> ' sys.ps1 = '>>> '
try: try:
opts, args = getopt.getopt(sys.argv[1:], "c:deihr:st:") opts, args = getopt.getopt(sys.argv[1:], "c:deihnr:st:")
except getopt.error, msg: except getopt.error, msg:
sys.stderr.write("Error: %s\n" % str(msg)) sys.stderr.write("Error: %s\n" % str(msg))
sys.stderr.write(usage_msg) sys.stderr.write(usage_msg)
...@@ -1150,6 +1154,8 @@ def main(): ...@@ -1150,6 +1154,8 @@ def main():
sys.exit() sys.exit()
if o == '-i': if o == '-i':
enable_shell = True enable_shell = True
if o == '-n':
use_subprocess = False
if o == '-r': if o == '-r':
script = a script = a
if os.path.isfile(script): if os.path.isfile(script):
...@@ -1167,9 +1173,6 @@ def main(): ...@@ -1167,9 +1173,6 @@ def main():
if args and args[0] == '-': if args and args[0] == '-':
cmd = sys.stdin.read() cmd = sys.stdin.read()
enable_shell = True enable_shell = True
use_subprocess = True
# process sys.argv and sys.path: # process sys.argv and sys.path:
for i in range(len(sys.path)): for i in range(len(sys.path)):
sys.path[i] = os.path.abspath(sys.path[i]) sys.path[i] = os.path.abspath(sys.path[i])
...@@ -1202,7 +1205,6 @@ def main(): ...@@ -1202,7 +1205,6 @@ def main():
fixwordbreaks(root) fixwordbreaks(root)
root.withdraw() root.withdraw()
flist = PyShellFileList(root) flist = PyShellFileList(root)
if enable_edit: if enable_edit:
if not (cmd or script): if not (cmd or script):
for filename in args: for filename in args:
...@@ -1239,19 +1241,19 @@ def main(): ...@@ -1239,19 +1241,19 @@ def main():
def display_port_binding_error(): def display_port_binding_error():
print """\ print """\
IDLE cannot run. \nIDLE cannot run.
IDLE needs to use a specific TCP/IP port (8833) in order to execute and IDLE needs to use a specific TCP/IP port (8833) in order to communicate with
debug programs. IDLE is unable to bind to this port, and so cannot its Python execution server. IDLE is unable to bind to this port, and so
start. Here are some possible causes of this problem: cannot start. Here are some possible causes of this problem:
1. TCP/IP networking is not installed or not working on this computer 1. TCP/IP networking is not installed or not working on this computer
2. Another program is running that uses this port 2. Another program (another IDLE?) is running that uses this port
3. Personal firewall software is preventing IDLE from using this port 3. Personal firewall software is preventing IDLE from using this port
IDLE makes and accepts connections only with this computer, and does not Run IDLE with the -n command line switch to start without a subprocess
communicate over the internet in any way. Its use of port 8833 should not and refer to Help/IDLE Help "Running without a subprocess" for further
be a security risk on a single-user machine. details.
""" """
if __name__ == "__main__": if __name__ == "__main__":
......
...@@ -191,3 +191,16 @@ Other preferences: ...@@ -191,3 +191,16 @@ Other preferences:
Command line usage: Command line usage:
Enter idle -h at the command prompt to get a usage message. Enter idle -h at the command prompt to get a usage message.
Running without a subprocess:
If IDLE is started with the -n command line switch it will run in a
single process and will not create the subprocess which runs the RPC
Python execution server. This can be useful if Python cannot create
the subprocess or the RPC socket interface on your platform. However,
in this mode user code is not isolated from IDLE itself. Also, the
environment is not restarted when Run/Run Module (F5) is selected. If
your code has been modified, you must reload() the affected modules and
re-import any specific items (e.g. from foo import baz) if the changes
are to take effect. For these reasons, it is preferable to run IDLE
with the default subprocess if at all possible.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment