mirror of
https://github.com/python/cpython.git
synced 2024-11-24 18:34:43 +08:00
Added an optional debug handler that traps and prints all unknown appleevents.
This commit is contained in:
parent
d13c385462
commit
8eff33b51f
@ -30,7 +30,7 @@ def main():
|
||||
dummy = Res.GetResource('DLOG', ID_MAIN)
|
||||
except Res.Error:
|
||||
try:
|
||||
Res.OpenResFile("PICTbrowse.rsrc")
|
||||
Res.FSpOpenResFile("PICTbrowse.rsrc", 1)
|
||||
except Res.Error, arg:
|
||||
EasyDialogs.Message("Cannot open PICTbrowse.rsrc: "+arg[1])
|
||||
sys.exit(1)
|
||||
|
@ -25,7 +25,7 @@ def main():
|
||||
dummy = Res.GetResource('DLOG', ID_MAIN)
|
||||
except Res.Error:
|
||||
try:
|
||||
Res.OpenResFile("PICTbrowse.rsrc")
|
||||
Res.FSpOpenResFile("PICTbrowse.rsrc", 1)
|
||||
except Res.Error, arg:
|
||||
EasyDialogs.Message("Cannot open PICTbrowse.rsrc: "+arg[1])
|
||||
sys.exit(1)
|
||||
|
Binary file not shown.
@ -29,7 +29,7 @@ def main():
|
||||
dummy = Res.GetResource('DLOG', ID_MAIN)
|
||||
except Res.Error:
|
||||
try:
|
||||
Res.OpenResFile("PICTbrowse.rsrc")
|
||||
Res.FSpOpenResFile("PICTbrowse.rsrc", 1)
|
||||
except Res.Error, arg:
|
||||
EasyDialogs.Message("Cannot open PICTbrowse.rsrc: "+arg[1])
|
||||
sys.exit(1)
|
||||
|
@ -30,7 +30,7 @@ def main():
|
||||
dummy = Res.GetResource('DLOG', ID_MAIN)
|
||||
except Res.Error:
|
||||
try:
|
||||
Res.OpenResFile("PICTbrowse.rsrc")
|
||||
Res.FSpOpenResFile("PICTbrowse.rsrc", 1)
|
||||
except Res.Error, arg:
|
||||
EasyDialogs.Message("Cannot open PICTbrowse.rsrc: "+arg[1])
|
||||
sys.exit(1)
|
||||
|
Binary file not shown.
@ -4,6 +4,8 @@
|
||||
from MiniAEFrame import AEServer, MiniApplication
|
||||
import MacOS
|
||||
|
||||
debug=1
|
||||
|
||||
class CGITest(AEServer, MiniApplication):
|
||||
|
||||
def __init__(self):
|
||||
@ -12,6 +14,8 @@ class CGITest(AEServer, MiniApplication):
|
||||
self.installaehandler('aevt', 'oapp', self.open_app)
|
||||
self.installaehandler('aevt', 'quit', self.quit)
|
||||
self.installaehandler('WWW\275', 'sdoc', self.cgihandler)
|
||||
if debug:
|
||||
self.installaehandler('****', '****', self.otherhandler)
|
||||
oldparams = MacOS.SchedParams(0, 0)
|
||||
self.mainloop()
|
||||
apply(MacOS.SchedParams, oldparams)
|
||||
@ -21,8 +25,15 @@ class CGITest(AEServer, MiniApplication):
|
||||
|
||||
def open_app(self, **args):
|
||||
pass
|
||||
|
||||
|
||||
def otherhandler(self, *args, **kwargs):
|
||||
print 'Unknown AppleEvent'
|
||||
print 'args', args
|
||||
print 'kwargs', kwargs
|
||||
|
||||
def cgihandler(self, pathargs, **args):
|
||||
if debug:
|
||||
print 'CGI request', pathargs, args
|
||||
rv = """HTTP/1.0 200 OK
|
||||
Server: Unknown; python-cgi-script
|
||||
MIME-Version: 1.0
|
||||
|
@ -20,7 +20,7 @@ ITEM_QUIT_BUTTON=4
|
||||
def main():
|
||||
"""Main routine: open resource file, call dialog handler"""
|
||||
try:
|
||||
Res.OpenResFile("dnslookup-1.rsrc")
|
||||
Res.FSpOpenResFile("dnslookup-1.rsrc", 1)
|
||||
except Res.Error:
|
||||
EasyDialogs.Message("Cannot open dnslookup-1.rsrc")
|
||||
sys.exit(1)
|
||||
|
Binary file not shown.
@ -19,7 +19,7 @@ def main():
|
||||
dummy = Res.GetResource('DLOG', ID_MAIN)
|
||||
except Res.Error:
|
||||
try:
|
||||
Res.OpenResFile("dnslookup-2.rsrc")
|
||||
Res.FSpOpenResFile("dnslookup-2.rsrc", 1)
|
||||
except Res.Error:
|
||||
EasyDialogs.Message("Cannot open dnslookup-2.rsrc")
|
||||
sys.exit(1)
|
||||
|
Binary file not shown.
@ -72,7 +72,7 @@ class WasteWindow(ScrolledWindow):
|
||||
return None, None
|
||||
oldrf = Res.CurResFile()
|
||||
try:
|
||||
rf = Res.OpenResFile(self.path)
|
||||
rf = Res.FSpOpenResFile(self.path, 1)
|
||||
except Res.Error:
|
||||
return None, None
|
||||
try:
|
||||
@ -241,10 +241,10 @@ class WasteWindow(ScrolledWindow):
|
||||
#
|
||||
oldresfile = Res.CurResFile()
|
||||
try:
|
||||
rf = Res.OpenResFile(self.path)
|
||||
rf = Res.FSpOpenResFile(self.path, 3)
|
||||
except Res.Error:
|
||||
Res.CreateResFile(self.path)
|
||||
rf = Res.OpenResFile(self.path)
|
||||
rf = Res.FSpOpenResFile(self.path, 3)
|
||||
styles = Res.Resource('')
|
||||
soup = Res.Resource('')
|
||||
self.ted.WECopyRange(0, 0x3fffffff, None, styles, soup)
|
||||
|
@ -59,7 +59,7 @@ class WasteWindow(ScrolledWindow):
|
||||
return None, None
|
||||
oldrf = Res.CurResFile()
|
||||
try:
|
||||
rf = Res.OpenResFile(self.path)
|
||||
rf = Res.FSpOpenResFile(self.path, 1)
|
||||
except Res.Error:
|
||||
return None, None
|
||||
try:
|
||||
@ -210,10 +210,10 @@ class WasteWindow(ScrolledWindow):
|
||||
#
|
||||
oldresfile = Res.CurResFile()
|
||||
try:
|
||||
rf = Res.OpenResFile(self.path)
|
||||
rf = Res.FSpOpenResFile(self.path, 3)
|
||||
except Res.Error:
|
||||
Res.CreateResFile(self.path)
|
||||
rf = Res.OpenResFile(self.path)
|
||||
rf = Res.FSpOpenResFile(self.path, 3)
|
||||
styles = Res.Resource('')
|
||||
soup = Res.Resource('')
|
||||
self.ted.WECopyRange(0, 0x3fffffff, None, styles, soup)
|
||||
|
Loading…
Reference in New Issue
Block a user