Mercurial > cpython-lru_cache-weakref
annotate Lib/idlelib/PyShell.py @ 26659:d99e38bb6dcd legacy-trunk
M Debugger.py
M IOBinding.py
M PyShell.py
* Could not remove last set of saved breakpoints from a file
* Starting with empty edit window, could not load a file
* Multiple adjacent breakpoints were saved as one breakpoint
* Storing breakpoints whenever a file is closed can get them out
of synch with the saved version of a file. Only store them when the
file is saved.
* Add comment on current limitations on file editing in the presence of
breakpoints.
* Replace get_current_breaks() with update_breakpoints(), add an update to
PyShellEditorWindow.breakpoints, which is the master breakpoint data
structure, and which is used to reload the subprocess debugger.
* Revert Debugger.Debugger.load_breakpoints() to use editwin.breakpoints.
It is easier to debug the debugger if the breakpoint list in IDLE is
identical to the list in the subprocess debugger and is transferred when
the subprocess debugger is restarted, because this list can be easily
queried.
* Cleanup some linespacing and comments in IOBinding.py
| author | Kurt B. Kaiser <kbk@shore.net> |
|---|---|
| date | Sat, 14 Dec 2002 04:38:51 +0000 |
| parents | 615a25a6eb5b |
| children | f76717707a6d |
| rev | line source |
|---|---|
| 13975 | 1 #! /usr/bin/env python |
| 2 | |
| 3 import os | |
| 26468 | 4 import os.path |
| 13975 | 5 import sys |
| 6 import string | |
| 7 import getopt | |
| 8 import re | |
| 23547 | 9 import socket |
| 10 import time | |
| 25322 | 11 import traceback |
| 12 import types | |
| 26557 | 13 import exceptions |
| 13975 | 14 |
| 15 import linecache | |
| 16 from code import InteractiveInterpreter | |
| 17 | |
| 18 from Tkinter import * | |
| 19 import tkMessageBox | |
| 20 | |
| 21 from EditorWindow import EditorWindow, fixwordbreaks | |
| 22 from FileList import FileList | |
| 23 from ColorDelegator import ColorDelegator | |
| 24 from UndoDelegator import UndoDelegator | |
|
23784
24b0f6d693e3
Rework the code to have only the GvR RPC. Output from execution of user
Kurt B. Kaiser <kbk@shore.net>
parents:
23547
diff
changeset
|
25 from OutputWindow import OutputWindow |
|
20864
8957341f98f8
further config system work
Steven M. Gava <elguavas@python.net>
parents:
20306
diff
changeset
|
26 from configHandler import idleConf |
| 13975 | 27 import idlever |
| 28 | |
| 23547 | 29 import rpc |
|
23995
41468f9353ce
Shutdown subprocess debugger and associated Proxies/Adapters when closing
Kurt B. Kaiser <kbk@shore.net>
parents:
23969
diff
changeset
|
30 import RemoteDebugger |
| 23547 | 31 |
|
25346
6dec74f44242
Fix bug I created during merge from Python-idle.
Kurt B. Kaiser <kbk@shore.net>
parents:
25322
diff
changeset
|
32 IDENTCHARS = string.ascii_letters + string.digits + "_" |
|
6dec74f44242
Fix bug I created during merge from Python-idle.
Kurt B. Kaiser <kbk@shore.net>
parents:
25322
diff
changeset
|
33 |
| 23547 | 34 # Change warnings module to write to sys.__stderr__ |
| 35 try: | |
| 36 import warnings | |
| 37 except ImportError: | |
| 38 pass | |
| 39 else: | |
| 40 def idle_showwarning(message, category, filename, lineno): | |
| 41 file = sys.__stderr__ | |
| 42 file.write(warnings.formatwarning(message, category, filename, lineno)) | |
| 43 warnings.showwarning = idle_showwarning | |
| 44 | |
|
26463
c88f6fff1c3f
Correct an error introduced at Rev 1.30. The keyword arg is necessary
Kurt B. Kaiser <kbk@shore.net>
parents:
26028
diff
changeset
|
45 def extended_linecache_checkcache(orig_checkcache=linecache.checkcache): |
|
25894
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
46 """Extend linecache.checkcache to preserve the <pyshell#...> entries |
|
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
47 |
|
26463
c88f6fff1c3f
Correct an error introduced at Rev 1.30. The keyword arg is necessary
Kurt B. Kaiser <kbk@shore.net>
parents:
26028
diff
changeset
|
48 Rather than repeating the linecache code, patch it to save the pyshell# |
|
c88f6fff1c3f
Correct an error introduced at Rev 1.30. The keyword arg is necessary
Kurt B. Kaiser <kbk@shore.net>
parents:
26028
diff
changeset
|
49 entries, call the original linecache.checkcache(), and then restore the |
|
c88f6fff1c3f
Correct an error introduced at Rev 1.30. The keyword arg is necessary
Kurt B. Kaiser <kbk@shore.net>
parents:
26028
diff
changeset
|
50 saved entries. Assigning the orig_checkcache keyword arg freezes its value |
|
c88f6fff1c3f
Correct an error introduced at Rev 1.30. The keyword arg is necessary
Kurt B. Kaiser <kbk@shore.net>
parents:
26028
diff
changeset
|
51 at definition time to the (original) method linecache.checkcache(), i.e. |
|
c88f6fff1c3f
Correct an error introduced at Rev 1.30. The keyword arg is necessary
Kurt B. Kaiser <kbk@shore.net>
parents:
26028
diff
changeset
|
52 makes orig_checkcache lexical. |
|
25894
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
53 |
|
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
54 """ |
| 13975 | 55 cache = linecache.cache |
| 56 save = {} | |
| 57 for filename in cache.keys(): | |
| 58 if filename[:1] + filename[-1:] == '<>': | |
| 59 save[filename] = cache[filename] | |
| 60 orig_checkcache() | |
| 61 cache.update(save) | |
|
25894
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
62 |
|
26463
c88f6fff1c3f
Correct an error introduced at Rev 1.30. The keyword arg is necessary
Kurt B. Kaiser <kbk@shore.net>
parents:
26028
diff
changeset
|
63 # Patch linecache.checkcache(): |
|
c88f6fff1c3f
Correct an error introduced at Rev 1.30. The keyword arg is necessary
Kurt B. Kaiser <kbk@shore.net>
parents:
26028
diff
changeset
|
64 linecache.checkcache = extended_linecache_checkcache |
| 13975 | 65 |
|
25894
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
66 |
| 13975 | 67 class PyShellEditorWindow(EditorWindow): |
|
23995
41468f9353ce
Shutdown subprocess debugger and associated Proxies/Adapters when closing
Kurt B. Kaiser <kbk@shore.net>
parents:
23969
diff
changeset
|
68 "Regular text edit window when a shell is present" |
|
25894
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
69 |
| 13975 | 70 def __init__(self, *args): |
|
25894
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
71 self.breakpoints = [] |
| 13975 | 72 apply(EditorWindow.__init__, (self,) + args) |
| 73 self.text.bind("<<set-breakpoint-here>>", self.set_breakpoint_here) | |
|
25894
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
74 self.text.bind("<<clear-breakpoint-here>>", self.clear_breakpoint_here) |
| 13975 | 75 self.text.bind("<<open-python-shell>>", self.flist.open_shell) |
| 76 | |
| 26659 | 77 self.breakpointPath = os.path.join(idleConf.GetUserCfgDir(), |
| 78 'breakpoints.lst') | |
|
26025
18e09720738f
Recalls breakpoints set in a file
Chui Tey <chui.tey@advdata.com.au>
parents:
25894
diff
changeset
|
79 # whenever a file is changed, restore breakpoints |
|
18e09720738f
Recalls breakpoints set in a file
Chui Tey <chui.tey@advdata.com.au>
parents:
25894
diff
changeset
|
80 if self.io.filename: self.restore_file_breaks() |
| 26659 | 81 def filename_changed_hook(old_hook=self.io.filename_change_hook, |
| 82 self=self): | |
|
26025
18e09720738f
Recalls breakpoints set in a file
Chui Tey <chui.tey@advdata.com.au>
parents:
25894
diff
changeset
|
83 self.restore_file_breaks() |
|
18e09720738f
Recalls breakpoints set in a file
Chui Tey <chui.tey@advdata.com.au>
parents:
25894
diff
changeset
|
84 old_hook() |
|
18e09720738f
Recalls breakpoints set in a file
Chui Tey <chui.tey@advdata.com.au>
parents:
25894
diff
changeset
|
85 self.io.set_filename_change_hook(filename_changed_hook) |
|
18e09720738f
Recalls breakpoints set in a file
Chui Tey <chui.tey@advdata.com.au>
parents:
25894
diff
changeset
|
86 |
|
25894
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
87 rmenu_specs = [("Set Breakpoint", "<<set-breakpoint-here>>"), |
|
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
88 ("Clear Breakpoint", "<<clear-breakpoint-here>>")] |
| 13975 | 89 |
|
26025
18e09720738f
Recalls breakpoints set in a file
Chui Tey <chui.tey@advdata.com.au>
parents:
25894
diff
changeset
|
90 def set_breakpoint(self, lineno): |
|
18e09720738f
Recalls breakpoints set in a file
Chui Tey <chui.tey@advdata.com.au>
parents:
25894
diff
changeset
|
91 text = self.text |
|
18e09720738f
Recalls breakpoints set in a file
Chui Tey <chui.tey@advdata.com.au>
parents:
25894
diff
changeset
|
92 filename = self.io.filename |
|
18e09720738f
Recalls breakpoints set in a file
Chui Tey <chui.tey@advdata.com.au>
parents:
25894
diff
changeset
|
93 text.tag_add("BREAK", "%d.0" % lineno, "%d.0" % (lineno+1)) |
|
18e09720738f
Recalls breakpoints set in a file
Chui Tey <chui.tey@advdata.com.au>
parents:
25894
diff
changeset
|
94 try: |
|
18e09720738f
Recalls breakpoints set in a file
Chui Tey <chui.tey@advdata.com.au>
parents:
25894
diff
changeset
|
95 i = self.breakpoints.index(lineno) |
|
18e09720738f
Recalls breakpoints set in a file
Chui Tey <chui.tey@advdata.com.au>
parents:
25894
diff
changeset
|
96 except ValueError: # only add if missing, i.e. do once |
|
18e09720738f
Recalls breakpoints set in a file
Chui Tey <chui.tey@advdata.com.au>
parents:
25894
diff
changeset
|
97 self.breakpoints.append(lineno) |
|
18e09720738f
Recalls breakpoints set in a file
Chui Tey <chui.tey@advdata.com.au>
parents:
25894
diff
changeset
|
98 try: # update the subprocess debugger |
|
18e09720738f
Recalls breakpoints set in a file
Chui Tey <chui.tey@advdata.com.au>
parents:
25894
diff
changeset
|
99 debug = self.flist.pyshell.interp.debugger |
|
18e09720738f
Recalls breakpoints set in a file
Chui Tey <chui.tey@advdata.com.au>
parents:
25894
diff
changeset
|
100 debug.set_breakpoint_here(filename, lineno) |
|
18e09720738f
Recalls breakpoints set in a file
Chui Tey <chui.tey@advdata.com.au>
parents:
25894
diff
changeset
|
101 except: # but debugger may not be active right now.... |
|
18e09720738f
Recalls breakpoints set in a file
Chui Tey <chui.tey@advdata.com.au>
parents:
25894
diff
changeset
|
102 pass |
|
18e09720738f
Recalls breakpoints set in a file
Chui Tey <chui.tey@advdata.com.au>
parents:
25894
diff
changeset
|
103 |
| 13975 | 104 def set_breakpoint_here(self, event=None): |
|
25894
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
105 text = self.text |
|
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
106 filename = self.io.filename |
|
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
107 if not filename: |
|
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
108 text.bell() |
| 13975 | 109 return |
|
25894
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
110 lineno = int(float(text.index("insert"))) |
|
26025
18e09720738f
Recalls breakpoints set in a file
Chui Tey <chui.tey@advdata.com.au>
parents:
25894
diff
changeset
|
111 self.set_breakpoint(lineno) |
| 13975 | 112 |
|
23932
eab8eca9ec51
1. Debugger Breakpoints, finish implementation
Kurt B. Kaiser <kbk@shore.net>
parents:
23876
diff
changeset
|
113 def clear_breakpoint_here(self, event=None): |
|
25894
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
114 text = self.text |
|
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
115 filename = self.io.filename |
|
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
116 if not filename: |
|
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
117 text.bell() |
|
23932
eab8eca9ec51
1. Debugger Breakpoints, finish implementation
Kurt B. Kaiser <kbk@shore.net>
parents:
23876
diff
changeset
|
118 return |
|
25894
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
119 lineno = int(float(text.index("insert"))) |
|
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
120 try: |
|
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
121 self.breakpoints.remove(lineno) |
|
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
122 except: |
|
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
123 pass |
|
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
124 text.tag_remove("BREAK", "insert linestart",\ |
|
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
125 "insert lineend +1char") |
|
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
126 try: |
|
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
127 debug = self.flist.pyshell.interp.debugger |
|
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
128 debug.clear_breakpoint_here(filename, lineno) |
|
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
129 except: |
|
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
130 pass |
|
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
131 |
|
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
132 def clear_file_breaks(self): |
|
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
133 if self.breakpoints: |
|
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
134 text = self.text |
|
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
135 filename = self.io.filename |
|
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
136 if not filename: |
|
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
137 text.bell() |
|
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
138 return |
|
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
139 self.breakpoints = [] |
|
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
140 text.tag_remove("BREAK", "1.0", END) |
|
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
141 try: |
|
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
142 debug = self.flist.pyshell.interp.debugger |
|
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
143 debug.clear_file_breaks(filename) |
|
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
144 except: |
|
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
145 pass |
|
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
146 |
|
26025
18e09720738f
Recalls breakpoints set in a file
Chui Tey <chui.tey@advdata.com.au>
parents:
25894
diff
changeset
|
147 def store_file_breaks(self): |
| 26659 | 148 "Save breakpoints when file is saved" |
| 149 # XXX 13 Dec 2002 KBK Currently the file must be saved before it can | |
| 150 # be run. The breaks are saved at that time. If we introduce | |
| 151 # a temporary file save feature the save breaks functionality | |
| 152 # needs to be re-verified, since the breaks at the time the | |
| 153 # temp file is created may differ from the breaks at the last | |
| 154 # permanent save of the file. A break introduced after a save | |
| 155 # will be effective, but not persistent. This is necessary to | |
| 156 # keep the saved breaks synched with the saved file. | |
| 157 # | |
| 158 # Breakpoints are set as tagged ranges in the text. Certain | |
| 159 # kinds of edits cause these ranges to be deleted: Inserting | |
| 160 # or deleting a line just before a breakpoint, and certain | |
| 161 # deletions prior to a breakpoint. These issues need to be | |
| 162 # investigated and understood. It's not clear if they are | |
| 163 # Tk issues or IDLE issues, or whether they can actually | |
| 164 # be fixed. Since a modified file has to be saved before it is | |
| 165 # run, and since self.breakpoints (from which the subprocess | |
| 166 # debugger is loaded) is updated during the save, the visible | |
| 167 # breaks stay synched with the subprocess even if one of these | |
| 168 # unexpected breakpoint deletions occurs. | |
| 169 breaks = self.breakpoints | |
| 170 filename = self.io.filename | |
|
26025
18e09720738f
Recalls breakpoints set in a file
Chui Tey <chui.tey@advdata.com.au>
parents:
25894
diff
changeset
|
171 try: |
| 26659 | 172 lines = open(self.breakpointPath,"r").readlines() |
|
26025
18e09720738f
Recalls breakpoints set in a file
Chui Tey <chui.tey@advdata.com.au>
parents:
25894
diff
changeset
|
173 except IOError: |
| 26659 | 174 lines = [] |
| 175 new_file = open(self.breakpointPath,"w") | |
|
26025
18e09720738f
Recalls breakpoints set in a file
Chui Tey <chui.tey@advdata.com.au>
parents:
25894
diff
changeset
|
176 for line in lines: |
| 26659 | 177 if not line.startswith(filename + '='): |
|
26025
18e09720738f
Recalls breakpoints set in a file
Chui Tey <chui.tey@advdata.com.au>
parents:
25894
diff
changeset
|
178 new_file.write(line) |
| 26659 | 179 self.update_breakpoints() |
| 180 breaks = self.breakpoints | |
| 181 if breaks: | |
| 182 new_file.write(filename + '=' + str(breaks) + '\n') | |
|
26025
18e09720738f
Recalls breakpoints set in a file
Chui Tey <chui.tey@advdata.com.au>
parents:
25894
diff
changeset
|
183 new_file.close() |
|
18e09720738f
Recalls breakpoints set in a file
Chui Tey <chui.tey@advdata.com.au>
parents:
25894
diff
changeset
|
184 |
|
18e09720738f
Recalls breakpoints set in a file
Chui Tey <chui.tey@advdata.com.au>
parents:
25894
diff
changeset
|
185 def restore_file_breaks(self): |
|
18e09720738f
Recalls breakpoints set in a file
Chui Tey <chui.tey@advdata.com.au>
parents:
25894
diff
changeset
|
186 self.text.update() # this enables setting "BREAK" tags to be visible |
| 26659 | 187 filename = self.io.filename |
| 188 if filename is None: | |
| 189 return | |
|
26028
64a96b97e1e9
Set breakpoints on remote debugger
Chui Tey <chui.tey@advdata.com.au>
parents:
26025
diff
changeset
|
190 if os.path.isfile(self.breakpointPath): |
| 26659 | 191 lines = open(self.breakpointPath,"r").readlines() |
|
26028
64a96b97e1e9
Set breakpoints on remote debugger
Chui Tey <chui.tey@advdata.com.au>
parents:
26025
diff
changeset
|
192 for line in lines: |
| 26659 | 193 if line.startswith(filename + '='): |
| 194 breakpoint_linenumbers = eval(line[len(filename)+1:]) | |
|
26028
64a96b97e1e9
Set breakpoints on remote debugger
Chui Tey <chui.tey@advdata.com.au>
parents:
26025
diff
changeset
|
195 for breakpoint_linenumber in breakpoint_linenumbers: |
|
64a96b97e1e9
Set breakpoints on remote debugger
Chui Tey <chui.tey@advdata.com.au>
parents:
26025
diff
changeset
|
196 self.set_breakpoint(breakpoint_linenumber) |
|
26025
18e09720738f
Recalls breakpoints set in a file
Chui Tey <chui.tey@advdata.com.au>
parents:
25894
diff
changeset
|
197 |
| 26659 | 198 def update_breakpoints(self): |
| 199 "Retrieves all the breakpoints in the current window" | |
|
26025
18e09720738f
Recalls breakpoints set in a file
Chui Tey <chui.tey@advdata.com.au>
parents:
25894
diff
changeset
|
200 text = self.text |
| 26659 | 201 ranges = text.tag_ranges("BREAK") |
| 202 linenumber_list = self.ranges_to_linenumbers(ranges) | |
| 203 self.breakpoints = linenumber_list | |
| 204 | |
| 205 def ranges_to_linenumbers(self, ranges): | |
| 206 lines = [] | |
| 207 for index in range(0, len(ranges), 2): | |
| 208 lineno = int(float(ranges[index])) | |
| 209 end = int(float(ranges[index+1])) | |
| 210 while lineno < end: | |
| 211 lines.append(lineno) | |
| 212 lineno += 1 | |
| 213 return lines | |
| 214 | |
| 215 # XXX 13 Dec 2020 KBK Not used currently | |
| 216 # def saved_change_hook(self): | |
| 217 # "Extend base method - clear breaks if module is modified" | |
| 218 # if not self.get_saved(): | |
| 219 # self.clear_file_breaks() | |
| 220 # EditorWindow.saved_change_hook(self) | |
|
25894
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
221 |
|
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
222 def _close(self): |
|
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
223 "Extend base method - clear breaks when module is closed" |
|
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
224 self.clear_file_breaks() |
|
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
225 EditorWindow._close(self) |
|
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
226 |
| 13975 | 227 |
| 228 class PyShellFileList(FileList): | |
|
23969
edd7c0146ac8
Clear associated breakpoints when closing an edit window.
Kurt B. Kaiser <kbk@shore.net>
parents:
23932
diff
changeset
|
229 "Extend base class: file list when a shell is present" |
| 13975 | 230 |
| 231 EditorWindow = PyShellEditorWindow | |
| 232 | |
| 233 pyshell = None | |
| 234 | |
| 235 def open_shell(self, event=None): | |
| 236 if self.pyshell: | |
| 237 self.pyshell.wakeup() | |
| 238 else: | |
| 239 self.pyshell = PyShell(self) | |
| 240 self.pyshell.begin() | |
| 241 return self.pyshell | |
| 242 | |
| 243 | |
| 244 class ModifiedColorDelegator(ColorDelegator): | |
|
23969
edd7c0146ac8
Clear associated breakpoints when closing an edit window.
Kurt B. Kaiser <kbk@shore.net>
parents:
23932
diff
changeset
|
245 "Extend base class: colorizer for the shell window itself" |
|
22111
c494084dc6d8
First work on making config changes dynamic,
Steven M. Gava <elguavas@python.net>
parents:
21627
diff
changeset
|
246 |
|
c494084dc6d8
First work on making config changes dynamic,
Steven M. Gava <elguavas@python.net>
parents:
21627
diff
changeset
|
247 def __init__(self): |
|
c494084dc6d8
First work on making config changes dynamic,
Steven M. Gava <elguavas@python.net>
parents:
21627
diff
changeset
|
248 ColorDelegator.__init__(self) |
|
c494084dc6d8
First work on making config changes dynamic,
Steven M. Gava <elguavas@python.net>
parents:
21627
diff
changeset
|
249 self.LoadTagDefs() |
| 13975 | 250 |
| 251 def recolorize_main(self): | |
| 252 self.tag_remove("TODO", "1.0", "iomark") | |
| 253 self.tag_add("SYNC", "1.0", "iomark") | |
| 254 ColorDelegator.recolorize_main(self) | |
|
22111
c494084dc6d8
First work on making config changes dynamic,
Steven M. Gava <elguavas@python.net>
parents:
21627
diff
changeset
|
255 |
|
c494084dc6d8
First work on making config changes dynamic,
Steven M. Gava <elguavas@python.net>
parents:
21627
diff
changeset
|
256 def LoadTagDefs(self): |
|
c494084dc6d8
First work on making config changes dynamic,
Steven M. Gava <elguavas@python.net>
parents:
21627
diff
changeset
|
257 ColorDelegator.LoadTagDefs(self) |
|
c494084dc6d8
First work on making config changes dynamic,
Steven M. Gava <elguavas@python.net>
parents:
21627
diff
changeset
|
258 theme = idleConf.GetOption('main','Theme','name') |
|
c494084dc6d8
First work on making config changes dynamic,
Steven M. Gava <elguavas@python.net>
parents:
21627
diff
changeset
|
259 self.tagdefs.update({ |
|
c494084dc6d8
First work on making config changes dynamic,
Steven M. Gava <elguavas@python.net>
parents:
21627
diff
changeset
|
260 "stdin": {'background':None,'foreground':None}, |
|
c494084dc6d8
First work on making config changes dynamic,
Steven M. Gava <elguavas@python.net>
parents:
21627
diff
changeset
|
261 "stdout": idleConf.GetHighlight(theme, "stdout"), |
|
c494084dc6d8
First work on making config changes dynamic,
Steven M. Gava <elguavas@python.net>
parents:
21627
diff
changeset
|
262 "stderr": idleConf.GetHighlight(theme, "stderr"), |
|
c494084dc6d8
First work on making config changes dynamic,
Steven M. Gava <elguavas@python.net>
parents:
21627
diff
changeset
|
263 "console": idleConf.GetHighlight(theme, "console"), |
|
c494084dc6d8
First work on making config changes dynamic,
Steven M. Gava <elguavas@python.net>
parents:
21627
diff
changeset
|
264 "ERROR": idleConf.GetHighlight(theme, "error"), |
|
c494084dc6d8
First work on making config changes dynamic,
Steven M. Gava <elguavas@python.net>
parents:
21627
diff
changeset
|
265 None: idleConf.GetHighlight(theme, "normal"), |
|
c494084dc6d8
First work on making config changes dynamic,
Steven M. Gava <elguavas@python.net>
parents:
21627
diff
changeset
|
266 }) |
| 13975 | 267 |
| 268 class ModifiedUndoDelegator(UndoDelegator): | |
|
23969
edd7c0146ac8
Clear associated breakpoints when closing an edit window.
Kurt B. Kaiser <kbk@shore.net>
parents:
23932
diff
changeset
|
269 "Extend base class: forbid insert/delete before the I/O mark" |
| 13975 | 270 |
| 271 def insert(self, index, chars, tags=None): | |
| 272 try: | |
| 273 if self.delegate.compare(index, "<", "iomark"): | |
| 274 self.delegate.bell() | |
| 275 return | |
| 276 except TclError: | |
| 277 pass | |
| 278 UndoDelegator.insert(self, index, chars, tags) | |
| 279 | |
| 280 def delete(self, index1, index2=None): | |
| 281 try: | |
| 282 if self.delegate.compare(index1, "<", "iomark"): | |
| 283 self.delegate.bell() | |
| 284 return | |
| 285 except TclError: | |
| 286 pass | |
| 287 UndoDelegator.delete(self, index1, index2) | |
| 288 | |
| 289 class ModifiedInterpreter(InteractiveInterpreter): | |
| 290 | |
| 291 def __init__(self, tkconsole): | |
| 292 self.tkconsole = tkconsole | |
| 293 locals = sys.modules['__main__'].__dict__ | |
| 294 InteractiveInterpreter.__init__(self, locals=locals) | |
|
18560
12e7ad108229
cvs-py-rel2_1 (Rev 1.29 - 1.33) merge
Kurt B. Kaiser <kbk@shore.net>
parents:
13975
diff
changeset
|
295 self.save_warnings_filters = None |
| 13975 | 296 |
| 25123 | 297 port = 8833 |
| 23547 | 298 rpcclt = None |
| 299 rpcpid = None | |
| 300 | |
|
25480
9d50bc831bca
Finding a suitable interpreter to spawn needed tweaking on the Mac
Tony Lownds <tony@lownds.com>
parents:
25346
diff
changeset
|
301 def spawn_subprocess(self): |
|
9d50bc831bca
Finding a suitable interpreter to spawn needed tweaking on the Mac
Tony Lownds <tony@lownds.com>
parents:
25346
diff
changeset
|
302 w = ['-W' + s for s in sys.warnoptions] |
|
9d50bc831bca
Finding a suitable interpreter to spawn needed tweaking on the Mac
Tony Lownds <tony@lownds.com>
parents:
25346
diff
changeset
|
303 args = [self.find_executable()] + w \ |
|
9d50bc831bca
Finding a suitable interpreter to spawn needed tweaking on the Mac
Tony Lownds <tony@lownds.com>
parents:
25346
diff
changeset
|
304 + ["-c", "__import__('run').main()", str(self.port)] |
| 23547 | 305 self.rpcpid = os.spawnv(os.P_NOWAIT, args[0], args) |
| 25123 | 306 |
|
25480
9d50bc831bca
Finding a suitable interpreter to spawn needed tweaking on the Mac
Tony Lownds <tony@lownds.com>
parents:
25346
diff
changeset
|
307 def find_executable(self): |
|
9d50bc831bca
Finding a suitable interpreter to spawn needed tweaking on the Mac
Tony Lownds <tony@lownds.com>
parents:
25346
diff
changeset
|
308 if sys.platform == 'darwin' and sys.executable.count('.app'): |
|
9d50bc831bca
Finding a suitable interpreter to spawn needed tweaking on the Mac
Tony Lownds <tony@lownds.com>
parents:
25346
diff
changeset
|
309 # On Mac OS X, avoid calling sys.executable because it ignores |
|
9d50bc831bca
Finding a suitable interpreter to spawn needed tweaking on the Mac
Tony Lownds <tony@lownds.com>
parents:
25346
diff
changeset
|
310 # command-line options (sys.executable is an applet) |
|
9d50bc831bca
Finding a suitable interpreter to spawn needed tweaking on the Mac
Tony Lownds <tony@lownds.com>
parents:
25346
diff
changeset
|
311 # |
|
9d50bc831bca
Finding a suitable interpreter to spawn needed tweaking on the Mac
Tony Lownds <tony@lownds.com>
parents:
25346
diff
changeset
|
312 # Instead, find the executable by looking relative to |
|
9d50bc831bca
Finding a suitable interpreter to spawn needed tweaking on the Mac
Tony Lownds <tony@lownds.com>
parents:
25346
diff
changeset
|
313 # sys.prefix. |
|
9d50bc831bca
Finding a suitable interpreter to spawn needed tweaking on the Mac
Tony Lownds <tony@lownds.com>
parents:
25346
diff
changeset
|
314 executable = os.path.join(sys.prefix, 'Resources', |
|
25894
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
315 'Python.app', 'Contents', |
|
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
316 'MacOS', 'python') |
|
25480
9d50bc831bca
Finding a suitable interpreter to spawn needed tweaking on the Mac
Tony Lownds <tony@lownds.com>
parents:
25346
diff
changeset
|
317 return executable |
|
9d50bc831bca
Finding a suitable interpreter to spawn needed tweaking on the Mac
Tony Lownds <tony@lownds.com>
parents:
25346
diff
changeset
|
318 else: |
|
9d50bc831bca
Finding a suitable interpreter to spawn needed tweaking on the Mac
Tony Lownds <tony@lownds.com>
parents:
25346
diff
changeset
|
319 return sys.executable |
|
9d50bc831bca
Finding a suitable interpreter to spawn needed tweaking on the Mac
Tony Lownds <tony@lownds.com>
parents:
25346
diff
changeset
|
320 |
| 25123 | 321 def start_subprocess(self): |
| 322 addr = ("localhost", self.port) | |
| 323 self.spawn_subprocess() | |
|
24559
f059d5435d65
GvR provided solution to the socket rebinding timeout problem.
Kurt B. Kaiser <kbk@shore.net>
parents:
24386
diff
changeset
|
324 # Idle starts listening for connection on localhost |
|
f059d5435d65
GvR provided solution to the socket rebinding timeout problem.
Kurt B. Kaiser <kbk@shore.net>
parents:
24386
diff
changeset
|
325 for i in range(6): |
| 23547 | 326 time.sleep(i) |
| 327 try: | |
| 328 self.rpcclt = rpc.RPCClient(addr) | |
| 329 break | |
| 330 except socket.error, err: | |
|
24559
f059d5435d65
GvR provided solution to the socket rebinding timeout problem.
Kurt B. Kaiser <kbk@shore.net>
parents:
24386
diff
changeset
|
331 if i < 3: |
|
24386
0e27b67247da
Reverse the RPC socket connection: Python execution server connects to
Kurt B. Kaiser <kbk@shore.net>
parents:
24183
diff
changeset
|
332 print>>sys.__stderr__, ". ", |
|
0e27b67247da
Reverse the RPC socket connection: Python execution server connects to
Kurt B. Kaiser <kbk@shore.net>
parents:
24183
diff
changeset
|
333 else: |
|
0e27b67247da
Reverse the RPC socket connection: Python execution server connects to
Kurt B. Kaiser <kbk@shore.net>
parents:
24183
diff
changeset
|
334 print>>sys.__stderr__,"\nIdle socket error: " + err[1]\ |
|
0e27b67247da
Reverse the RPC socket connection: Python execution server connects to
Kurt B. Kaiser <kbk@shore.net>
parents:
24183
diff
changeset
|
335 + ", retrying..." |
| 23547 | 336 else: |
|
23784
24b0f6d693e3
Rework the code to have only the GvR RPC. Output from execution of user
Kurt B. Kaiser <kbk@shore.net>
parents:
23547
diff
changeset
|
337 display_port_binding_error() |
| 23547 | 338 return |
|
24386
0e27b67247da
Reverse the RPC socket connection: Python execution server connects to
Kurt B. Kaiser <kbk@shore.net>
parents:
24183
diff
changeset
|
339 # Accept the connection from the Python execution server |
|
0e27b67247da
Reverse the RPC socket connection: Python execution server connects to
Kurt B. Kaiser <kbk@shore.net>
parents:
24183
diff
changeset
|
340 self.rpcclt.accept() |
|
23784
24b0f6d693e3
Rework the code to have only the GvR RPC. Output from execution of user
Kurt B. Kaiser <kbk@shore.net>
parents:
23547
diff
changeset
|
341 self.rpcclt.register("stdin", self.tkconsole) |
|
24b0f6d693e3
Rework the code to have only the GvR RPC. Output from execution of user
Kurt B. Kaiser <kbk@shore.net>
parents:
23547
diff
changeset
|
342 self.rpcclt.register("stdout", self.tkconsole.stdout) |
|
24b0f6d693e3
Rework the code to have only the GvR RPC. Output from execution of user
Kurt B. Kaiser <kbk@shore.net>
parents:
23547
diff
changeset
|
343 self.rpcclt.register("stderr", self.tkconsole.stderr) |
| 23547 | 344 self.rpcclt.register("flist", self.tkconsole.flist) |
|
26590
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
345 self.transfer_path() |
| 23547 | 346 self.poll_subprocess() |
| 347 | |
| 25123 | 348 def restart_subprocess(self): |
| 349 # close only the subprocess debugger | |
|
25894
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
350 debug = self.getdebugger() |
|
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
351 if debug: |
| 25123 | 352 RemoteDebugger.close_subprocess_debugger(self.rpcclt) |
| 353 # kill subprocess, spawn a new one, accept connection | |
| 354 self.rpcclt.close() | |
| 355 self.spawn_subprocess() | |
| 356 self.rpcclt.accept() | |
|
26590
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
357 self.transfer_path() |
| 25123 | 358 # restart remote debugger |
|
25894
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
359 if debug: |
| 25123 | 360 gui = RemoteDebugger.restart_subprocess_debugger(self.rpcclt) |
|
25894
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
361 # reload remote debugger breakpoints for all PyShellEditWindows |
|
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
362 debug.load_breakpoints() |
|
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
363 |
|
26590
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
364 def transfer_path(self): |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
365 self.runcommand("""if 1: |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
366 import sys as _sys |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
367 _sys.path = %s |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
368 del _sys |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
369 \n""" % `sys.path`) |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
370 |
| 23547 | 371 active_seq = None |
| 372 | |
| 373 def poll_subprocess(self): | |
| 374 clt = self.rpcclt | |
| 375 if clt is None: | |
| 376 return | |
| 377 response = clt.pollresponse(self.active_seq) | |
| 26557 | 378 # Reschedule myself in 50 ms |
| 23547 | 379 self.tkconsole.text.after(50, self.poll_subprocess) |
| 380 if response: | |
| 381 self.tkconsole.resetoutput() | |
| 382 self.active_seq = None | |
| 383 how, what = response | |
| 384 file = self.tkconsole.console | |
| 385 if how == "OK": | |
| 386 if what is not None: | |
| 387 print >>file, `what` | |
| 388 elif how == "EXCEPTION": | |
| 389 mod, name, args, tb = what | |
| 390 print >>file, 'Traceback (most recent call last):' | |
| 391 while tb and tb[0][0] in ("run.py", "rpc.py"): | |
| 392 del tb[0] | |
| 393 while tb and tb[-1][0] in ("run.py", "rpc.py"): | |
| 394 del tb[-1] | |
| 395 for i in range(len(tb)): | |
| 396 fn, ln, nm, line = tb[i] | |
| 397 if not line and fn.startswith("<pyshell#"): | |
| 398 line = linecache.getline(fn, ln) | |
| 399 tb[i] = fn, ln, nm, line | |
| 400 traceback.print_list(tb, file=file) | |
| 26557 | 401 # try to reinstantiate the exception, stuff in the args: |
| 402 try: | |
| 403 etype = eval(mod + '.' + name) | |
| 404 val = etype() | |
| 405 val.args = args | |
| 406 except TypeError: # string exception! | |
| 407 etype = name | |
| 408 val = args | |
| 409 lines = traceback.format_exception_only(etype, val) | |
| 410 for line in lines[:-1]: | |
| 411 traceback._print(file, line, '') | |
| 412 traceback._print(file, lines[-1], '') | |
| 23547 | 413 if self.tkconsole.getvar("<<toggle-jit-stack-viewer>>"): |
| 414 self.remote_stack_viewer() | |
| 415 elif how == "ERROR": | |
| 26557 | 416 errmsg = "PyShell.ModifiedInterpreter: Subprocess ERROR:\n" |
| 417 print >>sys.__stderr__, errmsg, what | |
| 418 print >>file, errmsg, what | |
| 23547 | 419 self.tkconsole.endexecuting() |
| 420 | |
| 421 def kill_subprocess(self): | |
| 422 clt = self.rpcclt | |
| 423 self.rpcclt = None | |
| 424 if clt is not None: | |
| 425 clt.close() | |
| 426 | |
|
25894
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
427 debugger = None |
|
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
428 |
|
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
429 def setdebugger(self, debugger): |
|
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
430 self.debugger = debugger |
|
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
431 |
|
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
432 def getdebugger(self): |
|
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
433 return self.debugger |
|
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
434 |
| 23547 | 435 def remote_stack_viewer(self): |
| 436 import RemoteObjectBrowser | |
| 437 oid = self.rpcclt.remotecall("exec", "stackviewer", ("flist",), {}) | |
| 438 if oid is None: | |
| 439 self.tkconsole.root.bell() | |
| 440 return | |
| 441 item = RemoteObjectBrowser.StubObjectTreeItem(self.rpcclt, oid) | |
| 442 from TreeWidget import ScrolledCanvas, TreeNode | |
| 443 top = Toplevel(self.tkconsole.root) | |
| 444 sc = ScrolledCanvas(top, bg="white", highlightthickness=0) | |
| 445 sc.frame.pack(expand=1, fill="both") | |
| 446 node = TreeNode(sc.canvas, None, item) | |
| 447 node.expand() | |
| 448 # XXX Should GC the remote tree when closing the window | |
| 449 | |
| 13975 | 450 gid = 0 |
| 451 | |
| 452 def execsource(self, source): | |
|
23969
edd7c0146ac8
Clear associated breakpoints when closing an edit window.
Kurt B. Kaiser <kbk@shore.net>
parents:
23932
diff
changeset
|
453 "Like runsource() but assumes complete exec source" |
| 13975 | 454 filename = self.stuffsource(source) |
| 455 self.execfile(filename, source) | |
| 456 | |
| 457 def execfile(self, filename, source=None): | |
|
23969
edd7c0146ac8
Clear associated breakpoints when closing an edit window.
Kurt B. Kaiser <kbk@shore.net>
parents:
23932
diff
changeset
|
458 "Execute an existing file" |
| 13975 | 459 if source is None: |
| 460 source = open(filename, "r").read() | |
| 461 try: | |
| 462 code = compile(source, filename, "exec") | |
| 463 except (OverflowError, SyntaxError): | |
| 464 self.tkconsole.resetoutput() | |
| 26557 | 465 console = self.tkconsole.console |
| 466 print >>console, 'Traceback (most recent call last):' | |
| 13975 | 467 InteractiveInterpreter.showsyntaxerror(self, filename) |
| 26468 | 468 self.tkconsole.showprompt() |
| 13975 | 469 else: |
| 470 self.runcode(code) | |
| 471 | |
| 472 def runsource(self, source): | |
|
23969
edd7c0146ac8
Clear associated breakpoints when closing an edit window.
Kurt B. Kaiser <kbk@shore.net>
parents:
23932
diff
changeset
|
473 "Extend base class method: Stuff the source in the line cache first" |
| 13975 | 474 filename = self.stuffsource(source) |
| 475 self.more = 0 | |
|
18560
12e7ad108229
cvs-py-rel2_1 (Rev 1.29 - 1.33) merge
Kurt B. Kaiser <kbk@shore.net>
parents:
13975
diff
changeset
|
476 self.save_warnings_filters = warnings.filters[:] |
|
12e7ad108229
cvs-py-rel2_1 (Rev 1.29 - 1.33) merge
Kurt B. Kaiser <kbk@shore.net>
parents:
13975
diff
changeset
|
477 warnings.filterwarnings(action="error", category=SyntaxWarning) |
| 25310 | 478 if isinstance(source, types.UnicodeType): |
| 479 import IOBinding | |
| 480 try: | |
| 481 source = source.encode(IOBinding.encoding) | |
| 482 except UnicodeError: | |
| 483 self.tkconsole.resetoutput() | |
| 484 self.write("Unsupported characters in input") | |
| 485 return | |
|
18560
12e7ad108229
cvs-py-rel2_1 (Rev 1.29 - 1.33) merge
Kurt B. Kaiser <kbk@shore.net>
parents:
13975
diff
changeset
|
486 try: |
|
12e7ad108229
cvs-py-rel2_1 (Rev 1.29 - 1.33) merge
Kurt B. Kaiser <kbk@shore.net>
parents:
13975
diff
changeset
|
487 return InteractiveInterpreter.runsource(self, source, filename) |
|
12e7ad108229
cvs-py-rel2_1 (Rev 1.29 - 1.33) merge
Kurt B. Kaiser <kbk@shore.net>
parents:
13975
diff
changeset
|
488 finally: |
|
12e7ad108229
cvs-py-rel2_1 (Rev 1.29 - 1.33) merge
Kurt B. Kaiser <kbk@shore.net>
parents:
13975
diff
changeset
|
489 if self.save_warnings_filters is not None: |
|
12e7ad108229
cvs-py-rel2_1 (Rev 1.29 - 1.33) merge
Kurt B. Kaiser <kbk@shore.net>
parents:
13975
diff
changeset
|
490 warnings.filters[:] = self.save_warnings_filters |
|
12e7ad108229
cvs-py-rel2_1 (Rev 1.29 - 1.33) merge
Kurt B. Kaiser <kbk@shore.net>
parents:
13975
diff
changeset
|
491 self.save_warnings_filters = None |
| 13975 | 492 |
| 493 def stuffsource(self, source): | |
|
23969
edd7c0146ac8
Clear associated breakpoints when closing an edit window.
Kurt B. Kaiser <kbk@shore.net>
parents:
23932
diff
changeset
|
494 "Stuff source in the filename cache" |
| 13975 | 495 filename = "<pyshell#%d>" % self.gid |
| 496 self.gid = self.gid + 1 | |
| 25310 | 497 lines = source.split("\n") |
| 13975 | 498 linecache.cache[filename] = len(source)+1, 0, lines, filename |
| 499 return filename | |
| 25310 | 500 |
| 13975 | 501 def showsyntaxerror(self, filename=None): |
|
23969
edd7c0146ac8
Clear associated breakpoints when closing an edit window.
Kurt B. Kaiser <kbk@shore.net>
parents:
23932
diff
changeset
|
502 """Extend base class method: Add Colorizing |
|
edd7c0146ac8
Clear associated breakpoints when closing an edit window.
Kurt B. Kaiser <kbk@shore.net>
parents:
23932
diff
changeset
|
503 |
|
edd7c0146ac8
Clear associated breakpoints when closing an edit window.
Kurt B. Kaiser <kbk@shore.net>
parents:
23932
diff
changeset
|
504 Color the offending position instead of printing it and pointing at it |
|
edd7c0146ac8
Clear associated breakpoints when closing an edit window.
Kurt B. Kaiser <kbk@shore.net>
parents:
23932
diff
changeset
|
505 with a caret. |
|
edd7c0146ac8
Clear associated breakpoints when closing an edit window.
Kurt B. Kaiser <kbk@shore.net>
parents:
23932
diff
changeset
|
506 |
|
edd7c0146ac8
Clear associated breakpoints when closing an edit window.
Kurt B. Kaiser <kbk@shore.net>
parents:
23932
diff
changeset
|
507 """ |
| 13975 | 508 text = self.tkconsole.text |
| 509 stuff = self.unpackerror() | |
| 26468 | 510 if stuff: |
| 511 msg, lineno, offset, line = stuff | |
| 512 if lineno == 1: | |
| 513 pos = "iomark + %d chars" % (offset-1) | |
| 514 else: | |
| 515 pos = "iomark linestart + %d lines + %d chars" % \ | |
| 516 (lineno-1, offset-1) | |
| 517 text.tag_add("ERROR", pos) | |
| 518 text.see(pos) | |
| 519 char = text.get(pos) | |
| 520 if char and char in IDENTCHARS: | |
| 521 text.tag_add("ERROR", pos + " wordstart", pos) | |
| 522 self.tkconsole.resetoutput() | |
| 523 self.write("SyntaxError: %s\n" % str(msg)) | |
| 524 else: | |
| 13975 | 525 self.tkconsole.resetoutput() |
| 526 InteractiveInterpreter.showsyntaxerror(self, filename) | |
| 26468 | 527 self.tkconsole.showprompt() |
| 13975 | 528 |
| 529 def unpackerror(self): | |
| 530 type, value, tb = sys.exc_info() | |
| 531 ok = type is SyntaxError | |
| 532 if ok: | |
| 533 try: | |
| 534 msg, (dummy_filename, lineno, offset, line) = value | |
| 535 except: | |
| 536 ok = 0 | |
| 537 if ok: | |
| 538 return msg, lineno, offset, line | |
| 539 else: | |
| 540 return None | |
| 541 | |
| 542 def showtraceback(self): | |
|
23969
edd7c0146ac8
Clear associated breakpoints when closing an edit window.
Kurt B. Kaiser <kbk@shore.net>
parents:
23932
diff
changeset
|
543 "Extend base class method to reset output properly" |
| 13975 | 544 self.tkconsole.resetoutput() |
| 545 self.checklinecache() | |
| 546 InteractiveInterpreter.showtraceback(self) | |
| 23547 | 547 if self.tkconsole.getvar("<<toggle-jit-stack-viewer>>"): |
| 548 self.tkconsole.open_stack_viewer() | |
| 13975 | 549 |
| 550 def checklinecache(self): | |
| 551 c = linecache.cache | |
| 552 for key in c.keys(): | |
| 553 if key[:1] + key[-1:] != "<>": | |
| 554 del c[key] | |
| 555 | |
| 25123 | 556 def display_executing_dialog(self): |
| 557 tkMessageBox.showerror( | |
| 558 "Already executing", | |
| 559 "The Python Shell window is already executing a command; " | |
| 560 "please wait until it is finished.", | |
| 561 master=self.tkconsole.text) | |
| 562 | |
| 23547 | 563 def runcommand(self, code): |
|
23969
edd7c0146ac8
Clear associated breakpoints when closing an edit window.
Kurt B. Kaiser <kbk@shore.net>
parents:
23932
diff
changeset
|
564 "Run the code without invoking the debugger" |
| 23547 | 565 # The code better not raise an exception! |
| 566 if self.tkconsole.executing: | |
|
26471
99c78cf95610
Add missing self for method call
Neal Norwitz <nnorwitz@gmail.com>
parents:
26468
diff
changeset
|
567 self.display_executing_dialog() |
| 23547 | 568 return 0 |
| 569 if self.rpcclt: | |
| 570 self.rpcclt.remotecall("exec", "runcode", (code,), {}) | |
| 571 else: | |
| 572 exec code in self.locals | |
| 573 return 1 | |
| 574 | |
| 13975 | 575 def runcode(self, code): |
|
23969
edd7c0146ac8
Clear associated breakpoints when closing an edit window.
Kurt B. Kaiser <kbk@shore.net>
parents:
23932
diff
changeset
|
576 "Override base class method" |
| 23547 | 577 if self.tkconsole.executing: |
|
26471
99c78cf95610
Add missing self for method call
Neal Norwitz <nnorwitz@gmail.com>
parents:
26468
diff
changeset
|
578 self.display_executing_dialog() |
| 23547 | 579 return |
| 580 self.checklinecache() | |
|
18560
12e7ad108229
cvs-py-rel2_1 (Rev 1.29 - 1.33) merge
Kurt B. Kaiser <kbk@shore.net>
parents:
13975
diff
changeset
|
581 if self.save_warnings_filters is not None: |
|
12e7ad108229
cvs-py-rel2_1 (Rev 1.29 - 1.33) merge
Kurt B. Kaiser <kbk@shore.net>
parents:
13975
diff
changeset
|
582 warnings.filters[:] = self.save_warnings_filters |
|
12e7ad108229
cvs-py-rel2_1 (Rev 1.29 - 1.33) merge
Kurt B. Kaiser <kbk@shore.net>
parents:
13975
diff
changeset
|
583 self.save_warnings_filters = None |
| 13975 | 584 debugger = self.debugger |
| 23547 | 585 if not debugger and self.rpcclt is not None: |
| 586 self.tkconsole.beginexecuting() | |
| 587 self.active_seq = self.rpcclt.asynccall("exec", "runcode", | |
| 588 (code,), {}) | |
| 589 return | |
| 13975 | 590 try: |
| 591 self.tkconsole.beginexecuting() | |
| 592 try: | |
| 593 if debugger: | |
| 594 debugger.run(code, self.locals) | |
| 595 else: | |
| 596 exec code in self.locals | |
| 597 except SystemExit: | |
| 598 if tkMessageBox.askyesno( | |
| 599 "Exit?", | |
| 600 "Do you want to exit altogether?", | |
| 601 default="yes", | |
| 602 master=self.tkconsole.text): | |
| 603 raise | |
| 604 else: | |
| 605 self.showtraceback() | |
| 606 except: | |
| 607 self.showtraceback() | |
| 608 finally: | |
| 609 self.tkconsole.endexecuting() | |
| 610 | |
| 611 def write(self, s): | |
|
23969
edd7c0146ac8
Clear associated breakpoints when closing an edit window.
Kurt B. Kaiser <kbk@shore.net>
parents:
23932
diff
changeset
|
612 "Override base class method" |
| 13975 | 613 self.tkconsole.console.write(s) |
| 614 | |
| 615 class PyShell(OutputWindow): | |
| 616 | |
| 617 shell_title = "Python Shell" | |
| 618 | |
| 619 # Override classes | |
| 620 ColorDelegator = ModifiedColorDelegator | |
| 621 UndoDelegator = ModifiedUndoDelegator | |
| 622 | |
|
26590
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
623 # Override menus |
|
24183
1723bcdc1e85
1. Prevent Undo before IOmark in PyShell.PyShell
Kurt B. Kaiser <kbk@shore.net>
parents:
23995
diff
changeset
|
624 menu_specs = [ |
|
1723bcdc1e85
1. Prevent Undo before IOmark in PyShell.PyShell
Kurt B. Kaiser <kbk@shore.net>
parents:
23995
diff
changeset
|
625 ("file", "_File"), |
|
1723bcdc1e85
1. Prevent Undo before IOmark in PyShell.PyShell
Kurt B. Kaiser <kbk@shore.net>
parents:
23995
diff
changeset
|
626 ("edit", "_Edit"), |
|
1723bcdc1e85
1. Prevent Undo before IOmark in PyShell.PyShell
Kurt B. Kaiser <kbk@shore.net>
parents:
23995
diff
changeset
|
627 ("debug", "_Debug"), |
|
1723bcdc1e85
1. Prevent Undo before IOmark in PyShell.PyShell
Kurt B. Kaiser <kbk@shore.net>
parents:
23995
diff
changeset
|
628 ("settings", "_Settings"), |
|
1723bcdc1e85
1. Prevent Undo before IOmark in PyShell.PyShell
Kurt B. Kaiser <kbk@shore.net>
parents:
23995
diff
changeset
|
629 ("windows", "_Windows"), |
|
1723bcdc1e85
1. Prevent Undo before IOmark in PyShell.PyShell
Kurt B. Kaiser <kbk@shore.net>
parents:
23995
diff
changeset
|
630 ("help", "_Help"), |
|
1723bcdc1e85
1. Prevent Undo before IOmark in PyShell.PyShell
Kurt B. Kaiser <kbk@shore.net>
parents:
23995
diff
changeset
|
631 ] |
| 13975 | 632 |
| 633 # New classes | |
| 634 from IdleHistory import History | |
| 635 | |
| 636 def __init__(self, flist=None): | |
| 637 self.interp = ModifiedInterpreter(self) | |
| 638 if flist is None: | |
| 639 root = Tk() | |
| 640 fixwordbreaks(root) | |
| 641 root.withdraw() | |
| 642 flist = PyShellFileList(root) | |
|
25691
b39bd03a8dab
M CallTips.py Add support for getting calltip from subprocess,
Kurt B. Kaiser <kbk@shore.net>
parents:
25480
diff
changeset
|
643 # |
| 13975 | 644 OutputWindow.__init__(self, flist, None, None) |
|
25691
b39bd03a8dab
M CallTips.py Add support for getting calltip from subprocess,
Kurt B. Kaiser <kbk@shore.net>
parents:
25480
diff
changeset
|
645 # |
| 13975 | 646 import __builtin__ |
| 647 __builtin__.quit = __builtin__.exit = "To exit, type Ctrl-D." | |
|
25691
b39bd03a8dab
M CallTips.py Add support for getting calltip from subprocess,
Kurt B. Kaiser <kbk@shore.net>
parents:
25480
diff
changeset
|
648 # |
|
25261
4b6185128814
MERGE DS_RPC_BRANCH into MAIN
Kurt B. Kaiser <kbk@shore.net>
parents:
25123
diff
changeset
|
649 self.config(usetabs=1, indentwidth=8, context_use_ps1=1) |
|
25691
b39bd03a8dab
M CallTips.py Add support for getting calltip from subprocess,
Kurt B. Kaiser <kbk@shore.net>
parents:
25480
diff
changeset
|
650 # |
| 13975 | 651 text = self.text |
| 652 text.configure(wrap="char") | |
| 653 text.bind("<<newline-and-indent>>", self.enter_callback) | |
| 654 text.bind("<<plain-newline-and-indent>>", self.linefeed_callback) | |
| 655 text.bind("<<interrupt-execution>>", self.cancel_callback) | |
| 656 text.bind("<<beginning-of-line>>", self.home_callback) | |
| 657 text.bind("<<end-of-file>>", self.eof_callback) | |
| 658 text.bind("<<open-stack-viewer>>", self.open_stack_viewer) | |
| 659 text.bind("<<toggle-debugger>>", self.toggle_debugger) | |
| 660 text.bind("<<open-python-shell>>", self.flist.open_shell) | |
| 661 text.bind("<<toggle-jit-stack-viewer>>", self.toggle_jit_stack_viewer) | |
|
25691
b39bd03a8dab
M CallTips.py Add support for getting calltip from subprocess,
Kurt B. Kaiser <kbk@shore.net>
parents:
25480
diff
changeset
|
662 # |
| 13975 | 663 self.save_stdout = sys.stdout |
| 664 self.save_stderr = sys.stderr | |
| 665 self.save_stdin = sys.stdin | |
| 23547 | 666 self.stdout = PseudoFile(self, "stdout") |
| 667 self.stderr = PseudoFile(self, "stderr") | |
| 13975 | 668 self.console = PseudoFile(self, "console") |
| 23547 | 669 if not use_subprocess: |
| 670 sys.stdout = self.stdout | |
| 671 sys.stderr = self.stderr | |
| 672 sys.stdin = self | |
|
25691
b39bd03a8dab
M CallTips.py Add support for getting calltip from subprocess,
Kurt B. Kaiser <kbk@shore.net>
parents:
25480
diff
changeset
|
673 # |
| 13975 | 674 self.history = self.History(self.text) |
|
25691
b39bd03a8dab
M CallTips.py Add support for getting calltip from subprocess,
Kurt B. Kaiser <kbk@shore.net>
parents:
25480
diff
changeset
|
675 # |
| 23547 | 676 if use_subprocess: |
| 25123 | 677 self.interp.start_subprocess() |
| 23547 | 678 |
| 13975 | 679 reading = 0 |
| 680 executing = 0 | |
| 681 canceled = 0 | |
| 682 endoffile = 0 | |
| 683 | |
| 684 def toggle_debugger(self, event=None): | |
| 685 if self.executing: | |
| 686 tkMessageBox.showerror("Don't debug now", | |
| 687 "You can only toggle the debugger when idle", | |
| 688 master=self.text) | |
| 689 self.set_debugger_indicator() | |
| 690 return "break" | |
| 691 else: | |
| 692 db = self.interp.getdebugger() | |
| 693 if db: | |
| 694 self.close_debugger() | |
| 695 else: | |
| 696 self.open_debugger() | |
| 697 | |
| 698 def set_debugger_indicator(self): | |
| 699 db = self.interp.getdebugger() | |
| 700 self.setvar("<<toggle-debugger>>", not not db) | |
| 701 | |
| 702 def toggle_jit_stack_viewer( self, event=None): | |
| 703 pass # All we need is the variable | |
| 704 | |
| 705 def close_debugger(self): | |
| 706 db = self.interp.getdebugger() | |
| 707 if db: | |
| 708 self.interp.setdebugger(None) | |
| 709 db.close() | |
|
23995
41468f9353ce
Shutdown subprocess debugger and associated Proxies/Adapters when closing
Kurt B. Kaiser <kbk@shore.net>
parents:
23969
diff
changeset
|
710 if self.interp.rpcclt: |
|
41468f9353ce
Shutdown subprocess debugger and associated Proxies/Adapters when closing
Kurt B. Kaiser <kbk@shore.net>
parents:
23969
diff
changeset
|
711 RemoteDebugger.close_remote_debugger(self.interp.rpcclt) |
| 13975 | 712 self.resetoutput() |
| 713 self.console.write("[DEBUG OFF]\n") | |
| 714 sys.ps1 = ">>> " | |
| 715 self.showprompt() | |
| 716 self.set_debugger_indicator() | |
| 717 | |
| 718 def open_debugger(self): | |
|
23876
832f0501148b
Polish RemoteDebugger code.
Kurt B. Kaiser <kbk@shore.net>
parents:
23784
diff
changeset
|
719 # XXX KBK 13Jun02 An RPC client always exists now? Open remote |
|
832f0501148b
Polish RemoteDebugger code.
Kurt B. Kaiser <kbk@shore.net>
parents:
23784
diff
changeset
|
720 # debugger and return...dike the rest of this fcn and combine |
|
832f0501148b
Polish RemoteDebugger code.
Kurt B. Kaiser <kbk@shore.net>
parents:
23784
diff
changeset
|
721 # with open_remote_debugger? |
| 23547 | 722 if self.interp.rpcclt: |
| 723 return self.open_remote_debugger() | |
| 13975 | 724 import Debugger |
| 725 self.interp.setdebugger(Debugger.Debugger(self)) | |
| 726 sys.ps1 = "[DEBUG ON]\n>>> " | |
| 727 self.showprompt() | |
| 728 self.set_debugger_indicator() | |
| 729 | |
| 23547 | 730 def open_remote_debugger(self): |
| 731 gui = RemoteDebugger.start_remote_debugger(self.interp.rpcclt, self) | |
| 732 self.interp.setdebugger(gui) | |
|
25894
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
733 # Load all PyShellEditorWindow breakpoints: |
|
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
734 gui.load_breakpoints() |
| 23547 | 735 sys.ps1 = "[DEBUG ON]\n>>> " |
| 736 self.showprompt() | |
| 737 self.set_debugger_indicator() | |
| 738 | |
| 13975 | 739 def beginexecuting(self): |
|
23995
41468f9353ce
Shutdown subprocess debugger and associated Proxies/Adapters when closing
Kurt B. Kaiser <kbk@shore.net>
parents:
23969
diff
changeset
|
740 "Helper for ModifiedInterpreter" |
| 13975 | 741 self.resetoutput() |
| 742 self.executing = 1 | |
| 743 ##self._cancel_check = self.cancel_check | |
| 744 ##sys.settrace(self._cancel_check) | |
| 745 | |
| 746 def endexecuting(self): | |
|
23969
edd7c0146ac8
Clear associated breakpoints when closing an edit window.
Kurt B. Kaiser <kbk@shore.net>
parents:
23932
diff
changeset
|
747 "Helper for ModifiedInterpreter" |
| 13975 | 748 ##sys.settrace(None) |
| 749 ##self._cancel_check = None | |
| 750 self.executing = 0 | |
| 751 self.canceled = 0 | |
| 23547 | 752 self.showprompt() |
| 13975 | 753 |
| 754 def close(self): | |
|
23969
edd7c0146ac8
Clear associated breakpoints when closing an edit window.
Kurt B. Kaiser <kbk@shore.net>
parents:
23932
diff
changeset
|
755 "Extend EditorWindow.close()" |
| 13975 | 756 if self.executing: |
| 757 # XXX Need to ask a question here | |
| 758 if not tkMessageBox.askokcancel( | |
| 759 "Kill?", | |
| 760 "The program is still running; do you want to kill it?", | |
| 761 default="ok", | |
| 762 master=self.text): | |
| 763 return "cancel" | |
| 764 self.canceled = 1 | |
| 765 if self.reading: | |
| 766 self.top.quit() | |
| 767 return "cancel" | |
|
23969
edd7c0146ac8
Clear associated breakpoints when closing an edit window.
Kurt B. Kaiser <kbk@shore.net>
parents:
23932
diff
changeset
|
768 return EditorWindow.close(self) |
| 13975 | 769 |
| 770 def _close(self): | |
|
23969
edd7c0146ac8
Clear associated breakpoints when closing an edit window.
Kurt B. Kaiser <kbk@shore.net>
parents:
23932
diff
changeset
|
771 "Extend EditorWindow._close(), shut down debugger and execution server" |
| 13975 | 772 self.close_debugger() |
| 23547 | 773 self.interp.kill_subprocess() |
| 13975 | 774 # Restore std streams |
| 775 sys.stdout = self.save_stdout | |
| 776 sys.stderr = self.save_stderr | |
| 777 sys.stdin = self.save_stdin | |
| 778 # Break cycles | |
| 779 self.interp = None | |
| 780 self.console = None | |
| 781 self.flist.pyshell = None | |
| 782 self.history = None | |
|
23969
edd7c0146ac8
Clear associated breakpoints when closing an edit window.
Kurt B. Kaiser <kbk@shore.net>
parents:
23932
diff
changeset
|
783 EditorWindow._close(self) |
| 13975 | 784 |
| 785 def ispythonsource(self, filename): | |
|
23969
edd7c0146ac8
Clear associated breakpoints when closing an edit window.
Kurt B. Kaiser <kbk@shore.net>
parents:
23932
diff
changeset
|
786 "Override EditorWindow method: never remove the colorizer" |
| 25310 | 787 return True |
| 13975 | 788 |
| 789 def short_title(self): | |
| 790 return self.shell_title | |
| 791 | |
|
18560
12e7ad108229
cvs-py-rel2_1 (Rev 1.29 - 1.33) merge
Kurt B. Kaiser <kbk@shore.net>
parents:
13975
diff
changeset
|
792 COPYRIGHT = \ |
|
12e7ad108229
cvs-py-rel2_1 (Rev 1.29 - 1.33) merge
Kurt B. Kaiser <kbk@shore.net>
parents:
13975
diff
changeset
|
793 'Type "copyright", "credits" or "license" for more information.' |
|
12e7ad108229
cvs-py-rel2_1 (Rev 1.29 - 1.33) merge
Kurt B. Kaiser <kbk@shore.net>
parents:
13975
diff
changeset
|
794 |
| 13975 | 795 def begin(self): |
| 796 self.resetoutput() | |
|
23784
24b0f6d693e3
Rework the code to have only the GvR RPC. Output from execution of user
Kurt B. Kaiser <kbk@shore.net>
parents:
23547
diff
changeset
|
797 self.write("Python %s on %s\n%s\nGRPC IDLE Fork %s\n" % |
|
18560
12e7ad108229
cvs-py-rel2_1 (Rev 1.29 - 1.33) merge
Kurt B. Kaiser <kbk@shore.net>
parents:
13975
diff
changeset
|
798 (sys.version, sys.platform, self.COPYRIGHT, |
| 13975 | 799 idlever.IDLE_VERSION)) |
| 800 try: | |
| 801 sys.ps1 | |
| 802 except AttributeError: | |
| 803 sys.ps1 = ">>> " | |
| 804 self.showprompt() | |
| 805 import Tkinter | |
| 806 Tkinter._default_root = None | |
| 807 | |
| 808 def interact(self): | |
| 809 self.begin() | |
| 810 self.top.mainloop() | |
| 811 | |
| 812 def readline(self): | |
| 813 save = self.reading | |
| 814 try: | |
| 815 self.reading = 1 | |
| 816 self.top.mainloop() | |
| 817 finally: | |
| 818 self.reading = save | |
| 819 line = self.text.get("iomark", "end-1c") | |
| 820 self.resetoutput() | |
| 821 if self.canceled: | |
| 822 self.canceled = 0 | |
| 823 raise KeyboardInterrupt | |
| 824 if self.endoffile: | |
| 825 self.endoffile = 0 | |
| 826 return "" | |
| 827 return line | |
| 828 | |
| 829 def isatty(self): | |
| 25310 | 830 return True |
| 13975 | 831 |
| 832 def cancel_callback(self, event): | |
| 833 try: | |
| 834 if self.text.compare("sel.first", "!=", "sel.last"): | |
| 835 return # Active selection -- always use default binding | |
| 836 except: | |
| 837 pass | |
| 838 if not (self.executing or self.reading): | |
| 839 self.resetoutput() | |
| 840 self.write("KeyboardInterrupt\n") | |
| 841 self.showprompt() | |
| 842 return "break" | |
| 843 self.endoffile = 0 | |
| 844 if self.reading: | |
| 23547 | 845 self.canceled = 1 |
| 13975 | 846 self.top.quit() |
| 23547 | 847 elif (self.executing and self.interp.rpcclt and |
| 848 self.interp.rpcpid and hasattr(os, "kill")): | |
| 849 try: | |
| 850 from signal import SIGINT | |
| 851 except ImportError: | |
| 852 SIGINT = 2 | |
| 853 os.kill(self.interp.rpcpid, SIGINT) | |
| 854 else: | |
| 855 self.canceled = 1 | |
| 13975 | 856 return "break" |
| 857 | |
| 858 def eof_callback(self, event): | |
| 859 if self.executing and not self.reading: | |
| 860 return # Let the default binding (delete next char) take over | |
| 861 if not (self.text.compare("iomark", "==", "insert") and | |
| 862 self.text.compare("insert", "==", "end-1c")): | |
| 863 return # Let the default binding (delete next char) take over | |
| 864 if not self.executing: | |
| 865 self.resetoutput() | |
| 866 self.close() | |
| 867 else: | |
| 868 self.canceled = 0 | |
| 869 self.endoffile = 1 | |
| 870 self.top.quit() | |
| 871 return "break" | |
| 872 | |
| 873 def home_callback(self, event): | |
| 874 if event.state != 0 and event.keysym == "Home": | |
| 875 return # <Modifier-Home>; fall back to class binding | |
| 876 if self.text.compare("iomark", "<=", "insert") and \ | |
| 877 self.text.compare("insert linestart", "<=", "iomark"): | |
| 878 self.text.mark_set("insert", "iomark") | |
| 879 self.text.tag_remove("sel", "1.0", "end") | |
| 880 self.text.see("insert") | |
| 881 return "break" | |
| 882 | |
| 883 def linefeed_callback(self, event): | |
| 884 # Insert a linefeed without entering anything (still autoindented) | |
| 885 if self.reading: | |
| 886 self.text.insert("insert", "\n") | |
| 887 self.text.see("insert") | |
| 888 else: | |
|
25261
4b6185128814
MERGE DS_RPC_BRANCH into MAIN
Kurt B. Kaiser <kbk@shore.net>
parents:
25123
diff
changeset
|
889 self.auto_indent(event) |
| 13975 | 890 return "break" |
| 891 | |
| 892 def enter_callback(self, event): | |
| 893 if self.executing and not self.reading: | |
| 894 return # Let the default binding (insert '\n') take over | |
| 895 # If some text is selected, recall the selection | |
| 896 # (but only if this before the I/O mark) | |
| 897 try: | |
| 898 sel = self.text.get("sel.first", "sel.last") | |
| 899 if sel: | |
| 900 if self.text.compare("sel.last", "<=", "iomark"): | |
| 901 self.recall(sel) | |
| 902 return "break" | |
| 903 except: | |
| 904 pass | |
| 905 # If we're strictly before the line containing iomark, recall | |
| 906 # the current line, less a leading prompt, less leading or | |
| 907 # trailing whitespace | |
| 908 if self.text.compare("insert", "<", "iomark linestart"): | |
| 909 # Check if there's a relevant stdin range -- if so, use it | |
| 910 prev = self.text.tag_prevrange("stdin", "insert") | |
| 911 if prev and self.text.compare("insert", "<", prev[1]): | |
| 912 self.recall(self.text.get(prev[0], prev[1])) | |
| 913 return "break" | |
| 914 next = self.text.tag_nextrange("stdin", "insert") | |
| 915 if next and self.text.compare("insert lineend", ">=", next[0]): | |
| 916 self.recall(self.text.get(next[0], next[1])) | |
| 917 return "break" | |
| 918 # No stdin mark -- just get the current line | |
| 919 self.recall(self.text.get("insert linestart", "insert lineend")) | |
| 920 return "break" | |
| 921 # If we're in the current input and there's only whitespace | |
| 922 # beyond the cursor, erase that whitespace first | |
| 923 s = self.text.get("insert", "end-1c") | |
| 25310 | 924 if s and not s.strip(): |
| 13975 | 925 self.text.delete("insert", "end-1c") |
| 926 # If we're in the current input before its last line, | |
| 927 # insert a newline right at the insert point | |
| 928 if self.text.compare("insert", "<", "end-1c linestart"): | |
|
25261
4b6185128814
MERGE DS_RPC_BRANCH into MAIN
Kurt B. Kaiser <kbk@shore.net>
parents:
25123
diff
changeset
|
929 self.auto_indent(event) |
| 13975 | 930 return "break" |
| 931 # We're in the last line; append a newline and submit it | |
| 932 self.text.mark_set("insert", "end-1c") | |
| 933 if self.reading: | |
| 934 self.text.insert("insert", "\n") | |
| 935 self.text.see("insert") | |
| 936 else: | |
|
25261
4b6185128814
MERGE DS_RPC_BRANCH into MAIN
Kurt B. Kaiser <kbk@shore.net>
parents:
25123
diff
changeset
|
937 self.auto_indent(event) |
| 13975 | 938 self.text.tag_add("stdin", "iomark", "end-1c") |
| 939 self.text.update_idletasks() | |
| 940 if self.reading: | |
| 941 self.top.quit() # Break out of recursive mainloop() in raw_input() | |
| 942 else: | |
| 943 self.runit() | |
| 944 return "break" | |
| 945 | |
| 946 def recall(self, s): | |
| 947 if self.history: | |
| 948 self.history.recall(s) | |
| 949 | |
| 950 def runit(self): | |
| 951 line = self.text.get("iomark", "end-1c") | |
| 952 # Strip off last newline and surrounding whitespace. | |
| 953 # (To allow you to hit return twice to end a statement.) | |
| 954 i = len(line) | |
| 955 while i > 0 and line[i-1] in " \t": | |
| 956 i = i-1 | |
| 957 if i > 0 and line[i-1] == "\n": | |
| 958 i = i-1 | |
| 959 while i > 0 and line[i-1] in " \t": | |
| 960 i = i-1 | |
| 961 line = line[:i] | |
| 962 more = self.interp.runsource(line) | |
| 963 | |
| 964 def cancel_check(self, frame, what, args, | |
| 965 dooneevent=tkinter.dooneevent, | |
| 966 dontwait=tkinter.DONT_WAIT): | |
| 967 # Hack -- use the debugger hooks to be able to handle events | |
| 968 # and interrupt execution at any time. | |
| 969 # This slows execution down quite a bit, so you may want to | |
| 970 # disable this (by not calling settrace() in runcode() above) | |
| 971 # for full-bore (uninterruptable) speed. | |
| 972 # XXX This should become a user option. | |
| 973 if self.canceled: | |
| 974 return | |
| 975 dooneevent(dontwait) | |
| 976 if self.canceled: | |
| 977 self.canceled = 0 | |
| 978 raise KeyboardInterrupt | |
| 979 return self._cancel_check | |
| 980 | |
| 981 def open_stack_viewer(self, event=None): | |
| 23547 | 982 if self.interp.rpcclt: |
| 983 return self.interp.remote_stack_viewer() | |
| 13975 | 984 try: |
| 985 sys.last_traceback | |
| 986 except: | |
| 987 tkMessageBox.showerror("No stack trace", | |
| 988 "There is no stack trace yet.\n" | |
| 989 "(sys.last_traceback is not defined)", | |
| 990 master=self.text) | |
| 991 return | |
| 992 from StackViewer import StackBrowser | |
| 993 sv = StackBrowser(self.root, self.flist) | |
| 994 | |
| 995 def showprompt(self): | |
| 996 self.resetoutput() | |
| 997 try: | |
| 998 s = str(sys.ps1) | |
| 999 except: | |
| 1000 s = "" | |
| 1001 self.console.write(s) | |
| 1002 self.text.mark_set("insert", "end-1c") | |
| 23547 | 1003 self.set_line_and_column() |
|
24183
1723bcdc1e85
1. Prevent Undo before IOmark in PyShell.PyShell
Kurt B. Kaiser <kbk@shore.net>
parents:
23995
diff
changeset
|
1004 self.io.reset_undo() |
| 13975 | 1005 |
| 1006 def resetoutput(self): | |
| 1007 source = self.text.get("iomark", "end-1c") | |
| 1008 if self.history: | |
| 1009 self.history.history_store(source) | |
| 1010 if self.text.get("end-2c") != "\n": | |
| 1011 self.text.insert("end-1c", "\n") | |
| 1012 self.text.mark_set("iomark", "end-1c") | |
| 23547 | 1013 self.set_line_and_column() |
| 13975 | 1014 sys.stdout.softspace = 0 |
| 1015 | |
| 1016 def write(self, s, tags=()): | |
| 1017 self.text.mark_gravity("iomark", "right") | |
| 1018 OutputWindow.write(self, s, tags, "iomark") | |
| 1019 self.text.mark_gravity("iomark", "left") | |
| 1020 if self.canceled: | |
| 1021 self.canceled = 0 | |
| 1022 raise KeyboardInterrupt | |
| 1023 | |
| 1024 class PseudoFile: | |
| 1025 | |
| 1026 def __init__(self, shell, tags): | |
| 1027 self.shell = shell | |
| 1028 self.tags = tags | |
| 23547 | 1029 self.softspace = 0 |
| 13975 | 1030 |
| 1031 def write(self, s): | |
| 1032 self.shell.write(s, self.tags) | |
| 1033 | |
| 1034 def writelines(self, l): | |
| 1035 map(self.write, l) | |
| 1036 | |
| 1037 def flush(self): | |
| 1038 pass | |
| 1039 | |
| 1040 def isatty(self): | |
| 25310 | 1041 return True |
| 13975 | 1042 |
|
23784
24b0f6d693e3
Rework the code to have only the GvR RPC. Output from execution of user
Kurt B. Kaiser <kbk@shore.net>
parents:
23547
diff
changeset
|
1043 |
| 13975 | 1044 usage_msg = """\ |
|
26590
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1045 |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1046 USAGE: idle [-deis] [-t title] [file]* |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1047 idle [-ds] [-t title] (-c cmd | -r file) [arg]* |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1048 idle [-ds] [-t title] - [arg]* |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1049 |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1050 -h print this help message and exit |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1051 |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1052 The following options will override the IDLE 'settings' configuration: |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1053 |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1054 -e open an edit window |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1055 -i open a shell window |
|
18649
8aa63aea7269
Implement idle command interface as suggested by GvR [idle-dev] 16 July
Kurt B. Kaiser <kbk@shore.net>
parents:
18614
diff
changeset
|
1056 |
|
26590
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1057 The following options imply -i and will open a shell: |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1058 |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1059 -c cmd run the command in a shell, or |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1060 -r file run script from file |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1061 |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1062 -d enable the debugger |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1063 -s run $IDLESTARTUP or $PYTHONSTARTUP before anything else |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1064 -t title set title of shell window |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1065 |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1066 A default edit window will be bypassed when -c, -r, or - are used. |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1067 |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1068 [arg]* are passed to the command (-c) or script (-r) in sys.argv[1:]. |
| 13975 | 1069 |
|
26590
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1070 Examples: |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1071 |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1072 idle |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1073 Open an edit window or shell depending on IDLE's configuration. |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1074 |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1075 idle foo.py foobar.py |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1076 Edit the files, also open a shell if configured to start with shell. |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1077 |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1078 idle -est "Baz" foo.py |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1079 Run $IDLESTARTUP or $PYTHONSTARTUP, edit foo.py, and open a shell |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1080 window with the title "Baz". |
| 13975 | 1081 |
|
26590
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1082 idle -c "import sys; print sys.argv" "foo" |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1083 Open a shell window and run the command, passing "-c" in sys.argv[0] |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1084 and "foo" in sys.argv[1]. |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1085 |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1086 idle -d -s -r foo.py "Hello World" |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1087 Open a shell window, run a startup script, enable the debugger, and |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1088 run foo.py, passing "foo.py" in sys.argv[0] and "Hello World" in |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1089 sys.argv[1]. |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1090 |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1091 echo "import sys; print sys.argv" | idle - "foobar" |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1092 Open a shell window, run the script piped in, passing '' in sys.argv[0] |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1093 and "foobar" in sys.argv[1]. |
| 13975 | 1094 """ |
| 1095 | |
|
23784
24b0f6d693e3
Rework the code to have only the GvR RPC. Output from execution of user
Kurt B. Kaiser <kbk@shore.net>
parents:
23547
diff
changeset
|
1096 def main(): |
|
26590
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1097 global flist, root, use_subprocess |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1098 |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1099 enable_shell = False |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1100 enable_edit = False |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1101 debug = False |
|
23784
24b0f6d693e3
Rework the code to have only the GvR RPC. Output from execution of user
Kurt B. Kaiser <kbk@shore.net>
parents:
23547
diff
changeset
|
1102 cmd = None |
|
24b0f6d693e3
Rework the code to have only the GvR RPC. Output from execution of user
Kurt B. Kaiser <kbk@shore.net>
parents:
23547
diff
changeset
|
1103 script = None |
|
26590
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1104 startup = False |
|
23784
24b0f6d693e3
Rework the code to have only the GvR RPC. Output from execution of user
Kurt B. Kaiser <kbk@shore.net>
parents:
23547
diff
changeset
|
1105 try: |
|
26590
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1106 opts, args = getopt.getopt(sys.argv[1:], "c:deihr:st:") |
|
23784
24b0f6d693e3
Rework the code to have only the GvR RPC. Output from execution of user
Kurt B. Kaiser <kbk@shore.net>
parents:
23547
diff
changeset
|
1107 except getopt.error, msg: |
|
24b0f6d693e3
Rework the code to have only the GvR RPC. Output from execution of user
Kurt B. Kaiser <kbk@shore.net>
parents:
23547
diff
changeset
|
1108 sys.stderr.write("Error: %s\n" % str(msg)) |
|
24b0f6d693e3
Rework the code to have only the GvR RPC. Output from execution of user
Kurt B. Kaiser <kbk@shore.net>
parents:
23547
diff
changeset
|
1109 sys.stderr.write(usage_msg) |
|
24b0f6d693e3
Rework the code to have only the GvR RPC. Output from execution of user
Kurt B. Kaiser <kbk@shore.net>
parents:
23547
diff
changeset
|
1110 sys.exit(2) |
|
24b0f6d693e3
Rework the code to have only the GvR RPC. Output from execution of user
Kurt B. Kaiser <kbk@shore.net>
parents:
23547
diff
changeset
|
1111 for o, a in opts: |
|
24b0f6d693e3
Rework the code to have only the GvR RPC. Output from execution of user
Kurt B. Kaiser <kbk@shore.net>
parents:
23547
diff
changeset
|
1112 if o == '-c': |
|
24b0f6d693e3
Rework the code to have only the GvR RPC. Output from execution of user
Kurt B. Kaiser <kbk@shore.net>
parents:
23547
diff
changeset
|
1113 cmd = a |
|
26590
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1114 enable_shell = True |
|
23784
24b0f6d693e3
Rework the code to have only the GvR RPC. Output from execution of user
Kurt B. Kaiser <kbk@shore.net>
parents:
23547
diff
changeset
|
1115 if o == '-d': |
|
26590
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1116 debug = True |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1117 enable_shell = True |
|
23784
24b0f6d693e3
Rework the code to have only the GvR RPC. Output from execution of user
Kurt B. Kaiser <kbk@shore.net>
parents:
23547
diff
changeset
|
1118 if o == '-e': |
|
26590
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1119 enable_edit = True |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1120 if o == '-h': |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1121 sys.stdout.write(usage_msg) |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1122 sys.exit() |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1123 if o == '-i': |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1124 enable_shell = True |
|
23784
24b0f6d693e3
Rework the code to have only the GvR RPC. Output from execution of user
Kurt B. Kaiser <kbk@shore.net>
parents:
23547
diff
changeset
|
1125 if o == '-r': |
|
24b0f6d693e3
Rework the code to have only the GvR RPC. Output from execution of user
Kurt B. Kaiser <kbk@shore.net>
parents:
23547
diff
changeset
|
1126 script = a |
|
26590
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1127 if os.path.isfile(script): |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1128 pass |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1129 else: |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1130 print "No script file: ", script |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1131 sys.exit() |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1132 enable_shell = True |
|
23784
24b0f6d693e3
Rework the code to have only the GvR RPC. Output from execution of user
Kurt B. Kaiser <kbk@shore.net>
parents:
23547
diff
changeset
|
1133 if o == '-s': |
|
26590
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1134 startup = True |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1135 enable_shell = True |
|
23784
24b0f6d693e3
Rework the code to have only the GvR RPC. Output from execution of user
Kurt B. Kaiser <kbk@shore.net>
parents:
23547
diff
changeset
|
1136 if o == '-t': |
|
24b0f6d693e3
Rework the code to have only the GvR RPC. Output from execution of user
Kurt B. Kaiser <kbk@shore.net>
parents:
23547
diff
changeset
|
1137 PyShell.shell_title = a |
|
26590
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1138 enable_shell = True |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1139 if args and args[0] == '-': |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1140 cmd = sys.stdin.read() |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1141 enable_shell = True |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1142 |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1143 use_subprocess = True |
|
23784
24b0f6d693e3
Rework the code to have only the GvR RPC. Output from execution of user
Kurt B. Kaiser <kbk@shore.net>
parents:
23547
diff
changeset
|
1144 |
|
26590
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1145 # process sys.argv and sys.path: |
|
23784
24b0f6d693e3
Rework the code to have only the GvR RPC. Output from execution of user
Kurt B. Kaiser <kbk@shore.net>
parents:
23547
diff
changeset
|
1146 for i in range(len(sys.path)): |
|
24b0f6d693e3
Rework the code to have only the GvR RPC. Output from execution of user
Kurt B. Kaiser <kbk@shore.net>
parents:
23547
diff
changeset
|
1147 sys.path[i] = os.path.abspath(sys.path[i]) |
|
26590
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1148 if args and args[0] == '-': |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1149 sys.argv = [''] + args[1:] |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1150 elif cmd: |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1151 sys.argv = ['-c'] + args |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1152 elif script: |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1153 sys.argv = [script] + args |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1154 elif args: |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1155 enable_edit = True |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1156 pathx = [] |
|
23784
24b0f6d693e3
Rework the code to have only the GvR RPC. Output from execution of user
Kurt B. Kaiser <kbk@shore.net>
parents:
23547
diff
changeset
|
1157 for filename in args: |
|
24b0f6d693e3
Rework the code to have only the GvR RPC. Output from execution of user
Kurt B. Kaiser <kbk@shore.net>
parents:
23547
diff
changeset
|
1158 pathx.append(os.path.dirname(filename)) |
|
26590
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1159 for dir in pathx: |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1160 dir = os.path.abspath(dir) |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1161 if not dir in sys.path: |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1162 sys.path.insert(0, dir) |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1163 # check the IDLE settings configuration (but command line overrides) |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1164 edit_start = idleConf.GetOption('main', 'General', |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1165 'editor-on-startup', type='bool') |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1166 enable_edit = enable_edit or edit_start |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1167 enable_shell = enable_shell or not edit_start |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1168 # start editor and/or shell windows: |
|
23784
24b0f6d693e3
Rework the code to have only the GvR RPC. Output from execution of user
Kurt B. Kaiser <kbk@shore.net>
parents:
23547
diff
changeset
|
1169 root = Tk(className="Idle") |
|
24b0f6d693e3
Rework the code to have only the GvR RPC. Output from execution of user
Kurt B. Kaiser <kbk@shore.net>
parents:
23547
diff
changeset
|
1170 fixwordbreaks(root) |
|
24b0f6d693e3
Rework the code to have only the GvR RPC. Output from execution of user
Kurt B. Kaiser <kbk@shore.net>
parents:
23547
diff
changeset
|
1171 root.withdraw() |
|
24b0f6d693e3
Rework the code to have only the GvR RPC. Output from execution of user
Kurt B. Kaiser <kbk@shore.net>
parents:
23547
diff
changeset
|
1172 flist = PyShellFileList(root) |
|
26590
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1173 if enable_edit: |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1174 if not (cmd or script): |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1175 for filename in args: |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1176 flist.open(filename) |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1177 if not args: |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1178 flist.new() |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1179 if enable_shell: |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1180 flist.open_shell() |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1181 elif enable_shell: |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1182 flist.pyshell = PyShell(flist) |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1183 flist.pyshell.begin() |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1184 shell = flist.pyshell |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1185 # handle remaining options: |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1186 if debug: |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1187 shell.open_debugger() |
|
23784
24b0f6d693e3
Rework the code to have only the GvR RPC. Output from execution of user
Kurt B. Kaiser <kbk@shore.net>
parents:
23547
diff
changeset
|
1188 if startup: |
|
24b0f6d693e3
Rework the code to have only the GvR RPC. Output from execution of user
Kurt B. Kaiser <kbk@shore.net>
parents:
23547
diff
changeset
|
1189 filename = os.environ.get("IDLESTARTUP") or \ |
|
24b0f6d693e3
Rework the code to have only the GvR RPC. Output from execution of user
Kurt B. Kaiser <kbk@shore.net>
parents:
23547
diff
changeset
|
1190 os.environ.get("PYTHONSTARTUP") |
|
24b0f6d693e3
Rework the code to have only the GvR RPC. Output from execution of user
Kurt B. Kaiser <kbk@shore.net>
parents:
23547
diff
changeset
|
1191 if filename and os.path.isfile(filename): |
|
26590
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1192 shell.interp.execfile(filename) |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1193 if cmd or script: |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1194 shell.interp.runcommand("""if 1: |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1195 import sys as _sys |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1196 _sys.argv = %s |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1197 del _sys |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1198 \n""" % `sys.argv`) |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1199 if cmd: |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1200 shell.interp.execsource(cmd) |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1201 elif script: |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1202 shell.interp.execfile(script) |
|
23784
24b0f6d693e3
Rework the code to have only the GvR RPC. Output from execution of user
Kurt B. Kaiser <kbk@shore.net>
parents:
23547
diff
changeset
|
1203 root.mainloop() |
|
24b0f6d693e3
Rework the code to have only the GvR RPC. Output from execution of user
Kurt B. Kaiser <kbk@shore.net>
parents:
23547
diff
changeset
|
1204 root.destroy() |
|
24b0f6d693e3
Rework the code to have only the GvR RPC. Output from execution of user
Kurt B. Kaiser <kbk@shore.net>
parents:
23547
diff
changeset
|
1205 |
|
26590
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1206 |
|
23784
24b0f6d693e3
Rework the code to have only the GvR RPC. Output from execution of user
Kurt B. Kaiser <kbk@shore.net>
parents:
23547
diff
changeset
|
1207 def display_port_binding_error(): |
|
24b0f6d693e3
Rework the code to have only the GvR RPC. Output from execution of user
Kurt B. Kaiser <kbk@shore.net>
parents:
23547
diff
changeset
|
1208 print """\ |
|
20306
1ca228e21a98
merged port binding error message patch
Steven M. Gava <elguavas@python.net>
parents:
18649
diff
changeset
|
1209 IDLE cannot run. |
|
1ca228e21a98
merged port binding error message patch
Steven M. Gava <elguavas@python.net>
parents:
18649
diff
changeset
|
1210 |
|
23784
24b0f6d693e3
Rework the code to have only the GvR RPC. Output from execution of user
Kurt B. Kaiser <kbk@shore.net>
parents:
23547
diff
changeset
|
1211 IDLE needs to use a specific TCP/IP port (8833) in order to execute and |
|
20306
1ca228e21a98
merged port binding error message patch
Steven M. Gava <elguavas@python.net>
parents:
18649
diff
changeset
|
1212 debug programs. IDLE is unable to bind to this port, and so cannot |
|
1ca228e21a98
merged port binding error message patch
Steven M. Gava <elguavas@python.net>
parents:
18649
diff
changeset
|
1213 start. Here are some possible causes of this problem: |
|
1ca228e21a98
merged port binding error message patch
Steven M. Gava <elguavas@python.net>
parents:
18649
diff
changeset
|
1214 |
|
1ca228e21a98
merged port binding error message patch
Steven M. Gava <elguavas@python.net>
parents:
18649
diff
changeset
|
1215 1. TCP/IP networking is not installed or not working on this computer |
|
1ca228e21a98
merged port binding error message patch
Steven M. Gava <elguavas@python.net>
parents:
18649
diff
changeset
|
1216 2. Another program is running that uses this port |
|
23784
24b0f6d693e3
Rework the code to have only the GvR RPC. Output from execution of user
Kurt B. Kaiser <kbk@shore.net>
parents:
23547
diff
changeset
|
1217 3. Personal firewall software is preventing IDLE from using this port |
|
20306
1ca228e21a98
merged port binding error message patch
Steven M. Gava <elguavas@python.net>
parents:
18649
diff
changeset
|
1218 |
|
1ca228e21a98
merged port binding error message patch
Steven M. Gava <elguavas@python.net>
parents:
18649
diff
changeset
|
1219 IDLE makes and accepts connections only with this computer, and does not |
|
23784
24b0f6d693e3
Rework the code to have only the GvR RPC. Output from execution of user
Kurt B. Kaiser <kbk@shore.net>
parents:
23547
diff
changeset
|
1220 communicate over the internet in any way. Its use of port 8833 should not |
|
20306
1ca228e21a98
merged port binding error message patch
Steven M. Gava <elguavas@python.net>
parents:
18649
diff
changeset
|
1221 be a security risk on a single-user machine. |
|
1ca228e21a98
merged port binding error message patch
Steven M. Gava <elguavas@python.net>
parents:
18649
diff
changeset
|
1222 """ |
| 13975 | 1223 |
| 1224 if __name__ == "__main__": | |
| 1225 main() |
