rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
e.grid(row=self.row, col=1, sticky="nwe")
e.grid(row=self.row, column=1, sticky="nwe")
def make_entry(self, label, var): l = Label(self.top, text=label) l.grid(row=self.row, col=0, sticky="nw") e = Entry(self.top, textvariable=var, exportselection=0) e.grid(row=self.row, col=1, sticky="nwe") self.row = self.row + 1 return e
l.grid(row=self.row, col=0, sticky="nw")
l.grid(row=self.row, column=0, sticky="nw")
def make_frame(self,labeltext=None): if labeltext: l = Label(self.top, text=labeltext) l.grid(row=self.row, col=0, sticky="nw") f = Frame(self.top) f.grid(row=self.row, col=1, columnspan=1, sticky="nwe") self.row = self.row + 1 return f
f.grid(row=self.row, col=1, columnspan=1, sticky="nwe")
f.grid(row=self.row, column=1, columnspan=1, sticky="nwe")
def make_frame(self,labeltext=None): if labeltext: l = Label(self.top, text=labeltext) l.grid(row=self.row, col=0, sticky="nw") f = Frame(self.top) f.grid(row=self.row, col=1, columnspan=1, sticky="nwe") self.row = self.row + 1 return f
f.grid(row=0,col=2,padx=2,pady=2,ipadx=2,ipady=2)
f.grid(row=0,column=2,padx=2,pady=2,ipadx=2,ipady=2)
def create_command_buttons(self): # # place button frame on the right f = self.buttonframe = Frame(self.top) f.grid(row=0,col=2,padx=2,pady=2,ipadx=2,ipady=2)
thishost = socket.getfqdn() try: if os.environ.has_key('LOGNAME'): realuser = os.environ['LOGNAME'] elif os.environ.has_key('USER'): realuser = os.environ['USER'] else: realuser = 'anonymous' except AttributeError: realuser = 'anonymous' passwd = passwd + realuser + '@' + thishost
passwd = passwd + 'anonymous@'
def login(self, user = '', passwd = '', acct = ''): '''Login, default anonymous.''' if not user: user = 'anonymous' if not passwd: passwd = '' if not acct: acct = '' if user == 'anonymous' and passwd in ('', '-'): # get fully qualified domain name of local host thishost = socket.getfqdn() try: if os.environ.has_key('LO...
self.announce('Building RPMs') rpm_args = ['rpm',]
self.announce('building RPMs') rpm_cmd = ['rpm']
def run (self):
rpm_args.append('-bs')
rpm_cmd.append('-bs')
def run (self):
rpm_args.append('-bb')
rpm_cmd.append('-bb')
def run (self):
rpm_args.append('-ba')
rpm_cmd.append('-ba')
def run (self):
rpm_args.extend(['--define',
rpm_cmd.extend(['--define',
def run (self):
rpm_args.append('--clean') rpm_args.append(spec_path) self.spawn(rpm_args)
rpm_cmd.append('--clean') rpm_cmd.append(spec_path) self.spawn(rpm_cmd)
def run (self):
def_build = 'env CFLAGS="$RPM_OPT_FLAGS" python setup.py build' else: def_build = 'python setup.py build'
def_build = 'env CFLAGS="$RPM_OPT_FLAGS" ' + def_build
def _make_spec_file(self): """Generate the text of an RPM spec file and return it as a list of strings (one per line). """ # definitions and headers spec_file = [ '%define name ' + self.distribution.get_name(), '%define version ' + self.distribution.get_version(), '%define release ' + self.release, '', 'Summary: ' + se...
"python setup.py install " "--root=$RPM_BUILD_ROOT " "--record=INSTALLED_FILES"),
("%s setup.py install " "--root=$RPM_BUILD_ROOT " "--record=INSTALLED_FILES") % self.python),
def _make_spec_file(self): """Generate the text of an RPM spec file and return it as a list of strings (one per line). """ # definitions and headers spec_file = [ '%define name ' + self.distribution.get_name(), '%define version ' + self.distribution.get_version(), '%define release ' + self.release, '', 'Summary: ' + se...
if (os.path.exists('Modules/_curses_panel.c') and module_enabled(exts, '_curses') and
if (module_enabled(exts, '_curses') and
def detect_modules(self): # Ensure that /usr/local is always used if '/usr/local/lib' not in self.compiler.library_dirs: self.compiler.library_dirs.insert(0, '/usr/local/lib') if '/usr/local/include' not in self.compiler.include_dirs: self.compiler.include_dirs.insert(0, '/usr/local/include' )
otherwise return - (the signal that killed it). """
otherwise return -SIG, where SIG is the signal that killed it. """
def spawnv(mode, file, args): """spawnv(mode, file, args) -> integer
self.assertRaises(TypeError, u'hello'.count, 42)
self.assertRaises(TypeError, u'hello'.title, 42)
def test_title(self): self.checkmethod('title', u' hello ', u' Hello ') self.checkmethod('title', u'Hello ', u'Hello ') self.checkmethod('title', u'hello ', u'Hello ') self.checkmethod('title', u"fOrMaT thIs aS titLe String", u'Format This As Title String') self.checkmethod('title', u"fOrMaT,thIs-aS*titLe;String", u'Fo...
def writelines(self, list): self.write(''.join(list))
def writelines(self, iterable): write = self.write for line in iterable: write(line)
def writelines(self, list): self.write(''.join(list))
if sys.platform == 'win32': reuse_constant = socket.SO_EXCLUSIVEADDRUSE else: reuse_constant = socket.SO_REUSEADDR
def set_reuse_addr(self): # try to re-use a server port if possible try: # Windows SO_REUSEADDR is very broken (from a unixy perspective) if sys.platform == 'win32': reuse_constant = socket.SO_EXCLUSIVEADDRUSE else: reuse_constant = socket.SO_REUSEADDR
socket.SOL_SOCKET, reuse_constant,
socket.SOL_SOCKET, socket.SO_REUSEADDR,
def set_reuse_addr(self): # try to re-use a server port if possible try: # Windows SO_REUSEADDR is very broken (from a unixy perspective) if sys.platform == 'win32': reuse_constant = socket.SO_EXCLUSIVEADDRUSE else: reuse_constant = socket.SO_REUSEADDR
reuse_constant) | 1
socket.SO_REUSEADDR) | 1
def set_reuse_addr(self): # try to re-use a server port if possible try: # Windows SO_REUSEADDR is very broken (from a unixy perspective) if sys.platform == 'win32': reuse_constant = socket.SO_EXCLUSIVEADDRUSE else: reuse_constant = socket.SO_REUSEADDR
global DEBUG
def poll (timeout=0.0, map=None): global DEBUG if map is None: map = socket_map if map: r = []; w = []; e = [] for fd, obj in map.items(): if obj.readable(): r.append (fd) if obj.writable(): w.append (fd) r,w,e = select.select (r,w,e, timeout) if DEBUG: print r,w,e for fd in r: try: obj = map[fd] except KeyError: con...
r,w,e = select.select (r,w,e, timeout)
try: r,w,e = select.select (r,w,e, timeout) except select.error, err: if err[0] != EINTR: raise
def poll (timeout=0.0, map=None): global DEBUG if map is None: map = socket_map if map: r = []; w = []; e = [] for fd, obj in map.items(): if obj.readable(): r.append (fd) if obj.writable(): w.append (fd) r,w,e = select.select (r,w,e, timeout) if DEBUG: print r,w,e for fd in r: try: obj = map[fd] except KeyError: con...
r = pollster.poll (timeout)
try: r = pollster.poll (timeout) except select.error, err: if err[0] != EINTR: raise r = []
def poll3 (timeout=0.0, map=None): # Use the poll() support added to the select module in Python 2.0 if map is None: map=socket_map if timeout is not None: # timeout is in milliseconds timeout = int(timeout*1000) pollster = select.poll() if map: for fd, obj in map.items(): flags = 0 if obj.readable(): flags = select.PO...
self.__dict__['socket'] = sock
self.socket = sock
def set_socket (self, sock, map=None): self.__dict__['socket'] = sock self._fileno = sock.fileno() self.add_channel (map)
if os.environ.has_key('CFLAGS'): extra_args.extend(string.split(os.environ['CFLAGS']))
for undef in ext.undef_macros: macros.append((undef,))
print testtar
def path(path): return test_support.findfile(path)
state = [kThemeStateActive, kThemeStateInactive][not onoff] App.DrawThemeListBoxFrame(Qd.InsetRect(self._bounds, 1, 1), state)
def activate(self, onoff): self._activated = onoff if self._visible: self._list.LActivate(onoff) state = [kThemeStateActive, kThemeStateInactive][not onoff] App.DrawThemeListBoxFrame(Qd.InsetRect(self._bounds, 1, 1), state) if self._selected: self.drawselframe(onoff)
if (not check_intermediate) or len(plist) < 2:
if not check_intermediate:
def __init__(self, master, name, destroy_physically=1, check_intermediate=1): if check_intermediate: path = master._subwidget_name(name) try: path = path[len(master._w)+1:] plist = path.split('.') except: plist = []
self.file = self.make_file('')
self.file = self.__file = StringIO()
def read_lines(self): """Internal: read lines until EOF or outerboundary.""" self.file = self.make_file('') if self.outerboundary: self.read_lines_to_outerboundary() else: self.read_lines_to_eof()
self.file.write(line)
self.__write(line)
def read_lines_to_eof(self): """Internal: read lines until EOF.""" while 1: line = self.fp.readline() if not line: self.done = -1 break self.file.write(line)
self.file.write(odelim + line)
self.__write(odelim + line)
def read_lines_to_outerboundary(self): """Internal: read lines until outerboundary.""" next = "--" + self.outerboundary last = next + "--" delim = "" while 1: line = self.fp.readline() if not line: self.done = -1 break if line[:2] == "--": strippedline = line.strip() if strippedline == next: break if strippedline == la...
result = self.__class__([])
result = self.__class__()
def copy(self): """Return a shallow copy of a set.""" result = self.__class__([]) result._data.update(self._data) return result
result = self.__class__([])
result = self.__class__()
def __deepcopy__(self, memo): """Return a deep copy of a set; used by copy module.""" # This pre-creates the result and inserts it in the memo # early, in case the deep copy recurses into another reference # to this same set. A set can't be an element of itself, but # it can certainly contain an object that has a refe...
result = self.__class__([])
result = self.__class__()
def __and__(self, other): """Return the intersection of two sets as a new set.
result = self.__class__([])
result = self.__class__()
def __xor__(self, other): """Return the symmetric difference of two sets as a new set.
result = self.__class__([])
result = self.__class__()
def __sub__(self, other): """Return the difference of two sets as a new Set.
class _TemporarilyImmutableSet(object):
class _TemporarilyImmutableSet(BaseSet):
def _as_temporarily_immutable(self): # Return self wrapped in a temporarily immutable set return _TemporarilyImmutableSet(self)
def __eq__(self, other): return self._set == other def __ne__(self, other): return self._set != other def _test(): red = Set() assert `red` == "Set([])", "Empty set: %s" % `red` green = Set((0,)) assert `green` == "Set([0])", "Unit set: %s" % `green` blue = Set([0, 1, 2]) assert blue._repr(True) == "Set([0, ...
def __hash__(self): if self._hashcode is None: self._hashcode = self._set._compute_hash() return self._hashcode
if n > self.maxlist: s = s + ', ...'
if n > self.maxdict: s = s + ', ...'
def repr_dictionary(self, x, level): n = len(x) if n == 0: return '{}' if level <= 0: return '{...}' s = '' keys = x.keys() keys.sort() for i in range(min(n, self.maxdict)): if s: s = s + ', ' key = keys[i] s = s + self.repr1(key, level-1) s = s + ': ' + self.repr1(x[key], level-1) if n > self.maxlist: s = s + ', ...' ...
for option in options: yield (option, d[option])
return [(option, d[option]) for option in options]
def items(self, section, raw=False, vars=None): """Return a list of tuples with (name, value) for each option in the section.
for option in options: yield (option, self._interpolate(section, option, d[option], d))
return [(option, self._interpolate(section, option, d[option], d)) for option in options]
def items(self, section, raw=False, vars=None): """Return a list of tuples with (name, value) for each option in the section.
testtype('u', u'\u263a')
def main(): testtype('c', 'c') for type in (['b', 'h', 'i', 'l', 'f', 'd']): testtype(type, 1) unlink(TESTFN)
testunicode() testsubclassing()
def main(): testtype('c', 'c') for type in (['b', 'h', 'i', 'l', 'f', 'd']): testtype(type, 1) unlink(TESTFN)
def seek(self): raise IOError, 'Random access not allowed in gzip files' def tell(self): raise IOError, 'I won\'t tell() you for gzip files'
def flush(self): self.fileobj.flush()
import string PATH = string.splitfields(envpath, pathsep)
PATH = envpath.split(pathsep)
def _execvpe(file, args, env=None): if env is not None: func = execve argrest = (args, env) else: func = execv argrest = (args,) env = environ global _notfound head, tail = path.split(file) if head: apply(func, (file,) + argrest) return if env.has_key('PATH'): envpath = env['PATH'] else: envpath = defpath import string...
import string
def _execvpe(file, args, env=None): if env is not None: func = execve argrest = (args, env) else: func = execv argrest = (args,) env = environ global _notfound head, tail = path.split(file) if head: apply(func, (file,) + argrest) return if env.has_key('PATH'): envpath = env['PATH'] else: envpath = defpath import string...
upper = string.upper
def __init__(self, environ): UserDict.UserDict.__init__(self) data = self.data upper = string.upper for k, v in environ.items(): data[upper(k)] = v
data[upper(k)] = v
data[k.upper()] = v
def __init__(self, environ): UserDict.UserDict.__init__(self) data = self.data upper = string.upper for k, v in environ.items(): data[upper(k)] = v
key = string.upper(key) self.data[key] = item
self.data[key.upper()] = item
def __setitem__(self, key, item): putenv(key, item) key = string.upper(key) self.data[key] = item
return self.data[string.upper(key)]
return self.data[key.upper()] def __delitem__(self, key): del self.data[key.upper()]
def __getitem__(self, key): return self.data[string.upper(key)]
return self.data.has_key(string.upper(key))
return self.data.has_key(key.upper()) def get(self, key, failobj=None): return self.data.get(key.upper(), failobj) def update(self, dict): for k, v in dict.items(): self[k] = v
def has_key(self, key): return self.data.has_key(string.upper(key))
self.tk.call(self._w, 'select', 'item')
return self.tk.call(self._w, 'select', 'item') or None
def select_item(self): """Return the item which has the selection.""" self.tk.call(self._w, 'select', 'item')
def wm_state(self): """Return the state of this widget as one of normal, icon, iconic (see wm_iconwindow) and withdrawn.""" return self.tk.call('wm', 'state', self._w)
def wm_state(self, newstate=None): """Query or set the state of this widget as one of normal, icon, iconic (see wm_iconwindow), withdrawn, or zoomed (Windows only).""" return self.tk.call('wm', 'state', self._w, newstate)
def wm_state(self): """Return the state of this widget as one of normal, icon, iconic (see wm_iconwindow) and withdrawn.""" return self.tk.call('wm', 'state', self._w)
self.assertEquals(ef.read(), '\xff\xfe\\\xd5\n\x00\x00\xae')
self.assertEquals(ef.read(), '\\\xd5\n\x00\x00\xae')
def test_basic(self): f = StringIO.StringIO('\xed\x95\x9c\n\xea\xb8\x80') ef = codecs.EncodedFile(f, 'utf-16-le', 'utf-8') self.assertEquals(ef.read(), '\xff\xfe\\\xd5\n\x00\x00\xae')
err('usage: classfix file-or-directory ...\n')
err('usage: ' + argv[0] + ' file-or-directory ...\n')
def main(): bad = 0 if not sys.argv[1:]: # No arguments err('usage: classfix file-or-directory ...\n') sys.exit(2) for arg in sys.argv[1:]: if path.isdir(arg): if recursedown(arg): bad = 1 elif path.islink(arg): err(arg + ': will not process symbolic links\n') bad = 1 else: if fix(arg): bad = 1 sys.exit(bad)
ispython = regexp.compile('^[a-zA-Z0-9_]+\.py$').match
ispythonprog = regex.compile('^[a-zA-Z0-9_]+\.py$') def ispython(name): return ispythonprog.match(name) >= 0
def main(): bad = 0 if not sys.argv[1:]: # No arguments err('usage: classfix file-or-directory ...\n') sys.exit(2) for arg in sys.argv[1:]: if path.isdir(arg): if recursedown(arg): bad = 1 elif path.islink(arg): err(arg + ': will not process symbolic links\n') bad = 1 else: if fix(arg): bad = 1 sys.exit(bad)
if recursedown(fullname): bad = 1
subdirs.append(fullname)
def recursedown(dirname): dbg('recursedown(' + `dirname` + ')\n') bad = 0 try: names = posix.listdir(dirname) except posix.error, msg: err(dirname + ': cannot list directory: ' + `msg` + '\n') return 1 for name in names: if name in ('.', '..'): continue fullname = path.join(dirname, name) if path.islink(fullname): pass...
classexpr = '^([ \t]*class +[a-zA-Z0-9_]+) *\( *\) *((=.*)?):' findclass = regexp.compile(classexpr).match baseexpr = '^ *(.*) *\( *\) *$' findbase = regexp.compile(baseexpr).match
def recursedown(dirname): dbg('recursedown(' + `dirname` + ')\n') bad = 0 try: names = posix.listdir(dirname) except posix.error, msg: err(dirname + ': cannot list directory: ' + `msg` + '\n') return 1 for name in names: if name in ('.', '..'): continue fullname = path.join(dirname, name) if path.islink(fullname): pass...
dbg('fix(' + `filename` + ')\n')
def fix(filename):
tf = None
g = None
def fix(filename):
res = findclass(line) if not res: if tf: tf.write(line) continue if not tf: try: tf = open(tempname, 'w') except IOError, msg: f.close() err(tempname+': cannot create: '+`msg`+'\n') return 1 rep(filename + ':\n') f.seek(0) continue a0, b0 = res[0] a1, b1 = res[1] a2, b2 = res[2] head = line[:b1] tail = line[b0:] if a2...
lineno = lineno + 1 while line[-2:] == '\\\n': nextline = f.readline() if not nextline: break line = line + nextline lineno = lineno + 1 newline = fixline(line) if newline != line: if g is None: try: g = open(tempname, 'w') except IOError, msg: f.close() err(tempname+': cannot create: '+\ `msg`+'\n') return 1 f.seek(0)...
def fix(filename):
if not tf: return 0
if not g: return 0
def fix(filename):
exts.append( Extension('pwd', ['pwdmodule.c']) ) exts.append( Extension('grp', ['grpmodule.c']) )
if platform not in ['mac']: exts.append( Extension('pwd', ['pwdmodule.c']) ) exts.append( Extension('grp', ['grpmodule.c']) )
def detect_modules(self): # Ensure that /usr/local is always used add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
if platform not in ['atheos']:
if platform not in ['atheos', 'mac']:
def detect_modules(self): # Ensure that /usr/local is always used add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
exts.append( Extension('syslog', ['syslogmodule.c']) )
if platform not in ['mac']: exts.append( Extension('syslog', ['syslogmodule.c']) )
def detect_modules(self): # Ensure that /usr/local is always used add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
if self.compiler.find_library_file(lib_dirs, 'crypt'): libs = ['crypt'] else: libs = [] exts.append( Extension('crypt', ['cryptmodule.c'], libraries=libs) )
if platform not in ['mac']: if self.compiler.find_library_file(lib_dirs, 'crypt'): libs = ['crypt'] else: libs = [] exts.append( Extension('crypt', ['cryptmodule.c'], libraries=libs) )
def detect_modules(self): # Ensure that /usr/local is always used add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
if platform not in ['cygwin']:
if platform not in ['cygwin', 'mac']:
def detect_modules(self): # Ensure that /usr/local is always used add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
filename = EasyDialogs.AskFileForOpen(message='Select file with aeut/aete resource:')
filename = EasyDialogs.AskFileForOpen( message='Select scriptable application', dialogOptionFlags=0x1056)
def main(): if len(sys.argv) > 1: for filename in sys.argv[1:]: processfile(filename) else: filename = EasyDialogs.AskFileForOpen(message='Select file with aeut/aete resource:') if not filename: sys.exit(0) processfile(filename)
processfile(filename) def processfile(fullname):
try: processfile(filename) except MacOS.Error, arg: print "Error getting terminology:", arg print "Retry, manually parsing resources" processfile_fromresource(filename) def processfile_fromresource(fullname):
def main(): if len(sys.argv) > 1: for filename in sys.argv[1:]: processfile(filename) else: filename = EasyDialogs.AskFileForOpen(message='Select file with aeut/aete resource:') if not filename: sys.exit(0) processfile(filename)
defaultLocation=DEFAULT_PACKAGEFOLDER)
defaultLocation=DEFAULT_USER_PACKAGEFOLDER)
def compileaete(aete, resinfo, fname): """Generate code for a full aete resource. fname passed for doc purposes""" [version, language, script, suites] = aete major, minor = divmod(version, 256) creatorsignature, dummy = MacOS.GetCreatorAndType(fname) packagename = identify(os.path.splitext(os.path.basename(fname))[0]) ...
defaultLocation=DEFAULT_PACKAGEFOLDER)
defaultLocation=DEFAULT_STANDARD_PACKAGEFOLDER)
def compileaete(aete, resinfo, fname): """Generate code for a full aete resource. fname passed for doc purposes""" [version, language, script, suites] = aete major, minor = divmod(version, 256) creatorsignature, dummy = MacOS.GetCreatorAndType(fname) packagename = identify(os.path.splitext(os.path.basename(fname))[0]) ...
print identify('for')
def identify(str): """Turn any string into an identifier: - replace space by _ - replace other illegal chars by _xx_ (hex code) - prepend _ if the result is a python keyword """ if not str: return "empty_ae_name_" rv = '' ok = string.ascii_letters + '_' ok2 = ok + string.digits for c in str: if c in ok: rv = rv + c eli...
class TestMultipartMixed(unittest.TestCase):
class TestMultipartMixed(TestEmailBase):
def test_charset(self): eq = self.assertEqual msg = MIMEText('hello there', _charset='us-ascii') eq(msg.get_charset().input_charset, 'us-ascii') eq(msg['content-type'], 'text/plain; charset="us-ascii"')
By default, smtplib.SMTP_PORT is used.
By default, smtplib.SMTP_PORT is used. An SMTPConnectError is raised if the specified `host' doesn't respond correctly.
def __init__(self, host = '', port = 0): """Initialize a new instance.
if host: self.connect(host, port)
if host: (code, msg) = self.connect(host, port) if code != 220: raise SMTPConnectError(code, msg)
def __init__(self, host = '', port = 0): """Initialize a new instance.
return msg
return (code,msg)
def connect(self, host='localhost', port = 0): """Connect to a host on a given port.
(code,msg)=self.getreply() return code
return self.getreply()
def docmd(self, cmd, args=""): """Send a command, and return its response code.""" self.putcmd(cmd,args) (code,msg)=self.getreply() return code
return code
return (code,msg)
def helo(self, name=''): """SMTP 'helo' command. Hostname to send for this command defaults to the FQDN of the local host. """ name=string.strip(name) if len(name)==0: name=socket.gethostbyaddr(socket.gethostname())[0] self.putcmd("helo",name) (code,msg)=self.getreply() self.helo_resp=msg return code
return code
return (code,msg)
def ehlo(self, name=''): """ SMTP 'ehlo' command. Hostname to send for this command defaults to the FQDN of the local host. """ name=string.strip(name) if len(name)==0: name=socket.gethostbyaddr(socket.gethostname())[0] self.putcmd("ehlo",name) (code,msg)=self.getreply() # According to RFC1869 some (badly written) # MT...
(code,msg)=self.getreply() return msg
return self.getreply()
def help(self, args=''): """SMTP 'help' command. Returns help text from server.""" self.putcmd("help", args) (code,msg)=self.getreply() return msg
code=self.docmd("rset") return code
return self.docmd("rset")
def rset(self): """SMTP 'rset' command -- resets session.""" code=self.docmd("rset") return code
code=self.docmd("noop") return code
return self.docmd("noop")
def noop(self): """SMTP 'noop' command -- doesn't do anything :>""" code=self.docmd("noop") return code
return -1
raise SMTPDataError(code,repl)
def data(self,msg): """SMTP 'DATA' command -- sends message data to server. Automatically quotes lines beginning with a period per rfc821. """ self.putcmd("data") (code,repl)=self.getreply() if self.debuglevel >0 : print "data:", (code,repl) if code <> 354: return -1 else: self.send(quotedata(msg)) self.send("%s.%s" % ...
return code
return (code,msg)
def data(self,msg): """SMTP 'DATA' command -- sends message data to server. Automatically quotes lines beginning with a period per rfc821. """ self.putcmd("data") (code,repl)=self.getreply() if self.debuglevel >0 : print "data:", (code,repl) if code <> 354: return -1 else: self.send(quotedata(msg)) self.send("%s.%s" % ...
one recipient. Otherwise it will throw an exception (either SMTPSenderRefused, SMTPRecipientsRefused, or SMTPDataError) That is, if this method does not throw an exception, then someone should get your mail. If this method does not throw an exception, it returns a dictionary, with one entry for each recipient that wa...
one recipient. It returns a dictionary, with one entry for each recipient that was refused. Each entry contains a tuple of the SMTP error code and the accompanying error message sent by the server. This method may raise the following exceptions: SMTPHeloError The server didn't reply properly to the helo gre...
def sendmail(self, from_addr, to_addrs, msg, mail_options=[], rcpt_options=[]): """This command performs an entire mail transaction.
if not self.helo_resp and not self.ehlo_resp: if self.ehlo() >= 400: self.helo()
if self.helo_resp is None and self.ehlo_resp is None: if not (200 <= self.ehlo()[0] <= 299): (code,resp) = self.helo() if not (200 <= code <= 299): raise SMTPHeloError(code, resp)
def sendmail(self, from_addr, to_addrs, msg, mail_options=[], rcpt_options=[]): """This command performs an entire mail transaction.
raise SMTPSenderRefused('%s: %s' % (from_addr, resp))
raise SMTPSenderRefused(code, resp, from_addr)
def sendmail(self, from_addr, to_addrs, msg, mail_options=[], rcpt_options=[]): """This command performs an entire mail transaction.
raise SMTPRecipientsRefused(string.join( map(lambda x:"%s: %s" % (x[0], x[1][1]), senderrs.items()), '; ')) code=self.data(msg) if code <>250 :
raise SMTPRecipientsRefused(senderrs) (code,resp)=self.data(msg) if code <> 250:
def sendmail(self, from_addr, to_addrs, msg, mail_options=[], rcpt_options=[]): """This command performs an entire mail transaction.
raise SMTPDataError('data transmission error: %s' % code)
raise SMTPDataError(code, resp)
def sendmail(self, from_addr, to_addrs, msg, mail_options=[], rcpt_options=[]): """This command performs an entire mail transaction.
"Test MCRYPT type miscelaneous methods."
"Test BZ2File type miscellaneous methods."
def decompress(self, data): return bz2.decompress(data)
raise norm_error, 'Cannot use :: immedeately after volume name'
raise norm_error, 'Cannot use :: immediately after volume name'
def normpath(s): """Normalize a pathname. Will return the same result for equivalent paths.""" if ":" not in s: return ":"+s comps = s.split(":") i = 1 while i < len(comps)-1: if comps[i] == "" and comps[i-1] != "": if i > 1: del comps[i-1:i+1] i = i - 1 else: # best way to handle this is to raise an exception raise...
self.passiveserver = 0
def connect(self, host = '', port = 0): '''Connect to host. Arguments are: - host: hostname to connect to (string, default previous host) - port: port to connect to (integer, default previous port)''' if host: self.host = host if port: self.port = port self.passiveserver = 0 msg = "getaddrinfo returns an empty list" f...
try: obj.handle_read_event() except ExitNow: raise ExitNow except: obj.handle_error()
def poll (timeout=0.0, map=None): global DEBUG if map is None: map = socket_map if map: r = []; w = []; e = [] for fd, obj in map.items(): if obj.readable(): r.append (fd) if obj.writable(): w.append (fd) r,w,e = select.select (r,w,e, timeout) if DEBUG: print r,w,e for fd in r: try: obj = map[fd] try: obj.handle_read...
pass
continue try: obj.handle_read_event() except ExitNow: raise ExitNow except: obj.handle_error()
def poll (timeout=0.0, map=None): global DEBUG if map is None: map = socket_map if map: r = []; w = []; e = [] for fd, obj in map.items(): if obj.readable(): r.append (fd) if obj.writable(): w.append (fd) r,w,e = select.select (r,w,e, timeout) if DEBUG: print r,w,e for fd in r: try: obj = map[fd] try: obj.handle_read...
try: obj.handle_write_event() except ExitNow: raise ExitNow except: obj.handle_error()
def poll (timeout=0.0, map=None): global DEBUG if map is None: map = socket_map if map: r = []; w = []; e = [] for fd, obj in map.items(): if obj.readable(): r.append (fd) if obj.writable(): w.append (fd) r,w,e = select.select (r,w,e, timeout) if DEBUG: print r,w,e for fd in r: try: obj = map[fd] try: obj.handle_read...
pass
continue try: obj.handle_write_event() except ExitNow: raise ExitNow except: obj.handle_error()
def poll (timeout=0.0, map=None): global DEBUG if map is None: map = socket_map if map: r = []; w = []; e = [] for fd, obj in map.items(): if obj.readable(): r.append (fd) if obj.writable(): w.append (fd) r,w,e = select.select (r,w,e, timeout) if DEBUG: print r,w,e for fd in r: try: obj = map[fd] try: obj.handle_read...
try: if (flags & poll.POLLIN): obj.handle_read_event() if (flags & poll.POLLOUT): obj.handle_write_event() except ExitNow: raise ExitNow except: obj.handle_error()
def poll2 (timeout=0.0, map=None): import poll if map is None: map=socket_map if timeout is not None: # timeout is in milliseconds timeout = int(timeout*1000) if map: l = [] for fd, obj in map.items(): flags = 0 if obj.readable(): flags = poll.POLLIN if obj.writable(): flags = flags | poll.POLLOUT if flags: l.append ((...
pass
continue try: if (flags & poll.POLLIN): obj.handle_read_event() if (flags & poll.POLLOUT): obj.handle_write_event() except ExitNow: raise ExitNow except: obj.handle_error()
def poll2 (timeout=0.0, map=None): import poll if map is None: map=socket_map if timeout is not None: # timeout is in milliseconds timeout = int(timeout*1000) if map: l = [] for fd, obj in map.items(): flags = 0 if obj.readable(): flags = poll.POLLIN if obj.writable(): flags = flags | poll.POLLOUT if flags: l.append ((...
try: if (flags & select.POLLIN): obj.handle_read_event() if (flags & select.POLLOUT): obj.handle_write_event() except ExitNow: raise ExitNow except: obj.handle_error()
def poll3 (timeout=0.0, map=None): # Use the poll() support added to the select module in Python 2.0 if map is None: map=socket_map if timeout is not None: # timeout is in milliseconds timeout = int(timeout*1000) pollster = select.poll() if map: for fd, obj in map.items(): flags = 0 if obj.readable(): flags = select.PO...
pass
continue try: if (flags & select.POLLIN): obj.handle_read_event() if (flags & select.POLLOUT): obj.handle_write_event() except ExitNow: raise ExitNow except: obj.handle_error()
def poll3 (timeout=0.0, map=None): # Use the poll() support added to the select module in Python 2.0 if map is None: map=socket_map if timeout is not None: # timeout is in milliseconds timeout = int(timeout*1000) pollster = select.poll() if map: for fd, obj in map.items(): flags = 0 if obj.readable(): flags = select.PO...