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