Commit e3ca02a2 authored by Barry Warsaw's avatar Barry Warsaw

Error message goes to stderr

canceled() takes an optional flag so that the canceled flag can be
cleared.
parent 57610ff2
...@@ -12,6 +12,7 @@ conform to the following interface: ...@@ -12,6 +12,7 @@ conform to the following interface:
since this would cause it to get updated twice. since this would cause it to get updated twice.
""" """
import sys
from types import DictType from types import DictType
import marshal import marshal
...@@ -33,7 +34,9 @@ class Switchboard: ...@@ -33,7 +34,9 @@ class Switchboard:
fp = open(initfile) fp = open(initfile)
self.__optiondb = marshal.load(fp) self.__optiondb = marshal.load(fp)
if type(self.__optiondb) <> DictType: if type(self.__optiondb) <> DictType:
print 'Problem reading options from file:', initfile sys.stderr.write(
'Problem reading options from file: %s\n' %
initfile)
self.__optiondb = {} self.__optiondb = {}
except (IOError, EOFError): except (IOError, EOFError):
pass pass
...@@ -76,7 +79,8 @@ class Switchboard: ...@@ -76,7 +79,8 @@ class Switchboard:
try: try:
fp = open(self.__initfile, 'w') fp = open(self.__initfile, 'w')
except IOError: except IOError:
print 'Cannot write options to file:', file sys.stderr.write('Cannot write options to file: %s\n' %
self.__initfile)
else: else:
marshal.dump(self.__optiondb, fp) marshal.dump(self.__optiondb, fp)
finally: finally:
...@@ -88,8 +92,8 @@ class Switchboard: ...@@ -88,8 +92,8 @@ class Switchboard:
if hasattr(v, 'withdraw'): if hasattr(v, 'withdraw'):
v.withdraw() v.withdraw()
def canceled(self): def canceled(self, flag=1):
self.__canceled = 1 self.__canceled = flag
def canceled_p(self): def canceled_p(self):
return self.__canceled return self.__canceled
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment