Skip to content

Commit

Permalink
1. Add a command line switch to run without the subprocess
Browse files Browse the repository at this point in the history
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
  • Loading branch information
kbkaiser committed May 15, 2003
1 parent 5db4843 commit 8f570a7
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 18 deletions.
38 changes: 20 additions & 18 deletions Lib/idlelib/PyShell.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ def start_subprocess(self):
self.rpcclt = rpc.RPCClient(addr)
break
except socket.error, err:
print>>sys.__stderr__,"Idle socket error: " + err[1]\
print>>sys.__stderr__,"IDLE socket error: " + err[1]\
+ ", retrying..."
else:
display_port_binding_error()
Expand Down Expand Up @@ -650,7 +650,6 @@ class PyShell(OutputWindow):
menu_specs = [
("file", "_File"),
("edit", "_Edit"),
("shell", "_Shell"),
("debug", "_Debug"),
("options", "_Options"),
("windows", "_Windows"),
Expand All @@ -661,6 +660,8 @@ class PyShell(OutputWindow):
from IdleHistory import History

def __init__(self, flist=None):
if use_subprocess:
self.menu_specs.insert(2, ("shell", "_Shell"))
self.interp = ModifiedInterpreter(self)
if flist is None:
root = Tk()
Expand All @@ -686,8 +687,9 @@ def __init__(self, flist=None):
text.bind("<<toggle-debugger>>", self.toggle_debugger)
text.bind("<<open-python-shell>>", self.flist.open_shell)
text.bind("<<toggle-jit-stack-viewer>>", self.toggle_jit_stack_viewer)
text.bind("<<view-restart>>", self.view_restart_mark)
text.bind("<<restart-shell>>", self.restart_shell)
if use_subprocess:
text.bind("<<view-restart>>", self.view_restart_mark)
text.bind("<<restart-shell>>", self.restart_shell)
#
self.save_stdout = sys.stdout
self.save_stderr = sys.stderr
Expand Down Expand Up @@ -810,7 +812,7 @@ def short_title(self):
return self.shell_title

COPYRIGHT = \
'Type "copyright", "credits" or "license" for more information.'
'Type "copyright", "credits" or "license()" for more information.'

def begin(self):
self.resetoutput()
Expand Down Expand Up @@ -1072,6 +1074,7 @@ def isatty(self):
idle [-ds] [-t title] - [arg]*
-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:
Expand Down Expand Up @@ -1120,6 +1123,7 @@ def isatty(self):
def main():
global flist, root, use_subprocess

use_subprocess = True
enable_shell = False
enable_edit = False
debug = False
Expand All @@ -1131,7 +1135,7 @@ def main():
except AttributeError:
sys.ps1 = '>>> '
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:
sys.stderr.write("Error: %s\n" % str(msg))
sys.stderr.write(usage_msg)
Expand All @@ -1150,6 +1154,8 @@ def main():
sys.exit()
if o == '-i':
enable_shell = True
if o == '-n':
use_subprocess = False
if o == '-r':
script = a
if os.path.isfile(script):
Expand All @@ -1167,9 +1173,6 @@ def main():
if args and args[0] == '-':
cmd = sys.stdin.read()
enable_shell = True

use_subprocess = True

# process sys.argv and sys.path:
for i in range(len(sys.path)):
sys.path[i] = os.path.abspath(sys.path[i])
Expand Down Expand Up @@ -1202,7 +1205,6 @@ def main():
fixwordbreaks(root)
root.withdraw()
flist = PyShellFileList(root)

if enable_edit:
if not (cmd or script):
for filename in args:
Expand Down Expand Up @@ -1239,19 +1241,19 @@ def main():

def display_port_binding_error():
print """\
IDLE cannot run.
\nIDLE cannot run.
IDLE needs to use a specific TCP/IP port (8833) in order to execute and
debug programs. IDLE is unable to bind to this port, and so cannot
start. Here are some possible causes of this problem:
IDLE needs to use a specific TCP/IP port (8833) in order to communicate with
its Python execution server. IDLE is unable to bind to this port, and so
cannot start. Here are some possible causes of this problem:
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
IDLE makes and accepts connections only with this computer, and does not
communicate over the internet in any way. Its use of port 8833 should not
be a security risk on a single-user machine.
Run IDLE with the -n command line switch to start without a subprocess
and refer to Help/IDLE Help "Running without a subprocess" for further
details.
"""

if __name__ == "__main__":
Expand Down
13 changes: 13 additions & 0 deletions Lib/idlelib/help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -191,3 +191,16 @@ Other preferences:
Command line usage:

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.

0 comments on commit 8f570a7

Please sign in to comment.