Mercurial > cpython-lru_cache-weakref
annotate Lib/idlelib/PyShell.py @ 26730:9b4c014b3a21 legacy-trunk
Update way a subprocess is launched for Mac OS X.
Another applet mechanism has been developed for Python on Mac OS X and
trying to use the -c "__import__('run').main()" trick is just not working.
macosx_main.py is a new file which should be used as the startup file for
Mac OS X applet bundles. This startup file understands a -p option, which
when seen will start run.main(). When running as an applet, this seems like
the best approach.
| author | Tony Lownds <tony@lownds.com> |
|---|---|
| date | Fri, 20 Dec 2002 04:24:43 +0000 |
| parents | 975333d40bf8 |
| children | 72cf089d634a |
| 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 None: idleConf.GetHighlight(theme, "normal"), |
|
c494084dc6d8
First work on making config changes dynamic,
Steven M. Gava <elguavas@python.net>
parents:
21627
diff
changeset
|
265 }) |
| 13975 | 266 |
| 267 class ModifiedUndoDelegator(UndoDelegator): | |
|
23969
edd7c0146ac8
Clear associated breakpoints when closing an edit window.
Kurt B. Kaiser <kbk@shore.net>
parents:
23932
diff
changeset
|
268 "Extend base class: forbid insert/delete before the I/O mark" |
| 13975 | 269 |
| 270 def insert(self, index, chars, tags=None): | |
| 271 try: | |
| 272 if self.delegate.compare(index, "<", "iomark"): | |
| 273 self.delegate.bell() | |
| 274 return | |
| 275 except TclError: | |
| 276 pass | |
| 277 UndoDelegator.insert(self, index, chars, tags) | |
| 278 | |
| 279 def delete(self, index1, index2=None): | |
| 280 try: | |
| 281 if self.delegate.compare(index1, "<", "iomark"): | |
| 282 self.delegate.bell() | |
| 283 return | |
| 284 except TclError: | |
| 285 pass | |
| 286 UndoDelegator.delete(self, index1, index2) | |
| 287 | |
| 288 class ModifiedInterpreter(InteractiveInterpreter): | |
| 289 | |
| 290 def __init__(self, tkconsole): | |
| 291 self.tkconsole = tkconsole | |
| 292 locals = sys.modules['__main__'].__dict__ | |
| 293 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
|
294 self.save_warnings_filters = None |
| 13975 | 295 |
| 25123 | 296 port = 8833 |
| 23547 | 297 rpcclt = None |
| 298 rpcpid = None | |
| 299 | |
|
25480
9d50bc831bca
Finding a suitable interpreter to spawn needed tweaking on the Mac
Tony Lownds <tony@lownds.com>
parents:
25346
diff
changeset
|
300 def spawn_subprocess(self): |
|
26730
9b4c014b3a21
Update way a subprocess is launched for Mac OS X.
Tony Lownds <tony@lownds.com>
parents:
26693
diff
changeset
|
301 args = self.build_subprocess_arglist() |
| 23547 | 302 self.rpcpid = os.spawnv(os.P_NOWAIT, args[0], args) |
| 25123 | 303 |
|
26730
9b4c014b3a21
Update way a subprocess is launched for Mac OS X.
Tony Lownds <tony@lownds.com>
parents:
26693
diff
changeset
|
304 def build_subprocess_arglist(self): |
|
9b4c014b3a21
Update way a subprocess is launched for Mac OS X.
Tony Lownds <tony@lownds.com>
parents:
26693
diff
changeset
|
305 if sys.platform == 'darwin' and sys.argv[0].count('.app'): |
|
9b4c014b3a21
Update way a subprocess is launched for Mac OS X.
Tony Lownds <tony@lownds.com>
parents:
26693
diff
changeset
|
306 # We need to avoid using sys.executable because it fails on some |
|
9b4c014b3a21
Update way a subprocess is launched for Mac OS X.
Tony Lownds <tony@lownds.com>
parents:
26693
diff
changeset
|
307 # of the applet architectures On Mac OS X. |
|
9b4c014b3a21
Update way a subprocess is launched for Mac OS X.
Tony Lownds <tony@lownds.com>
parents:
26693
diff
changeset
|
308 # |
|
9b4c014b3a21
Update way a subprocess is launched for Mac OS X.
Tony Lownds <tony@lownds.com>
parents:
26693
diff
changeset
|
309 # here are the applet architectures tried: |
|
25480
9d50bc831bca
Finding a suitable interpreter to spawn needed tweaking on the Mac
Tony Lownds <tony@lownds.com>
parents:
25346
diff
changeset
|
310 # |
|
26730
9b4c014b3a21
Update way a subprocess is launched for Mac OS X.
Tony Lownds <tony@lownds.com>
parents:
26693
diff
changeset
|
311 # framework applet: sys.executable + -p is correct |
|
9b4c014b3a21
Update way a subprocess is launched for Mac OS X.
Tony Lownds <tony@lownds.com>
parents:
26693
diff
changeset
|
312 # python 2.2 + pure python main applet: |
|
9b4c014b3a21
Update way a subprocess is launched for Mac OS X.
Tony Lownds <tony@lownds.com>
parents:
26693
diff
changeset
|
313 # sys.executable + -p is correct |
|
9b4c014b3a21
Update way a subprocess is launched for Mac OS X.
Tony Lownds <tony@lownds.com>
parents:
26693
diff
changeset
|
314 # pythonw idle.py: sys.executable + -c is correct |
|
9b4c014b3a21
Update way a subprocess is launched for Mac OS X.
Tony Lownds <tony@lownds.com>
parents:
26693
diff
changeset
|
315 # |
|
9b4c014b3a21
Update way a subprocess is launched for Mac OS X.
Tony Lownds <tony@lownds.com>
parents:
26693
diff
changeset
|
316 # XXX what about warnoptions? |
|
9b4c014b3a21
Update way a subprocess is launched for Mac OS X.
Tony Lownds <tony@lownds.com>
parents:
26693
diff
changeset
|
317 return [sys.executable, '-p', str(self.port)] |
|
25480
9d50bc831bca
Finding a suitable interpreter to spawn needed tweaking on the Mac
Tony Lownds <tony@lownds.com>
parents:
25346
diff
changeset
|
318 else: |
|
26730
9b4c014b3a21
Update way a subprocess is launched for Mac OS X.
Tony Lownds <tony@lownds.com>
parents:
26693
diff
changeset
|
319 w = ['-W' + s for s in sys.warnoptions] |
|
9b4c014b3a21
Update way a subprocess is launched for Mac OS X.
Tony Lownds <tony@lownds.com>
parents:
26693
diff
changeset
|
320 return [sys.executable] + w \ |
|
9b4c014b3a21
Update way a subprocess is launched for Mac OS X.
Tony Lownds <tony@lownds.com>
parents:
26693
diff
changeset
|
321 + ["-c", "__import__('run').main()", str(self.port)] |
|
25480
9d50bc831bca
Finding a suitable interpreter to spawn needed tweaking on the Mac
Tony Lownds <tony@lownds.com>
parents:
25346
diff
changeset
|
322 |
| 25123 | 323 def start_subprocess(self): |
| 324 addr = ("localhost", self.port) | |
| 325 self.spawn_subprocess() | |
|
24559
f059d5435d65
GvR provided solution to the socket rebinding timeout problem.
Kurt B. Kaiser <kbk@shore.net>
parents:
24386
diff
changeset
|
326 # 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
|
327 for i in range(6): |
| 23547 | 328 time.sleep(i) |
| 329 try: | |
| 330 self.rpcclt = rpc.RPCClient(addr) | |
| 331 break | |
| 332 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
|
333 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
|
334 print>>sys.__stderr__, ". ", |
|
0e27b67247da
Reverse the RPC socket connection: Python execution server connects to
Kurt B. Kaiser <kbk@shore.net>
parents:
24183
diff
changeset
|
335 else: |
|
0e27b67247da
Reverse the RPC socket connection: Python execution server connects to
Kurt B. Kaiser <kbk@shore.net>
parents:
24183
diff
changeset
|
336 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
|
337 + ", retrying..." |
| 23547 | 338 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
|
339 display_port_binding_error() |
| 23547 | 340 return |
|
24386
0e27b67247da
Reverse the RPC socket connection: Python execution server connects to
Kurt B. Kaiser <kbk@shore.net>
parents:
24183
diff
changeset
|
341 # 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
|
342 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
|
343 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
|
344 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
|
345 self.rpcclt.register("stderr", self.tkconsole.stderr) |
| 23547 | 346 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
|
347 self.transfer_path() |
| 23547 | 348 self.poll_subprocess() |
| 349 | |
| 25123 | 350 def restart_subprocess(self): |
| 351 # close only the subprocess debugger | |
|
25894
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
352 debug = self.getdebugger() |
|
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
353 if debug: |
| 25123 | 354 RemoteDebugger.close_subprocess_debugger(self.rpcclt) |
| 355 # kill subprocess, spawn a new one, accept connection | |
| 356 self.rpcclt.close() | |
| 357 self.spawn_subprocess() | |
| 358 self.rpcclt.accept() | |
|
26590
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
359 self.transfer_path() |
| 25123 | 360 # restart remote debugger |
|
25894
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
361 if debug: |
| 25123 | 362 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
|
363 # reload remote debugger breakpoints for all PyShellEditWindows |
|
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
364 debug.load_breakpoints() |
|
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
365 |
|
26590
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
366 def transfer_path(self): |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
367 self.runcommand("""if 1: |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
368 import sys as _sys |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
369 _sys.path = %s |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
370 del _sys |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
371 \n""" % `sys.path`) |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
372 |
| 23547 | 373 active_seq = None |
| 374 | |
| 375 def poll_subprocess(self): | |
| 376 clt = self.rpcclt | |
| 377 if clt is None: | |
| 378 return | |
| 379 response = clt.pollresponse(self.active_seq) | |
| 26557 | 380 # Reschedule myself in 50 ms |
| 23547 | 381 self.tkconsole.text.after(50, self.poll_subprocess) |
| 382 if response: | |
| 383 self.tkconsole.resetoutput() | |
| 384 self.active_seq = None | |
| 385 how, what = response | |
| 386 file = self.tkconsole.console | |
| 387 if how == "OK": | |
| 388 if what is not None: | |
| 389 print >>file, `what` | |
| 390 elif how == "EXCEPTION": | |
| 391 mod, name, args, tb = what | |
| 392 print >>file, 'Traceback (most recent call last):' | |
| 393 while tb and tb[0][0] in ("run.py", "rpc.py"): | |
| 394 del tb[0] | |
| 395 while tb and tb[-1][0] in ("run.py", "rpc.py"): | |
| 396 del tb[-1] | |
| 397 for i in range(len(tb)): | |
| 398 fn, ln, nm, line = tb[i] | |
| 399 if not line and fn.startswith("<pyshell#"): | |
| 400 line = linecache.getline(fn, ln) | |
| 401 tb[i] = fn, ln, nm, line | |
| 402 traceback.print_list(tb, file=file) | |
| 26557 | 403 # try to reinstantiate the exception, stuff in the args: |
| 404 try: | |
| 405 etype = eval(mod + '.' + name) | |
| 406 val = etype() | |
| 407 val.args = args | |
| 408 except TypeError: # string exception! | |
| 409 etype = name | |
| 410 val = args | |
| 411 lines = traceback.format_exception_only(etype, val) | |
| 412 for line in lines[:-1]: | |
| 413 traceback._print(file, line, '') | |
| 414 traceback._print(file, lines[-1], '') | |
| 23547 | 415 if self.tkconsole.getvar("<<toggle-jit-stack-viewer>>"): |
| 416 self.remote_stack_viewer() | |
| 417 elif how == "ERROR": | |
| 26557 | 418 errmsg = "PyShell.ModifiedInterpreter: Subprocess ERROR:\n" |
| 419 print >>sys.__stderr__, errmsg, what | |
| 420 print >>file, errmsg, what | |
| 23547 | 421 self.tkconsole.endexecuting() |
| 422 | |
| 423 def kill_subprocess(self): | |
| 424 clt = self.rpcclt | |
| 425 self.rpcclt = None | |
| 426 if clt is not None: | |
| 427 clt.close() | |
| 428 | |
|
25894
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
429 debugger = None |
|
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
430 |
|
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
431 def setdebugger(self, debugger): |
|
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
432 self.debugger = debugger |
|
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
433 |
|
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
434 def getdebugger(self): |
|
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
435 return self.debugger |
|
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
436 |
| 23547 | 437 def remote_stack_viewer(self): |
| 438 import RemoteObjectBrowser | |
| 439 oid = self.rpcclt.remotecall("exec", "stackviewer", ("flist",), {}) | |
| 440 if oid is None: | |
| 441 self.tkconsole.root.bell() | |
| 442 return | |
| 443 item = RemoteObjectBrowser.StubObjectTreeItem(self.rpcclt, oid) | |
| 444 from TreeWidget import ScrolledCanvas, TreeNode | |
| 445 top = Toplevel(self.tkconsole.root) | |
| 446 sc = ScrolledCanvas(top, bg="white", highlightthickness=0) | |
| 447 sc.frame.pack(expand=1, fill="both") | |
| 448 node = TreeNode(sc.canvas, None, item) | |
| 449 node.expand() | |
| 450 # XXX Should GC the remote tree when closing the window | |
| 451 | |
| 13975 | 452 gid = 0 |
| 453 | |
| 454 def execsource(self, source): | |
|
23969
edd7c0146ac8
Clear associated breakpoints when closing an edit window.
Kurt B. Kaiser <kbk@shore.net>
parents:
23932
diff
changeset
|
455 "Like runsource() but assumes complete exec source" |
| 13975 | 456 filename = self.stuffsource(source) |
| 457 self.execfile(filename, source) | |
| 458 | |
| 459 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
|
460 "Execute an existing file" |
| 13975 | 461 if source is None: |
| 462 source = open(filename, "r").read() | |
| 463 try: | |
| 464 code = compile(source, filename, "exec") | |
| 465 except (OverflowError, SyntaxError): | |
| 466 self.tkconsole.resetoutput() | |
| 26557 | 467 console = self.tkconsole.console |
| 468 print >>console, 'Traceback (most recent call last):' | |
| 13975 | 469 InteractiveInterpreter.showsyntaxerror(self, filename) |
| 26468 | 470 self.tkconsole.showprompt() |
| 13975 | 471 else: |
| 472 self.runcode(code) | |
| 473 | |
| 474 def runsource(self, source): | |
|
23969
edd7c0146ac8
Clear associated breakpoints when closing an edit window.
Kurt B. Kaiser <kbk@shore.net>
parents:
23932
diff
changeset
|
475 "Extend base class method: Stuff the source in the line cache first" |
| 13975 | 476 filename = self.stuffsource(source) |
| 477 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
|
478 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
|
479 warnings.filterwarnings(action="error", category=SyntaxWarning) |
| 25310 | 480 if isinstance(source, types.UnicodeType): |
| 481 import IOBinding | |
| 482 try: | |
| 483 source = source.encode(IOBinding.encoding) | |
| 484 except UnicodeError: | |
| 485 self.tkconsole.resetoutput() | |
| 486 self.write("Unsupported characters in input") | |
| 487 return | |
|
18560
12e7ad108229
cvs-py-rel2_1 (Rev 1.29 - 1.33) merge
Kurt B. Kaiser <kbk@shore.net>
parents:
13975
diff
changeset
|
488 try: |
|
12e7ad108229
cvs-py-rel2_1 (Rev 1.29 - 1.33) merge
Kurt B. Kaiser <kbk@shore.net>
parents:
13975
diff
changeset
|
489 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
|
490 finally: |
|
12e7ad108229
cvs-py-rel2_1 (Rev 1.29 - 1.33) merge
Kurt B. Kaiser <kbk@shore.net>
parents:
13975
diff
changeset
|
491 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
|
492 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
|
493 self.save_warnings_filters = None |
| 13975 | 494 |
| 495 def stuffsource(self, source): | |
|
23969
edd7c0146ac8
Clear associated breakpoints when closing an edit window.
Kurt B. Kaiser <kbk@shore.net>
parents:
23932
diff
changeset
|
496 "Stuff source in the filename cache" |
| 13975 | 497 filename = "<pyshell#%d>" % self.gid |
| 498 self.gid = self.gid + 1 | |
| 25310 | 499 lines = source.split("\n") |
| 13975 | 500 linecache.cache[filename] = len(source)+1, 0, lines, filename |
| 501 return filename | |
| 25310 | 502 |
| 13975 | 503 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
|
504 """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
|
505 |
|
edd7c0146ac8
Clear associated breakpoints when closing an edit window.
Kurt B. Kaiser <kbk@shore.net>
parents:
23932
diff
changeset
|
506 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
|
507 with a caret. |
|
edd7c0146ac8
Clear associated breakpoints when closing an edit window.
Kurt B. Kaiser <kbk@shore.net>
parents:
23932
diff
changeset
|
508 |
|
edd7c0146ac8
Clear associated breakpoints when closing an edit window.
Kurt B. Kaiser <kbk@shore.net>
parents:
23932
diff
changeset
|
509 """ |
| 13975 | 510 text = self.tkconsole.text |
| 511 stuff = self.unpackerror() | |
| 26468 | 512 if stuff: |
| 513 msg, lineno, offset, line = stuff | |
| 514 if lineno == 1: | |
| 515 pos = "iomark + %d chars" % (offset-1) | |
| 516 else: | |
| 517 pos = "iomark linestart + %d lines + %d chars" % \ | |
| 518 (lineno-1, offset-1) | |
| 519 text.tag_add("ERROR", pos) | |
| 520 text.see(pos) | |
| 521 char = text.get(pos) | |
| 522 if char and char in IDENTCHARS: | |
| 523 text.tag_add("ERROR", pos + " wordstart", pos) | |
| 524 self.tkconsole.resetoutput() | |
| 525 self.write("SyntaxError: %s\n" % str(msg)) | |
| 526 else: | |
| 13975 | 527 self.tkconsole.resetoutput() |
| 528 InteractiveInterpreter.showsyntaxerror(self, filename) | |
| 26468 | 529 self.tkconsole.showprompt() |
| 13975 | 530 |
| 531 def unpackerror(self): | |
| 532 type, value, tb = sys.exc_info() | |
| 533 ok = type is SyntaxError | |
| 534 if ok: | |
| 535 try: | |
| 536 msg, (dummy_filename, lineno, offset, line) = value | |
| 537 except: | |
| 538 ok = 0 | |
| 539 if ok: | |
| 540 return msg, lineno, offset, line | |
| 541 else: | |
| 542 return None | |
| 543 | |
| 544 def showtraceback(self): | |
|
23969
edd7c0146ac8
Clear associated breakpoints when closing an edit window.
Kurt B. Kaiser <kbk@shore.net>
parents:
23932
diff
changeset
|
545 "Extend base class method to reset output properly" |
| 13975 | 546 self.tkconsole.resetoutput() |
| 547 self.checklinecache() | |
| 548 InteractiveInterpreter.showtraceback(self) | |
| 23547 | 549 if self.tkconsole.getvar("<<toggle-jit-stack-viewer>>"): |
| 550 self.tkconsole.open_stack_viewer() | |
| 13975 | 551 |
| 552 def checklinecache(self): | |
| 553 c = linecache.cache | |
| 554 for key in c.keys(): | |
| 555 if key[:1] + key[-1:] != "<>": | |
| 556 del c[key] | |
| 557 | |
| 25123 | 558 def display_executing_dialog(self): |
| 559 tkMessageBox.showerror( | |
| 560 "Already executing", | |
| 561 "The Python Shell window is already executing a command; " | |
| 562 "please wait until it is finished.", | |
| 563 master=self.tkconsole.text) | |
| 564 | |
| 23547 | 565 def runcommand(self, code): |
|
23969
edd7c0146ac8
Clear associated breakpoints when closing an edit window.
Kurt B. Kaiser <kbk@shore.net>
parents:
23932
diff
changeset
|
566 "Run the code without invoking the debugger" |
| 23547 | 567 # The code better not raise an exception! |
| 568 if self.tkconsole.executing: | |
|
26471
99c78cf95610
Add missing self for method call
Neal Norwitz <nnorwitz@gmail.com>
parents:
26468
diff
changeset
|
569 self.display_executing_dialog() |
| 23547 | 570 return 0 |
| 571 if self.rpcclt: | |
| 572 self.rpcclt.remotecall("exec", "runcode", (code,), {}) | |
| 573 else: | |
| 574 exec code in self.locals | |
| 575 return 1 | |
| 576 | |
| 13975 | 577 def runcode(self, code): |
|
23969
edd7c0146ac8
Clear associated breakpoints when closing an edit window.
Kurt B. Kaiser <kbk@shore.net>
parents:
23932
diff
changeset
|
578 "Override base class method" |
| 23547 | 579 if self.tkconsole.executing: |
|
26471
99c78cf95610
Add missing self for method call
Neal Norwitz <nnorwitz@gmail.com>
parents:
26468
diff
changeset
|
580 self.display_executing_dialog() |
| 23547 | 581 return |
| 582 self.checklinecache() | |
|
18560
12e7ad108229
cvs-py-rel2_1 (Rev 1.29 - 1.33) merge
Kurt B. Kaiser <kbk@shore.net>
parents:
13975
diff
changeset
|
583 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
|
584 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
|
585 self.save_warnings_filters = None |
| 13975 | 586 debugger = self.debugger |
| 23547 | 587 if not debugger and self.rpcclt is not None: |
| 588 self.tkconsole.beginexecuting() | |
| 589 self.active_seq = self.rpcclt.asynccall("exec", "runcode", | |
| 590 (code,), {}) | |
| 591 return | |
| 13975 | 592 try: |
| 593 self.tkconsole.beginexecuting() | |
| 594 try: | |
| 595 if debugger: | |
| 596 debugger.run(code, self.locals) | |
| 597 else: | |
| 598 exec code in self.locals | |
| 599 except SystemExit: | |
| 600 if tkMessageBox.askyesno( | |
| 601 "Exit?", | |
| 602 "Do you want to exit altogether?", | |
| 603 default="yes", | |
| 604 master=self.tkconsole.text): | |
| 605 raise | |
| 606 else: | |
| 607 self.showtraceback() | |
| 608 except: | |
| 609 self.showtraceback() | |
| 610 finally: | |
| 611 self.tkconsole.endexecuting() | |
| 612 | |
| 613 def write(self, s): | |
|
23969
edd7c0146ac8
Clear associated breakpoints when closing an edit window.
Kurt B. Kaiser <kbk@shore.net>
parents:
23932
diff
changeset
|
614 "Override base class method" |
| 13975 | 615 self.tkconsole.console.write(s) |
| 616 | |
| 617 class PyShell(OutputWindow): | |
| 618 | |
| 619 shell_title = "Python Shell" | |
| 620 | |
| 621 # Override classes | |
| 622 ColorDelegator = ModifiedColorDelegator | |
| 623 UndoDelegator = ModifiedUndoDelegator | |
| 624 | |
|
26590
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
625 # Override menus |
|
24183
1723bcdc1e85
1. Prevent Undo before IOmark in PyShell.PyShell
Kurt B. Kaiser <kbk@shore.net>
parents:
23995
diff
changeset
|
626 menu_specs = [ |
|
1723bcdc1e85
1. Prevent Undo before IOmark in PyShell.PyShell
Kurt B. Kaiser <kbk@shore.net>
parents:
23995
diff
changeset
|
627 ("file", "_File"), |
|
1723bcdc1e85
1. Prevent Undo before IOmark in PyShell.PyShell
Kurt B. Kaiser <kbk@shore.net>
parents:
23995
diff
changeset
|
628 ("edit", "_Edit"), |
|
1723bcdc1e85
1. Prevent Undo before IOmark in PyShell.PyShell
Kurt B. Kaiser <kbk@shore.net>
parents:
23995
diff
changeset
|
629 ("debug", "_Debug"), |
|
1723bcdc1e85
1. Prevent Undo before IOmark in PyShell.PyShell
Kurt B. Kaiser <kbk@shore.net>
parents:
23995
diff
changeset
|
630 ("settings", "_Settings"), |
|
1723bcdc1e85
1. Prevent Undo before IOmark in PyShell.PyShell
Kurt B. Kaiser <kbk@shore.net>
parents:
23995
diff
changeset
|
631 ("windows", "_Windows"), |
|
1723bcdc1e85
1. Prevent Undo before IOmark in PyShell.PyShell
Kurt B. Kaiser <kbk@shore.net>
parents:
23995
diff
changeset
|
632 ("help", "_Help"), |
|
1723bcdc1e85
1. Prevent Undo before IOmark in PyShell.PyShell
Kurt B. Kaiser <kbk@shore.net>
parents:
23995
diff
changeset
|
633 ] |
| 13975 | 634 |
| 635 # New classes | |
| 636 from IdleHistory import History | |
| 637 | |
| 638 def __init__(self, flist=None): | |
| 639 self.interp = ModifiedInterpreter(self) | |
| 640 if flist is None: | |
| 641 root = Tk() | |
| 642 fixwordbreaks(root) | |
| 643 root.withdraw() | |
| 644 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
|
645 # |
| 13975 | 646 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
|
647 # |
| 13975 | 648 import __builtin__ |
| 649 __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
|
650 # |
|
25261
4b6185128814
MERGE DS_RPC_BRANCH into MAIN
Kurt B. Kaiser <kbk@shore.net>
parents:
25123
diff
changeset
|
651 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
|
652 # |
| 13975 | 653 text = self.text |
| 654 text.configure(wrap="char") | |
| 655 text.bind("<<newline-and-indent>>", self.enter_callback) | |
| 656 text.bind("<<plain-newline-and-indent>>", self.linefeed_callback) | |
| 657 text.bind("<<interrupt-execution>>", self.cancel_callback) | |
| 658 text.bind("<<beginning-of-line>>", self.home_callback) | |
| 659 text.bind("<<end-of-file>>", self.eof_callback) | |
| 660 text.bind("<<open-stack-viewer>>", self.open_stack_viewer) | |
| 661 text.bind("<<toggle-debugger>>", self.toggle_debugger) | |
| 662 text.bind("<<open-python-shell>>", self.flist.open_shell) | |
| 663 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
|
664 # |
| 13975 | 665 self.save_stdout = sys.stdout |
| 666 self.save_stderr = sys.stderr | |
| 667 self.save_stdin = sys.stdin | |
| 23547 | 668 self.stdout = PseudoFile(self, "stdout") |
| 669 self.stderr = PseudoFile(self, "stderr") | |
| 13975 | 670 self.console = PseudoFile(self, "console") |
| 23547 | 671 if not use_subprocess: |
| 672 sys.stdout = self.stdout | |
| 673 sys.stderr = self.stderr | |
| 674 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
|
675 # |
| 13975 | 676 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
|
677 # |
| 23547 | 678 if use_subprocess: |
| 25123 | 679 self.interp.start_subprocess() |
| 23547 | 680 |
| 13975 | 681 reading = 0 |
| 682 executing = 0 | |
| 683 canceled = 0 | |
| 684 endoffile = 0 | |
| 685 | |
| 686 def toggle_debugger(self, event=None): | |
| 687 if self.executing: | |
| 688 tkMessageBox.showerror("Don't debug now", | |
| 689 "You can only toggle the debugger when idle", | |
| 690 master=self.text) | |
| 691 self.set_debugger_indicator() | |
| 692 return "break" | |
| 693 else: | |
| 694 db = self.interp.getdebugger() | |
| 695 if db: | |
| 696 self.close_debugger() | |
| 697 else: | |
| 698 self.open_debugger() | |
| 699 | |
| 700 def set_debugger_indicator(self): | |
| 701 db = self.interp.getdebugger() | |
| 702 self.setvar("<<toggle-debugger>>", not not db) | |
| 703 | |
| 704 def toggle_jit_stack_viewer( self, event=None): | |
| 705 pass # All we need is the variable | |
| 706 | |
| 707 def close_debugger(self): | |
| 708 db = self.interp.getdebugger() | |
| 709 if db: | |
| 710 self.interp.setdebugger(None) | |
| 711 db.close() | |
|
23995
41468f9353ce
Shutdown subprocess debugger and associated Proxies/Adapters when closing
Kurt B. Kaiser <kbk@shore.net>
parents:
23969
diff
changeset
|
712 if self.interp.rpcclt: |
|
41468f9353ce
Shutdown subprocess debugger and associated Proxies/Adapters when closing
Kurt B. Kaiser <kbk@shore.net>
parents:
23969
diff
changeset
|
713 RemoteDebugger.close_remote_debugger(self.interp.rpcclt) |
| 13975 | 714 self.resetoutput() |
| 715 self.console.write("[DEBUG OFF]\n") | |
| 716 sys.ps1 = ">>> " | |
| 717 self.showprompt() | |
| 718 self.set_debugger_indicator() | |
| 719 | |
| 720 def open_debugger(self): | |
|
23876
832f0501148b
Polish RemoteDebugger code.
Kurt B. Kaiser <kbk@shore.net>
parents:
23784
diff
changeset
|
721 # 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
|
722 # 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
|
723 # with open_remote_debugger? |
| 23547 | 724 if self.interp.rpcclt: |
| 725 return self.open_remote_debugger() | |
| 13975 | 726 import Debugger |
| 727 self.interp.setdebugger(Debugger.Debugger(self)) | |
| 728 sys.ps1 = "[DEBUG ON]\n>>> " | |
| 729 self.showprompt() | |
| 730 self.set_debugger_indicator() | |
| 731 | |
| 23547 | 732 def open_remote_debugger(self): |
| 733 gui = RemoteDebugger.start_remote_debugger(self.interp.rpcclt, self) | |
| 734 self.interp.setdebugger(gui) | |
|
25894
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
735 # Load all PyShellEditorWindow breakpoints: |
|
19500c9b58c1
Implement Restoring Breakpoints in Subprocess Debugger
Kurt B. Kaiser <kbk@shore.net>
parents:
25691
diff
changeset
|
736 gui.load_breakpoints() |
| 23547 | 737 sys.ps1 = "[DEBUG ON]\n>>> " |
| 738 self.showprompt() | |
| 739 self.set_debugger_indicator() | |
| 740 | |
| 13975 | 741 def beginexecuting(self): |
|
23995
41468f9353ce
Shutdown subprocess debugger and associated Proxies/Adapters when closing
Kurt B. Kaiser <kbk@shore.net>
parents:
23969
diff
changeset
|
742 "Helper for ModifiedInterpreter" |
| 13975 | 743 self.resetoutput() |
| 744 self.executing = 1 | |
| 745 ##self._cancel_check = self.cancel_check | |
| 746 ##sys.settrace(self._cancel_check) | |
| 747 | |
| 748 def endexecuting(self): | |
|
23969
edd7c0146ac8
Clear associated breakpoints when closing an edit window.
Kurt B. Kaiser <kbk@shore.net>
parents:
23932
diff
changeset
|
749 "Helper for ModifiedInterpreter" |
| 13975 | 750 ##sys.settrace(None) |
| 751 ##self._cancel_check = None | |
| 752 self.executing = 0 | |
| 753 self.canceled = 0 | |
| 23547 | 754 self.showprompt() |
| 13975 | 755 |
| 756 def close(self): | |
|
23969
edd7c0146ac8
Clear associated breakpoints when closing an edit window.
Kurt B. Kaiser <kbk@shore.net>
parents:
23932
diff
changeset
|
757 "Extend EditorWindow.close()" |
| 13975 | 758 if self.executing: |
| 759 # XXX Need to ask a question here | |
| 760 if not tkMessageBox.askokcancel( | |
| 761 "Kill?", | |
| 762 "The program is still running; do you want to kill it?", | |
| 763 default="ok", | |
| 764 master=self.text): | |
| 765 return "cancel" | |
| 766 self.canceled = 1 | |
| 767 if self.reading: | |
| 768 self.top.quit() | |
| 769 return "cancel" | |
|
23969
edd7c0146ac8
Clear associated breakpoints when closing an edit window.
Kurt B. Kaiser <kbk@shore.net>
parents:
23932
diff
changeset
|
770 return EditorWindow.close(self) |
| 13975 | 771 |
| 772 def _close(self): | |
|
23969
edd7c0146ac8
Clear associated breakpoints when closing an edit window.
Kurt B. Kaiser <kbk@shore.net>
parents:
23932
diff
changeset
|
773 "Extend EditorWindow._close(), shut down debugger and execution server" |
| 13975 | 774 self.close_debugger() |
| 23547 | 775 self.interp.kill_subprocess() |
| 13975 | 776 # Restore std streams |
| 777 sys.stdout = self.save_stdout | |
| 778 sys.stderr = self.save_stderr | |
| 779 sys.stdin = self.save_stdin | |
| 780 # Break cycles | |
| 781 self.interp = None | |
| 782 self.console = None | |
| 783 self.flist.pyshell = None | |
| 784 self.history = None | |
|
23969
edd7c0146ac8
Clear associated breakpoints when closing an edit window.
Kurt B. Kaiser <kbk@shore.net>
parents:
23932
diff
changeset
|
785 EditorWindow._close(self) |
| 13975 | 786 |
| 787 def ispythonsource(self, filename): | |
|
23969
edd7c0146ac8
Clear associated breakpoints when closing an edit window.
Kurt B. Kaiser <kbk@shore.net>
parents:
23932
diff
changeset
|
788 "Override EditorWindow method: never remove the colorizer" |
| 25310 | 789 return True |
| 13975 | 790 |
| 791 def short_title(self): | |
| 792 return self.shell_title | |
| 793 | |
|
18560
12e7ad108229
cvs-py-rel2_1 (Rev 1.29 - 1.33) merge
Kurt B. Kaiser <kbk@shore.net>
parents:
13975
diff
changeset
|
794 COPYRIGHT = \ |
|
12e7ad108229
cvs-py-rel2_1 (Rev 1.29 - 1.33) merge
Kurt B. Kaiser <kbk@shore.net>
parents:
13975
diff
changeset
|
795 '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
|
796 |
| 13975 | 797 def begin(self): |
| 798 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
|
799 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
|
800 (sys.version, sys.platform, self.COPYRIGHT, |
| 13975 | 801 idlever.IDLE_VERSION)) |
| 802 try: | |
| 803 sys.ps1 | |
| 804 except AttributeError: | |
| 805 sys.ps1 = ">>> " | |
| 806 self.showprompt() | |
| 807 import Tkinter | |
| 808 Tkinter._default_root = None | |
| 809 | |
| 810 def interact(self): | |
| 811 self.begin() | |
| 812 self.top.mainloop() | |
| 813 | |
| 814 def readline(self): | |
| 815 save = self.reading | |
| 816 try: | |
| 817 self.reading = 1 | |
| 818 self.top.mainloop() | |
| 819 finally: | |
| 820 self.reading = save | |
| 821 line = self.text.get("iomark", "end-1c") | |
| 822 self.resetoutput() | |
| 823 if self.canceled: | |
| 824 self.canceled = 0 | |
| 825 raise KeyboardInterrupt | |
| 826 if self.endoffile: | |
| 827 self.endoffile = 0 | |
| 828 return "" | |
| 829 return line | |
| 830 | |
| 831 def isatty(self): | |
| 25310 | 832 return True |
| 13975 | 833 |
| 834 def cancel_callback(self, event): | |
| 835 try: | |
| 836 if self.text.compare("sel.first", "!=", "sel.last"): | |
| 837 return # Active selection -- always use default binding | |
| 838 except: | |
| 839 pass | |
| 840 if not (self.executing or self.reading): | |
| 841 self.resetoutput() | |
| 842 self.write("KeyboardInterrupt\n") | |
| 843 self.showprompt() | |
| 844 return "break" | |
| 845 self.endoffile = 0 | |
| 846 if self.reading: | |
| 23547 | 847 self.canceled = 1 |
| 13975 | 848 self.top.quit() |
| 23547 | 849 elif (self.executing and self.interp.rpcclt and |
| 850 self.interp.rpcpid and hasattr(os, "kill")): | |
| 851 try: | |
| 852 from signal import SIGINT | |
| 853 except ImportError: | |
| 854 SIGINT = 2 | |
| 855 os.kill(self.interp.rpcpid, SIGINT) | |
| 856 else: | |
| 857 self.canceled = 1 | |
| 13975 | 858 return "break" |
| 859 | |
| 860 def eof_callback(self, event): | |
| 861 if self.executing and not self.reading: | |
| 862 return # Let the default binding (delete next char) take over | |
| 863 if not (self.text.compare("iomark", "==", "insert") and | |
| 864 self.text.compare("insert", "==", "end-1c")): | |
| 865 return # Let the default binding (delete next char) take over | |
| 866 if not self.executing: | |
| 867 self.resetoutput() | |
| 868 self.close() | |
| 869 else: | |
| 870 self.canceled = 0 | |
| 871 self.endoffile = 1 | |
| 872 self.top.quit() | |
| 873 return "break" | |
| 874 | |
| 875 def home_callback(self, event): | |
| 876 if event.state != 0 and event.keysym == "Home": | |
| 877 return # <Modifier-Home>; fall back to class binding | |
| 878 if self.text.compare("iomark", "<=", "insert") and \ | |
| 879 self.text.compare("insert linestart", "<=", "iomark"): | |
| 880 self.text.mark_set("insert", "iomark") | |
| 881 self.text.tag_remove("sel", "1.0", "end") | |
| 882 self.text.see("insert") | |
| 883 return "break" | |
| 884 | |
| 885 def linefeed_callback(self, event): | |
| 886 # Insert a linefeed without entering anything (still autoindented) | |
| 887 if self.reading: | |
| 888 self.text.insert("insert", "\n") | |
| 889 self.text.see("insert") | |
| 890 else: | |
| 26667 | 891 self.newline_and_indent_event(event) |
| 13975 | 892 return "break" |
| 893 | |
| 894 def enter_callback(self, event): | |
| 895 if self.executing and not self.reading: | |
| 896 return # Let the default binding (insert '\n') take over | |
| 897 # If some text is selected, recall the selection | |
| 898 # (but only if this before the I/O mark) | |
| 899 try: | |
| 900 sel = self.text.get("sel.first", "sel.last") | |
| 901 if sel: | |
| 902 if self.text.compare("sel.last", "<=", "iomark"): | |
| 903 self.recall(sel) | |
| 904 return "break" | |
| 905 except: | |
| 906 pass | |
| 907 # If we're strictly before the line containing iomark, recall | |
| 908 # the current line, less a leading prompt, less leading or | |
| 909 # trailing whitespace | |
| 910 if self.text.compare("insert", "<", "iomark linestart"): | |
| 911 # Check if there's a relevant stdin range -- if so, use it | |
| 912 prev = self.text.tag_prevrange("stdin", "insert") | |
| 913 if prev and self.text.compare("insert", "<", prev[1]): | |
| 914 self.recall(self.text.get(prev[0], prev[1])) | |
| 915 return "break" | |
| 916 next = self.text.tag_nextrange("stdin", "insert") | |
| 917 if next and self.text.compare("insert lineend", ">=", next[0]): | |
| 918 self.recall(self.text.get(next[0], next[1])) | |
| 919 return "break" | |
| 920 # No stdin mark -- just get the current line | |
| 921 self.recall(self.text.get("insert linestart", "insert lineend")) | |
| 922 return "break" | |
| 26667 | 923 # If we're between the beginning of the line and the iomark, i.e. |
| 924 # in the prompt area, complain. | |
| 925 if self.text.compare("insert", "<", "iomark"): | |
| 926 self.text.bell() | |
| 927 return "break" | |
| 13975 | 928 # If we're in the current input and there's only whitespace |
| 929 # beyond the cursor, erase that whitespace first | |
| 930 s = self.text.get("insert", "end-1c") | |
| 25310 | 931 if s and not s.strip(): |
| 13975 | 932 self.text.delete("insert", "end-1c") |
| 933 # If we're in the current input before its last line, | |
| 934 # insert a newline right at the insert point | |
| 935 if self.text.compare("insert", "<", "end-1c linestart"): | |
| 26667 | 936 self.newline_and_indent_event(event) |
| 13975 | 937 return "break" |
| 938 # We're in the last line; append a newline and submit it | |
| 939 self.text.mark_set("insert", "end-1c") | |
| 940 if self.reading: | |
| 941 self.text.insert("insert", "\n") | |
| 942 self.text.see("insert") | |
| 943 else: | |
| 26667 | 944 self.newline_and_indent_event(event) |
| 13975 | 945 self.text.tag_add("stdin", "iomark", "end-1c") |
| 946 self.text.update_idletasks() | |
| 947 if self.reading: | |
| 948 self.top.quit() # Break out of recursive mainloop() in raw_input() | |
| 949 else: | |
| 950 self.runit() | |
| 951 return "break" | |
| 952 | |
| 953 def recall(self, s): | |
| 954 if self.history: | |
| 955 self.history.recall(s) | |
| 956 | |
| 957 def runit(self): | |
| 958 line = self.text.get("iomark", "end-1c") | |
| 959 # Strip off last newline and surrounding whitespace. | |
| 960 # (To allow you to hit return twice to end a statement.) | |
| 961 i = len(line) | |
| 962 while i > 0 and line[i-1] in " \t": | |
| 963 i = i-1 | |
| 964 if i > 0 and line[i-1] == "\n": | |
| 965 i = i-1 | |
| 966 while i > 0 and line[i-1] in " \t": | |
| 967 i = i-1 | |
| 968 line = line[:i] | |
| 969 more = self.interp.runsource(line) | |
| 970 | |
| 971 def cancel_check(self, frame, what, args, | |
| 972 dooneevent=tkinter.dooneevent, | |
| 973 dontwait=tkinter.DONT_WAIT): | |
| 974 # Hack -- use the debugger hooks to be able to handle events | |
| 975 # and interrupt execution at any time. | |
| 976 # This slows execution down quite a bit, so you may want to | |
| 977 # disable this (by not calling settrace() in runcode() above) | |
| 978 # for full-bore (uninterruptable) speed. | |
| 979 # XXX This should become a user option. | |
| 980 if self.canceled: | |
| 981 return | |
| 982 dooneevent(dontwait) | |
| 983 if self.canceled: | |
| 984 self.canceled = 0 | |
| 985 raise KeyboardInterrupt | |
| 986 return self._cancel_check | |
| 987 | |
| 988 def open_stack_viewer(self, event=None): | |
| 23547 | 989 if self.interp.rpcclt: |
| 990 return self.interp.remote_stack_viewer() | |
| 13975 | 991 try: |
| 992 sys.last_traceback | |
| 993 except: | |
| 994 tkMessageBox.showerror("No stack trace", | |
| 995 "There is no stack trace yet.\n" | |
| 996 "(sys.last_traceback is not defined)", | |
| 997 master=self.text) | |
| 998 return | |
| 999 from StackViewer import StackBrowser | |
| 1000 sv = StackBrowser(self.root, self.flist) | |
| 1001 | |
| 1002 def showprompt(self): | |
| 1003 self.resetoutput() | |
| 1004 try: | |
| 1005 s = str(sys.ps1) | |
| 1006 except: | |
| 1007 s = "" | |
| 1008 self.console.write(s) | |
| 1009 self.text.mark_set("insert", "end-1c") | |
| 23547 | 1010 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
|
1011 self.io.reset_undo() |
| 13975 | 1012 |
| 1013 def resetoutput(self): | |
| 1014 source = self.text.get("iomark", "end-1c") | |
| 1015 if self.history: | |
| 1016 self.history.history_store(source) | |
| 1017 if self.text.get("end-2c") != "\n": | |
| 1018 self.text.insert("end-1c", "\n") | |
| 1019 self.text.mark_set("iomark", "end-1c") | |
| 23547 | 1020 self.set_line_and_column() |
| 13975 | 1021 sys.stdout.softspace = 0 |
| 1022 | |
| 1023 def write(self, s, tags=()): | |
| 1024 self.text.mark_gravity("iomark", "right") | |
| 1025 OutputWindow.write(self, s, tags, "iomark") | |
| 1026 self.text.mark_gravity("iomark", "left") | |
| 1027 if self.canceled: | |
| 1028 self.canceled = 0 | |
| 1029 raise KeyboardInterrupt | |
| 1030 | |
| 1031 class PseudoFile: | |
| 1032 | |
| 1033 def __init__(self, shell, tags): | |
| 1034 self.shell = shell | |
| 1035 self.tags = tags | |
| 23547 | 1036 self.softspace = 0 |
| 13975 | 1037 |
| 1038 def write(self, s): | |
| 1039 self.shell.write(s, self.tags) | |
| 1040 | |
| 1041 def writelines(self, l): | |
| 1042 map(self.write, l) | |
| 1043 | |
| 1044 def flush(self): | |
| 1045 pass | |
| 1046 | |
| 1047 def isatty(self): | |
| 25310 | 1048 return True |
| 13975 | 1049 |
|
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
|
1050 |
| 13975 | 1051 usage_msg = """\ |
|
26590
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1052 |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1053 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
|
1054 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
|
1055 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
|
1056 |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1057 -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
|
1058 |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1059 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
|
1060 |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1061 -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
|
1062 -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
|
1063 |
|
26590
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1064 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
|
1065 |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1066 -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
|
1067 -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
|
1068 |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1069 -d enable the debugger |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1070 -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
|
1071 -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
|
1072 |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1073 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
|
1074 |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1075 [arg]* are passed to the command (-c) or script (-r) in sys.argv[1:]. |
| 13975 | 1076 |
|
26590
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1077 Examples: |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1078 |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1079 idle |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1080 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
|
1081 |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1082 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
|
1083 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
|
1084 |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1085 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
|
1086 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
|
1087 window with the title "Baz". |
| 13975 | 1088 |
|
26590
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1089 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
|
1090 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
|
1091 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
|
1092 |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1093 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
|
1094 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
|
1095 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
|
1096 sys.argv[1]. |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1097 |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1098 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
|
1099 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
|
1100 and "foobar" in sys.argv[1]. |
| 13975 | 1101 """ |
| 1102 | |
|
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
|
1103 def main(): |
|
26590
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1104 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
|
1105 |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1106 enable_shell = False |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1107 enable_edit = False |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1108 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
|
1109 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
|
1110 script = None |
|
26590
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1111 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
|
1112 try: |
|
26590
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1113 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
|
1114 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
|
1115 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
|
1116 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
|
1117 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
|
1118 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
|
1119 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
|
1120 cmd = a |
|
26590
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1121 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
|
1122 if o == '-d': |
|
26590
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1123 debug = True |
|
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 == '-e': |
|
26590
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1126 enable_edit = True |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1127 if o == '-h': |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1128 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
|
1129 sys.exit() |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1130 if o == '-i': |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1131 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
|
1132 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
|
1133 script = a |
|
26590
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1134 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
|
1135 pass |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1136 else: |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1137 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
|
1138 sys.exit() |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1139 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
|
1140 if o == '-s': |
|
26590
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1141 startup = True |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1142 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
|
1143 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
|
1144 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
|
1145 enable_shell = True |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1146 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
|
1147 cmd = sys.stdin.read() |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1148 enable_shell = True |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1149 |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1150 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
|
1151 |
|
26590
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1152 # 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
|
1153 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
|
1154 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
|
1155 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
|
1156 sys.argv = [''] + args[1:] |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1157 elif cmd: |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1158 sys.argv = ['-c'] + args |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1159 elif script: |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1160 sys.argv = [script] + args |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1161 elif args: |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1162 enable_edit = True |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1163 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
|
1164 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
|
1165 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
|
1166 for dir in pathx: |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1167 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
|
1168 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
|
1169 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
|
1170 # 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
|
1171 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
|
1172 '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
|
1173 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
|
1174 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
|
1175 # 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
|
1176 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
|
1177 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
|
1178 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
|
1179 flist = PyShellFileList(root) |
|
26730
9b4c014b3a21
Update way a subprocess is launched for Mac OS X.
Tony Lownds <tony@lownds.com>
parents:
26693
diff
changeset
|
1180 |
|
26590
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1181 if enable_edit: |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1182 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
|
1183 for filename in args: |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1184 flist.open(filename) |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1185 if not args: |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1186 flist.new() |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1187 if enable_shell: |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1188 flist.open_shell() |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1189 elif enable_shell: |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1190 flist.pyshell = PyShell(flist) |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1191 flist.pyshell.begin() |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1192 shell = flist.pyshell |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1193 # handle remaining options: |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1194 if debug: |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1195 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
|
1196 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
|
1197 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
|
1198 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
|
1199 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
|
1200 shell.interp.execfile(filename) |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1201 if cmd or script: |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1202 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
|
1203 import sys as _sys |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1204 _sys.argv = %s |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1205 del _sys |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1206 \n""" % `sys.argv`) |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1207 if cmd: |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1208 shell.interp.execsource(cmd) |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1209 elif script: |
|
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1210 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
|
1211 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
|
1212 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
|
1213 |
|
26590
615a25a6eb5b
Rework the command line interface, incorporating the shell/edit
Kurt B. Kaiser <kbk@shore.net>
parents:
26557
diff
changeset
|
1214 |
|
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
|
1215 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
|
1216 print """\ |
|
20306
1ca228e21a98
merged port binding error message patch
Steven M. Gava <elguavas@python.net>
parents:
18649
diff
changeset
|
1217 IDLE cannot run. |
|
1ca228e21a98
merged port binding error message patch
Steven M. Gava <elguavas@python.net>
parents:
18649
diff
changeset
|
1218 |
|
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
|
1219 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
|
1220 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
|
1221 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
|
1222 |
|
1ca228e21a98
merged port binding error message patch
Steven M. Gava <elguavas@python.net>
parents:
18649
diff
changeset
|
1223 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
|
1224 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
|
1225 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
|
1226 |
|
1ca228e21a98
merged port binding error message patch
Steven M. Gava <elguavas@python.net>
parents:
18649
diff
changeset
|
1227 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
|
1228 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
|
1229 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
|
1230 """ |
| 13975 | 1231 |
| 1232 if __name__ == "__main__": | |
| 1233 main() |
