rem
stringlengths
1
322k
add
stringlengths
0
2.05M
context
stringlengths
4
228k
meta
stringlengths
156
215
previous_shelve = bsddb.dbshelve.open(filename + '.previous')
previous_shelve = old_dbshelve.open(filename + '.previous')
def open_shelve(filename): from bsddb3 import db,dbshelve log.debug('Opening database ' + filename)
8a619583902822990a865e72dd837af6970244c5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7531/8a619583902822990a865e72dd837af6970244c5/apt_proxy.py
def __fake_stdout(self): import tempfile null = tempfile.TemporaryFile() self.real_stdout_fd = os.dup(sys.stdout.fileno()) os.dup2(null.fileno(), sys.stdout.fileno())
def __save_stdout(self): self.real_stdout_fd = os.dup(1) os.close(1)
def __fake_stdout(self): import tempfile null = tempfile.TemporaryFile() self.real_stdout_fd = os.dup(sys.stdout.fileno()) os.dup2(null.fileno(), sys.stdout.fileno())
e275dc5ac4f0188934ea8596e66b25c8395d0040 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7531/e275dc5ac4f0188934ea8596e66b25c8395d0040/packages.py
os.dup2(self.real_stdout_fd, sys.stdout.fileno())
os.dup2(self.real_stdout_fd, 1)
def __restore_stdout(self): os.dup2(self.real_stdout_fd, sys.stdout.fileno()) os.close(self.real_stdout_fd) del self.real_stdout_fd
e275dc5ac4f0188934ea8596e66b25c8395d0040 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7531/e275dc5ac4f0188934ea8596e66b25c8395d0040/packages.py
self.cache = apt_pkg.GetCache()
if log.isEnabled('apt'): self.cache = apt_pkg.GetCache() else: self.__save_stdout() self.cache = apt_pkg.GetCache() self.__restore_stdout()
def load(self): """ Regenerates the fake configuration and load the packages server. """ if not self.loaded: shutil.rmtree(self.status_dir+'/apt/lists/') os.makedirs(self.status_dir+'/apt/lists/partial') sources = open(self.status_dir+'/'+'apt/etc/sources.list', 'w') for file in self.packages.keys(): # we should probably clear old entries from self.packages and # take into account the recorded mtime as optimization fake_uri='http://apt-proxy:'+file source_line='deb '+dirname(fake_uri)+'/ /' listpath=(self.status_dir+'/apt/lists/' +apt_pkg.URItoFileName(fake_uri)) sources.write(source_line+'\n')
e275dc5ac4f0188934ea8596e66b25c8395d0040 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7531/e275dc5ac4f0188934ea8596e66b25c8395d0040/packages.py
"Tryes to make the packages server quit."
"Tries to make the packages server quit."
def unload(self): "Tryes to make the packages server quit." if self.loaded: del self.cache del self.records self.loaded = 0
e275dc5ac4f0188934ea8596e66b25c8395d0040 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7531/e275dc5ac4f0188934ea8596e66b25c8395d0040/packages.py
laterID = None file = None
def loseConnection(self): "Kill rsync process" if self.transport: if self.transport.pid: log.debug("killing rsync child" + str(self.transport.pid), 'rsync_client') os.kill(self.transport.pid, signal.SIGTERM) #self.transport.loseConnection()
d1edb4f2d936c29931d17ce8be7dd263a355beea /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7531/d1edb4f2d936c29931d17ce8be7dd263a355beea/apt_proxy.py
self.file = open(self.local_file,'rb') fcntl.lockf(self.file.fileno(), fcntl.LOCK_SH)
file = open(self.local_file,'rb') fcntl.lockf(file.fileno(), fcntl.LOCK_SH)
def activate(self, request): Fetcher.activate(self, request) if not request.apFetcher: return self.factory.file_served(request.uri)
d1edb4f2d936c29931d17ce8be7dd263a355beea /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7531/d1edb4f2d936c29931d17ce8be7dd263a355beea/apt_proxy.py
self.readBuffer() def readBuffer(self): self.laterID = None data = self.file.read(abstract.FileDescriptor.bufferSize) self.apDataReceived(data) if self.file.tell() == self.size: self.apDataReceived("") for req in self.requests: req.finish() self.apEnd() else: self.laterID = reactor.callLater(0, self.readBuffer) def apEnd(self): if self.laterID: self.laterID.cancel() if self.file: self.file.close() Fetcher.apEnd(self)
basic.FileSender().beginFileTransfer(file, self.request).addCallback(self.apEnd).addCallback(lambda r: file.close()) def apEnd(self, ignored=None): if len(self.requests) == 0: Fetcher.apEnd(self)
def activate(self, request): Fetcher.activate(self, request) if not request.apFetcher: return self.factory.file_served(request.uri)
d1edb4f2d936c29931d17ce8be7dd263a355beea /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7531/d1edb4f2d936c29931d17ce8be7dd263a355beea/apt_proxy.py
'serve_cached': this is somewhat of a hack only usefull for
'serve_cached': this is somewhat of a hack only useful for
def fetch(self, serve_cached=1): """ Serve 'self' from cache or through the appropriate Fetcher depending on the asociated backend. Use post_convert and gzip_convert regular expresions of the Fetcher to gzip/gunzip file before and after download. 'serve_cached': this is somewhat of a hack only usefull for LoopbackRequests (See LoopbackRequest class for more information). """ def fetch_real(result, dummyFetcher, cached, running): """ This is called after verifying if the file is properly cached. If 'cached' the requested file is properly cached. If not 'cached' the requested file was not there, didn't pass the integrity check or may be outdated. """ __pychecker__ = 'unusednames=result' if len(dummyFetcher.requests)==0: #The request's are gone, the clients probably closed the #conection log.debug("THE REQUESTS ARE GONE (Clients closed conection)", 'fetch') dummyFetcher.apEnd() return
d1edb4f2d936c29931d17ce8be7dd263a355beea /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7531/d1edb4f2d936c29931d17ce8be7dd263a355beea/apt_proxy.py
"If he wanted to know, tell dady that we are served."
"If he wanted to know, tell daddy that we are served."
def finish(self): "If he wanted to know, tell dady that we are served." if self.finish_cb: self.finish_cb() self.transport = None pass
d1edb4f2d936c29931d17ce8be7dd263a355beea /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7531/d1edb4f2d936c29931d17ce8be7dd263a355beea/apt_proxy.py
Each incomming request is passed to a new Request instance.
Each incoming request is passed to a new Request instance.
def finish(self): "If he wanted to know, tell dady that we are served." if self.finish_cb: self.finish_cb() self.transport = None pass
d1edb4f2d936c29931d17ce8be7dd263a355beea /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7531/d1edb4f2d936c29931d17ce8be7dd263a355beea/apt_proxy.py
"If the connection is lost, notify all my requets"
"If the connection is lost, notify all my requests"
def connectionLost(self, reason=None): "If the connection is lost, notify all my requets" __pychecker__ = 'unusednames=reason' for req in self.requests: req.connectionLost() log.debug("Client connection closed") if log.isEnabled('memleak'): memleak.print_top_10()
d1edb4f2d936c29931d17ce8be7dd263a355beea /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7531/d1edb4f2d936c29931d17ce8be7dd263a355beea/apt_proxy.py
if re.search('/../', self.uri):
if re.search('/\.\./', self.uri):
def process(self): """ Each new request begins processing here """ log.debug("Request: " + self.method + " " + self.uri); # Clean up URL self.uri = self.simplify_path(self.uri)
8acb0eecc1ede84253548c4dfe7596769ecd136e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7531/8acb0eecc1ede84253548c4dfe7596769ecd136e/apt_proxy.py
if (self.__class__ != FetcherFile or req.serve_if_cached):
if (fetcher_class != FetcherFile or req.serve_if_cached):
def apEndTransfer(self, fetcher_class): """ Remove this Fetcher and transfer all it's requests to a new instance of 'fetcher_class'. """ #Consider something like this: #req = dummyFetcher.fix_ref_request() #fetcher = fetcher_class() #dummyFetcher.transfer_requests(fetcher) #dummyFetcher.apEnd() #fetcher.activate(req)
ba3d8721d8b906b93d571d1233bb0567d59ea911 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7531/ba3d8721d8b906b93d571d1233bb0567d59ea911/apt_proxy.py
def activate(self, request):
def activate(self, request, postconverting=0):
def activate(self, request): Fetcher.activate(self, request) if not request.apFetcher: return
ba3d8721d8b906b93d571d1233bb0567d59ea911 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7531/ba3d8721d8b906b93d571d1233bb0567d59ea911/apt_proxy.py
loop = LoopbackRequest(request, self.host_transfer_done) loop.uri = host_uri loop.local_file = self.host_file loop.process() self.loop_req = loop loop.fetch(serve_cached=0)
running = self.factory.runningFetchers if not postconverting or running.has_key(self.host_file): loop = LoopbackRequest(request, self.host_transfer_done) loop.uri = host_uri loop.local_file = self.host_file loop.process() self.loop_req = loop loop.serve_if_cached=0 if running.has_key(self.host_file): running[self.host_file].insert_request(loop) else: loop.fetch(serve_cached=0) else: self.loop_req = None self.host_transfer_done()
def activate(self, request): Fetcher.activate(self, request) if not request.apFetcher: return
ba3d8721d8b906b93d571d1233bb0567d59ea911 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7531/ba3d8721d8b906b93d571d1233bb0567d59ea911/apt_proxy.py
if self.loop_req.code != http.OK:
if self.loop_req and self.loop_req.code != http.OK:
def host_transfer_done(self): """ Called by our LoopbackRequest when the real Fetcher calls finish() on it.
ba3d8721d8b906b93d571d1233bb0567d59ea911 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7531/ba3d8721d8b906b93d571d1233bb0567d59ea911/apt_proxy.py
post_convert = re.compile(r"^Should not match anything$") gzip_convert = post_convert
post_convert = re.compile(r"/Packages.gz$") gzip_convert = re.compile(r"^Should not match anything$")
def processEnded(self, reason=None): log.debug("Status: %d" %(self.process.status),'rsync_client') if self.process.status != 0: self.setResponseCode(http.NOT_FOUND) if not os.path.exists(self.local_file): try: os.removedirs(self.local_dir) except: pass
ba3d8721d8b906b93d571d1233bb0567d59ea911 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7531/ba3d8721d8b906b93d571d1233bb0567d59ea911/apt_proxy.py
print "CONVERT:", fetcher.post_convert
def fetch_real(result, dummyFetcher, cached, running): """ This is called after verifying if the file is properly cached. If 'cached' the requested file is properly cached. If not 'cached' the requested file was not there, didn't pass the integrity check or may be outdated. """ if len(dummyFetcher.requests)==0: #The request's are gone, the clients probably closed the #conection log.debug("THE REQUESTS ARE GONE (Clients closed conection)") dummyFetcher.apEnd() return
ba3d8721d8b906b93d571d1233bb0567d59ea911 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7531/ba3d8721d8b906b93d571d1233bb0567d59ea911/apt_proxy.py
FetcherGzip(loop)
gzip = FetcherGzip() gzip.activate(loop, postconverting=1)
def fetch_real(result, dummyFetcher, cached, running): """ This is called after verifying if the file is properly cached. If 'cached' the requested file is properly cached. If not 'cached' the requested file was not there, didn't pass the integrity check or may be outdated. """ if len(dummyFetcher.requests)==0: #The request's are gone, the clients probably closed the #conection log.debug("THE REQUESTS ARE GONE (Clients closed conection)") dummyFetcher.apEnd() return
ba3d8721d8b906b93d571d1233bb0567d59ea911 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7531/ba3d8721d8b906b93d571d1233bb0567d59ea911/apt_proxy.py
log.debug("have active fetcher",'client')
log.debug("have active fetcher: "+self.uri,'client')
def fetch_real(result, dummyFetcher, cached, running): """ This is called after verifying if the file is properly cached. If 'cached' the requested file is properly cached. If not 'cached' the requested file was not there, didn't pass the integrity check or may be outdated. """ if len(dummyFetcher.requests)==0: #The request's are gone, the clients probably closed the #conection log.debug("THE REQUESTS ARE GONE (Clients closed conection)") dummyFetcher.apEnd() return
ba3d8721d8b906b93d571d1233bb0567d59ea911 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7531/ba3d8721d8b906b93d571d1233bb0567d59ea911/apt_proxy.py
creator = ClientCreator(reactor, ftp.FTPClient, passive=0)
if not request.backend.username: creator = ClientCreator(reactor, ftp.FTPClient, passive=0) else: creator = ClientCreator(reactor, ftp.FTPClient, request.backend.username, request.backend.password, passive=0)
def activate (self, request): Fetcher.activate(self, request) if not request.apFetcher: return
6dd34e04f744a0653dad5ff163dbc3c66551643d /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7531/6dd34e04f744a0653dad5ff163dbc3c66551643d/apt_proxy.py
for k previous_shelve.keys():
for k in previous_shelve.keys():
def open_shelve(filename): from bsddb3 import db,dbshelve,DBInvalidArgError log.debug('Opening database ' + filename)
5ac6733a3de84056d877830510458bcf4f501b7f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/7531/5ac6733a3de84056d877830510458bcf4f501b7f/apt_proxy.py
def send_email(self, REQUEST, RESPONSE, group_id, email_address, email_id, message, subject=''): """ Send an email to the group. """ list_manager = self.get_xwfMailingListManager() sec = getSecurityManager() user = sec.getUser() if email_address not in user.get_emailAddresses(): raise 'Forbidden', 'Only the authenticated owner of an email address may use it to post' group = getattr(list_manager, group_id)
c5729558c58feb30cc51d77dd3bea85131b565e4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/6274/c5729558c58feb30cc51d77dd3bea85131b565e4/XWFVirtualMailingListArchive.py
moderated = self.getValueFor('moderated')
moderated = group.getValueFor('moderated')
def send_email(self, REQUEST, RESPONSE, group_id, email_address, email_id, message, subject=''): """ Send an email to the group. """ list_manager = self.get_xwfMailingListManager() sec = getSecurityManager() user = sec.getUser() if email_address not in user.get_emailAddresses(): raise 'Forbidden', 'Only the authenticated owner of an email address may use it to post' group = getattr(list_manager, group_id)
c5729558c58feb30cc51d77dd3bea85131b565e4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/6274/c5729558c58feb30cc51d77dd3bea85131b565e4/XWFVirtualMailingListArchive.py
def send_email(self, REQUEST, RESPONSE, group_id, email_address, email_id, message, subject=''): """ Send an email to the group. """ list_manager = self.get_xwfMailingListManager() sec = getSecurityManager() user = sec.getUser() if email_address not in user.get_emailAddresses(): raise 'Forbidden', 'Only the authenticated owner of an email address may use it to post' group = getattr(list_manager, group_id)
c5729558c58feb30cc51d77dd3bea85131b565e4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/6274/c5729558c58feb30cc51d77dd3bea85131b565e4/XWFVirtualMailingListArchive.py
subject = 'Re: %s' % orig_email.getProperty('subject')
subject = 'Re: %s' % orig_email.getProperty('mailSubject')
def send_email(self, REQUEST, RESPONSE, group_id, email_address, email_id, message, subject=''): """ Send an email to the group. We send the email via the mail server so it will handle things like message ID's for us. """ list_manager = self.get_xwfMailingListManager() sec = getSecurityManager() user = sec.getUser() if email_address not in user.get_emailAddresses(): raise 'Forbidden', 'Only the authenticated owner of an email address may use it to post' group = getattr(list_manager, group_id) group_email = group.getProperty('mailto') group_name = group.getProperty('title') message_id = None if email_id: orig_email = self.get_email(email_id) subject = 'Re: %s' % orig_email.getProperty('subject') message_id = orig_email.getProperty('message-id', '') name = '%s %s' % (user.preferredName, user.lastName) headers = """From: %s <%s>
4a702ae4744a1326ef5ac9c828f19b2e4985332f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/6274/4a702ae4744a1326ef5ac9c828f19b2e4985332f/XWFVirtualMailingListArchive.py
class GSBaseMessageView(Products.Five.BrowserView):
class GSNewTopicView(Products.Five.BrowserView, GSGroupObject):
def get_group_info(self): assert self.__groupInfo retval = self.__groupInfo assert retval return retval
a94a8bc3ab4bb5d2cad24b197851d0e95e995189 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/6274/a94a8bc3ab4bb5d2cad24b197851d0e95e995189/view.py
self.set_archive(self.context.messages) self.set_emailId(self.context.REQUEST.form.get('id', None)) self.init_email() self.init_topic() assert self.archive assert self.emailId assert self.email assert self.topic def set_archive(self, archive): """Set the email message archive to "archive".""" assert archive self.archive = archive assert self.archive def get_archive(self): """Get the email message archive.""" assert self.archive return self.archive def set_emailId(self, emailId): assert emailId self.emailId = emailId assert self.emailId def get_emailId(self): return self.emailId def init_email(self): assert self.emailId self.email = None self.email = self.archive.get_email(self.emailId) assert self.email def get_email(self): retval = self.email assert retval return retval def init_topic(self): assert self.emailId assert self.archive assert self.email query = {'compressedTopic': '%s' % self.email.compressedSubject} result = self.archive.find_email(query) assert result self.topic = map(lambda x: x.getObject(), result) assert self.topic assert self.topic.append assert len(self.topic) > 0 def get_topic(self): assert self.topic assert self.topic.append return self.topic def get_topic_name(self): assert self.email retval = self.email['mailSubject'] return retval def process_form(self): pass class GSTopicView(GSBaseMessageView, GSGroupObject): """View of a GroupServer Topic""" def __init__(self, context, request): assert context assert request GSBaseMessageView.__init__(self, context, request)
def __init__(self, context, request): # Preconditions assert context assert request Products.Five.BrowserView.__init__(self, context, request) self.set_archive(self.context.messages) self.set_emailId(self.context.REQUEST.form.get('id', None)) self.init_email() self.init_topic() # Postconditions assert self.archive assert self.emailId assert self.email assert self.topic
a94a8bc3ab4bb5d2cad24b197851d0e95e995189 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/6274/a94a8bc3ab4bb5d2cad24b197851d0e95e995189/view.py
self.init_threads() def init_threads(self): assert self.topic assert self.archive self.threads = self.archive.get_all_threads({}, 'mailDate', 'asc') self.threadNames = map(lambda thread: thread[1][0]['mailSubject'], self.threads) currThreadName = self.get_topic_name() assert currThreadName in self.threadNames self.currThreadIndex = self.threadNames.index(currThreadName) def post_date_storter(self, a, b): if a['mailDate'] > b['mailDate']: retval = 1 elif a['mailDate'] == b['mailDate']: retval = 0 else: retval = -1 assert retval in (1, 0, -1) return retval def init_topic(self): GSBaseMessageView.init_topic(self) self.topic.sort(self.post_date_storter) def get_next_topic(self): assert self.threads retval = None nextThreadIndex = self.currThreadIndex - 1 if nextThreadIndex >= 0: ntID = self.threads[nextThreadIndex][1][0]['id'] ntName = self.threads[nextThreadIndex][1][0]['mailSubject'] retval = (ntID, ntName) else: retval = (None, None) assert len(retval) == 2 return retval def get_previous_topic(self): assert self.threads retval = None previousThreadIndex = self.currThreadIndex + 1 if previousThreadIndex < len(self.threads): ptID = self.threads[previousThreadIndex][1][0]['id'] ptName = self.threads[previousThreadIndex][1][0]['mailSubject'] retval = (ptID, ptName) else: retval = (None, None) assert len(retval) == 2 return retval
def __init__(self, context, request): # Preconditions assert context assert request GSBaseMessageView.__init__(self, context, request) GSGroupObject.__init__(self, context) self.init_threads()
a94a8bc3ab4bb5d2cad24b197851d0e95e995189 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/6274/a94a8bc3ab4bb5d2cad24b197851d0e95e995189/view.py
pp = '/'.join(indexable.getPhysicalPath())
pp = '/'.join(object.getPhysicalPath())
def reindex_mailObjects(self): """ Reindex the mailObjects that we contain. """ for object in self.archive.objectValues('Folder'): if hasattr(object, 'mailFrom'): pp = '/'.join(indexable.getPhysicalPath()) self.Catalog.uncatalog_object(pp) self.Catalog.catalog_object(indexable, pp) return indexables
f464fbc958b4a328938bc5414396efa8b72a130e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/6274/f464fbc958b4a328938bc5414396efa8b72a130e/XWFMailingList.py
self.Catalog.catalog_object(indexable, pp)
self.Catalog.catalog_object(object, pp)
def reindex_mailObjects(self): """ Reindex the mailObjects that we contain. """ for object in self.archive.objectValues('Folder'): if hasattr(object, 'mailFrom'): pp = '/'.join(indexable.getPhysicalPath()) self.Catalog.uncatalog_object(pp) self.Catalog.catalog_object(indexable, pp) return indexables
f464fbc958b4a328938bc5414396efa8b72a130e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/6274/f464fbc958b4a328938bc5414396efa8b72a130e/XWFMailingList.py
mailString.encode(getConfiguration().default_zpublisher_encoding)
mailString.encode(getConfiguration().default_zpublisher_encoding or 'UTF-8')
def manage_addMail(self, mailString): """ Store mail & attachments in a folder and return it. """ import re archive = self.restrictedTraverse(self.getValueFor('storage'), default=None) # no archive available? then return immediately if archive is None: return None (header, body) = self.splitMail(mailString) # get the content type header, and re-encode the email to the default encoding ct = header.get('content-type',None) encoding = 'ascii' if ct: encoding_match = re.search('charset=[\'\"]?(.*?)[\'\"].*?;', ct) encoding = encoding_match and encoding_match.groups()[0] for try_encoding in (encoding, 'utf-8', 'iso-8859-1', 'iso-8859-15'): try: mailString = mailString.decode(try_encoding) mailString.encode(getConfiguration().default_zpublisher_encoding) (header, body) = self.splitMail(mailString) break except (UnicodeDecodeError, LookupError): pass # if 'keepdate' is set, get date from mail, if self.getValueFor('keepdate'): timetuple = rfc822.parsedate_tz(header.get('date')) time = DateTime(rfc822.mktime_tz(timetuple)) # ... take our own date, clients are always lying! else: time = DateTime() # let's create the mailObject mailFolder = archive subject = self.mime_decode_header(header.get('subject', 'No Subject')) # correct the subject subject = self.tidy_subject(subject) if subject.lower().find('re:', 0, 3) == 0 and len(subject) > 3: subject = subject[3:].strip() elif len(subject) == 0: subject = 'No Subject' compressedsubject = re.sub('\s+', '', subject) sender = self.mime_decode_header(header.get('from','No From')) title = "%s / %s" % (subject, sender) # we use our IdFactory to get the next ID, rather than trying something # ad-hoc id = str(self.get_nextId()) self.addMailBoxerMail(mailFolder, id, title) mailObject = getattr(mailFolder, id) # unpack attachments (TextBody, ContentType, HtmlBody, Attachments) = self.unpackMail( mailString) # ContentType is only set for the TextBody if ContentType: mailBody = TextBody else: mailBody = self.HtmlToText(HtmlBody) # and now add some properties to our new mailobject self.setMailBoxerMailProperty(mailObject, 'mailFrom', sender, 'ustring') self.setMailBoxerMailProperty(mailObject, 'mailSubject', subject, 'ustring') self.setMailBoxerMailProperty(mailObject, 'mailDate', time, 'date') self.setMailBoxerMailProperty(mailObject, 'mailBody', mailBody, 'utext') self.setMailBoxerMailProperty(mailObject, 'compressedSubject', compressedsubject, 'string') types = {'date': ('date', convert_date), 'from': ('lines', convert_addrs), 'to': ('lines', convert_addrs), 'received': ('lines', null_convert),} for key in header.keys(): if key in types: self.setMailBoxerMailProperty(mailObject, key, types[key][1](self.mime_decode_header(header.get(key,''))), types[key][0]) else: self.setMailBoxerMailProperty(mailObject, key, self.mime_decode_header(header.get(key,'')), 'text') sender_id = self.get_mailUserId(mailObject.getProperty('from', [])) self.setMailBoxerMailProperty(mailObject, 'mailUserId', sender_id, 'string') self.catalogMailBoxerMail(mailObject)
3e83e5f8b4849e55cdccfbd0d5afa983c155c05a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/6274/3e83e5f8b4849e55cdccfbd0d5afa983c155c05a/XWFMailingList.py
return indexables
return 1
def reindex_mailObjects(self): """ Reindex the mailObjects that we contain. """ for object in self.archive.objectValues('Folder'): if hasattr(object, 'mailFrom'): pp = '/'.join(object.getPhysicalPath()) self.Catalog.uncatalog_object(pp) self.Catalog.catalog_object(object, pp) return indexables
fbf5901ef7d02d309a2dd5366c78daea90c1b73f /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/6274/fbf5901ef7d02d309a2dd5366c78daea90c1b73f/XWFMailingList.py
group = getattr(listmanager, group_id)
group = getattr(list_manager, group_id)
def send_email(self, REQUEST, RESPONSE, group_id, email_address, email_id, message, subject=''): """ Send an email to the group. We send the email via the mail server so it will handle things like message ID's for us. """ list_manager = self.get_xwfMailingListManager() sec = getSecurityManager() user = sec.getUser() if email_address not in user.get_emailAddresses(): raise 'Forbidden', 'Only the authenticated owner of an email address may use it to post' group = getattr(listmanager, group_id) group_email = group.getProperty('mailto') group_name = group.getProperty('title') message_id = None if email_id: orig_email = self.get_email(email_id) subject = 'Re: %s' % orig_email.getProperty('subject') message_id = orig_email.getProperty('message-id', '') name = '%s %s' % (user.preferredName, user.lastName) headers = """From: %s <%s>
51e016dba1a410b7caaff43704c324f1e0bb7c57 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/6274/51e016dba1a410b7caaff43704c324f1e0bb7c57/XWFVirtualMailingListArchive.py
""" getting the maillist and moderatedlist is a special case, working in with the XWFT group framework. """
def getValueFor(self, key): # getting the maillist and moderatedlist is a special case, working in with the # XWFT group framework pass_group_id = False if key in ('digestmaillist', 'maillist', 'moderator', 'moderatedlist','mailinlist'): maillist = [] if key in ('digestmaillist', 'maillist'): address_getter = 'get_deliveryEmailAddressesByKey' member_getter = 'get_memberUserObjects' #address_getter = 'get_preferredEmailAddresses' pass_group_id = True maillist_script = getattr(self, 'maillist_members', None) elif key in ('moderator',): address_getter = 'get_emailAddresses' member_getter = 'get_moderatorUserObjects' maillist_script = None maillist = self.aq_inner.getProperty('moderator', []) if not maillist: maillist = self.aq_parent.getProperty('moderator',[]) elif key in ('moderatedlist',): address_getter = 'get_emailAddresses' member_getter = 'get_moderatedUserObjects' maillist_script = None maillist = self.aq_inner.getProperty('moderatedlist', []) if not maillist: maillist = self.aq_parent.getProperty('moderatedlist',[]) else: address_getter = 'get_emailAddresses' member_getter = 'get_memberUserObjects' maillist_script = getattr(self, 'mailinlist_members', None) # look for a maillist script if maillist_script: return maillist_script() try: users = getattr(self, member_getter)() for user in users: # we're looking to send out regular email, but this user is set to digest if key == 'maillist' and user.get_deliverySettingsByKey(self.getId()) == 3: continue elif key == 'digestmaillist' and user.get_deliverySettingsByKey(self.getId()) != 3: continue
5bd82550831bbccb7d4675bcee2c81d4524ca299 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/6274/5bd82550831bbccb7d4675bcee2c81d4524ca299/XWFMailingList.py
except:
except Exception, x: LOG('XWFMailingList', PROBLEM, 'A problem was experienced while getting values: %s' % x)
def getValueFor(self, key): # getting the maillist and moderatedlist is a special case, working in with the # XWFT group framework pass_group_id = False if key in ('digestmaillist', 'maillist', 'moderator', 'moderatedlist','mailinlist'): maillist = [] if key in ('digestmaillist', 'maillist'): address_getter = 'get_deliveryEmailAddressesByKey' member_getter = 'get_memberUserObjects' #address_getter = 'get_preferredEmailAddresses' pass_group_id = True maillist_script = getattr(self, 'maillist_members', None) elif key in ('moderator',): address_getter = 'get_emailAddresses' member_getter = 'get_moderatorUserObjects' maillist_script = None maillist = self.aq_inner.getProperty('moderator', []) if not maillist: maillist = self.aq_parent.getProperty('moderator',[]) elif key in ('moderatedlist',): address_getter = 'get_emailAddresses' member_getter = 'get_moderatedUserObjects' maillist_script = None maillist = self.aq_inner.getProperty('moderatedlist', []) if not maillist: maillist = self.aq_parent.getProperty('moderatedlist',[]) else: address_getter = 'get_emailAddresses' member_getter = 'get_memberUserObjects' maillist_script = getattr(self, 'mailinlist_members', None) # look for a maillist script if maillist_script: return maillist_script() try: users = getattr(self, member_getter)() for user in users: # we're looking to send out regular email, but this user is set to digest if key == 'maillist' and user.get_deliverySettingsByKey(self.getId()) == 3: continue elif key == 'digestmaillist' and user.get_deliverySettingsByKey(self.getId()) != 3: continue
5bd82550831bbccb7d4675bcee2c81d4524ca299 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/6274/5bd82550831bbccb7d4675bcee2c81d4524ca299/XWFMailingList.py
last_name = nparts[1:]
last_name = ' '.join(nparts[1:])
def requestMail(self, REQUEST): # Handles un-/subscribe-requests.
9419ff5a26a19753426b85f1b992ed392d45f2e8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/6274/9419ff5a26a19753426b85f1b992ed392d45f2e8/XWFMailingList.py
memberlist = self.lowerList(self.getValueFor('maillist'))
memberlist = self.lowerList(self.getValueFor('digestmaillist'))
def manage_digestBoxer(self, REQUEST): """ Send out a digest of topics to users who have requested it.
9419ff5a26a19753426b85f1b992ed392d45f2e8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/6274/9419ff5a26a19753426b85f1b992ed392d45f2e8/XWFMailingList.py
fr = curr_thread_results[0]
def thread_sorter(a, b): if s_on in ('mailDate', 'mailSubject'): a = getattr(a[1][0], s_on); b = getattr(b[1][0], s_on) elif s_on in ('mailCount', ): a = a[0]; b = b[0] else: return 0 if not a > b: return s_order == 'asc' and -1 or 1 elif not a < b: return s_order == 'asc' and 1 or -1 else: return 0
9404ef506829fb48624d879b2d8f7827b234c79b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/6274/9404ef506829fb48624d879b2d8f7827b234c79b/XWFVirtualMailingListArchive.py
security.declareProtected('Manage properties','getMemberUserObjects')
security.declareProtected('Manage properties','get_mailUserId')
def manage_delMember(self, email): """ Remove member from group. """ user = self.acl_users.get_userByEmail(email) if user: user.del_groupWithNotification('%s_member' % self.getId()) return 1
0fda689234bd0c838035b894b52a7e3bccc3741c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/6274/0fda689234bd0c838035b894b52a7e3bccc3741c/XWFMailingList.py
mailObject.manage_addProperty('mailSubject', Subject, 'string')
def manage_addMail(self, Mail): """ store mail & attachments in a folder and return it """
57729cb3b933d92c0559a8096bab7b9411268918 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/6274/57729cb3b933d92c0559a8096bab7b9411268918/XWFMailingList.py
if Subject.lower().find('re:', 0, 3) == 0 and len(subject) > 3:
if Subject.lower().find('re:', 0, 3) == 0 and len(Subject) > 3:
def manage_addMail(self, Mail): """ store mail & attachments in a folder and return it """
5e94ee5594b10d3e6ad9cce4197dd5fb22679646 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/6274/5e94ee5594b10d3e6ad9cce4197dd5fb22679646/XWFMailingList.py
f = file('/home/richard/foo.txt', 'a+') f.write(str(urlparts))
def getAuthorizedURL(url, auth): # annoyingly, xmlrpclib only recognises user@pass style # authentication, so having gone to the trouble of parsing # it out, we now need to add it back in again if not auth: return url import urlparse urlparts = list(urlparse.urlparse(url)) urlparts[1] = auth+'@'+urlparts[1] f = file('/home/richard/foo.txt', 'a+') f.write(str(urlparts)) return urlparse.urlunparse(urlparts)
30b050cbd78e047c83aba5f73d15c0e9ff30b4df /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/6274/30b050cbd78e047c83aba5f73d15c0e9ff30b4df/smtp2zope.py
encoding_match = re.search('charset=[\'\"]?(.*?)[\'\"].*?;', ct)
encoding_match = re.search('charset=[\'\"]?(.*?)[\'\"]?;', ct)
def manage_addMail(self, mailString): """ Store mail & attachments in a folder and return it. """ import re archive = self.restrictedTraverse(self.getValueFor('storage'), default=None) # no archive available? then return immediately if archive is None: return None (header, body) = self.splitMail(mailString) # get the content type header, and re-encode the email to the default encoding ct = header.get('content-type',None) encoding = 'ascii' if ct: encoding_match = re.search('charset=[\'\"]?(.*?)[\'\"].*?;', ct) encoding = encoding_match and encoding_match.groups()[0] or 'ascii' convert_encoding_to_default(mailString, encoding) (header, body) = self.splitMail(mailString) # if 'keepdate' is set, get date from mail, if self.getValueFor('keepdate'): timetuple = rfc822.parsedate_tz(header.get('date')) time = DateTime(rfc822.mktime_tz(timetuple)) # ... take our own date, clients are always lying! else: time = DateTime() # let's create the mailObject mailFolder = archive subject = self.mime_decode_header(header.get('subject', 'No Subject')) subject = convert_encoding_to_default(subject, encoding) # correct the subject subject = self.tidy_subject(subject) if subject.lower().find('re:', 0, 3) == 0 and len(subject) > 3: subject = subject[3:].strip() elif len(subject) == 0: subject = 'No Subject' compressedsubject = re.sub('\s+', '', subject) sender = self.mime_decode_header(header.get('from','No From')) sender = convert_encoding_to_default(sender, encoding) title = "%s / %s" % (subject, sender) # we use our IdFactory to get the next ID, rather than trying something # ad-hoc id = str(self.get_nextId()) self.addMailBoxerMail(mailFolder, id, title) mailObject = getattr(mailFolder, id) # unpack attachments (TextBody, ContentType, HtmlBody, Attachments) = self.unpackMail( mailString) # ContentType is only set for the TextBody if ContentType: mailBody = TextBody else: mailBody = self.HtmlToText(HtmlBody) # and now add some properties to our new mailobject self.setMailBoxerMailProperty(mailObject, 'mailFrom', sender, 'string') self.setMailBoxerMailProperty(mailObject, 'mailSubject', subject, 'string') self.setMailBoxerMailProperty(mailObject, 'mailDate', time, 'date') self.setMailBoxerMailProperty(mailObject, 'mailBody', mailBody, 'text') self.setMailBoxerMailProperty(mailObject, 'compressedSubject', compressedsubject, 'string') types = {'date': ('date', convert_date), 'from': ('lines', convert_addrs), 'to': ('lines', convert_addrs), 'received': ('lines', null_convert),} for key in header.keys(): if key in types: self.setMailBoxerMailProperty(mailObject, key, types[key][1](self.mime_decode_header(header.get(key,''))), types[key][0]) else: self.setMailBoxerMailProperty(mailObject, key, self.mime_decode_header(header.get(key,'')), 'text') sender_id = self.get_mailUserId(mailObject.getProperty('from', [])) self.setMailBoxerMailProperty(mailObject, 'mailUserId', sender_id, 'string') self.catalogMailBoxerMail(mailObject)
348002b9fa68768d2edcbf4dc861256e83f8cf58 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/6274/348002b9fa68768d2edcbf4dc861256e83f8cf58/XWFMailingList.py
if custom_mailcheck(mailinglist=self, sender=email, message=message):
if custom_mailcheck(mailinglist=self, sender=email, header=header, body=body):
def checkMail(self, REQUEST): # [email protected]: this is mostly the same as the MailBoxer parent, # only with notification. # Check for ip, loops and spam. # Check for correct IP mtahosts = self.getValueFor('mtahosts') if mtahosts: if 'HTTP_X_FORWARDED_FOR' in self.REQUEST.environ.keys(): REMOTE_IP = self.REQUEST.environ['HTTP_X_FORWARDED_FOR'] else: REMOTE_IP = self.REQUEST.environ['REMOTE_ADDR']
b5730d1ac828567fce76aa3462be58bd325a79df /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/6274/b5730d1ac828567fce76aa3462be58bd325a79df/XWFMailingList.py
pass
maillist = None
def getValueFor(self, key): # getting the maillist is a special case, working in with the # XWFT group framework pass_group_id = False if key in ('digestmaillist', 'maillist', 'mailinlist'): if key in ('digestmaillist', 'maillist'): address_getter = 'get_deliveryEmailAddressesByKey' #address_getter = 'get_preferredEmailAddresses' pass_group_id = True maillist_script = getattr(self, 'maillist_members', None) else: address_getter = 'get_emailAddresses' maillist_script = getattr(self, 'mailinlist_members', None) # look for a maillist script if maillist_script: return maillist_script() maillist = [] try: users = self.get_memberUserObjects() for user in users: # we're looking to send out regular email, but this user is set to digest if key == 'maillist' and user.get_deliverySettingsByKey(self.getId()) == 3: continue elif key == 'digestmaillist' and user.get_deliverySettingsByKey(self.getId()) != 3: continue
ec786fc696a268c9eaed9b4011eb7f6d0a0a3369 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/6274/ec786fc696a268c9eaed9b4011eb7f6d0a0a3369/XWFMailingList.py
if not maillist: maillist = self.getProperty('maillist')
if maillist == None: maillist = self.getProperty('maillist', [])
def getValueFor(self, key): # getting the maillist is a special case, working in with the # XWFT group framework pass_group_id = False if key in ('digestmaillist', 'maillist', 'mailinlist'): if key in ('digestmaillist', 'maillist'): address_getter = 'get_deliveryEmailAddressesByKey' #address_getter = 'get_preferredEmailAddresses' pass_group_id = True maillist_script = getattr(self, 'maillist_members', None) else: address_getter = 'get_emailAddresses' maillist_script = getattr(self, 'mailinlist_members', None) # look for a maillist script if maillist_script: return maillist_script() maillist = [] try: users = self.get_memberUserObjects() for user in users: # we're looking to send out regular email, but this user is set to digest if key == 'maillist' and user.get_deliverySettingsByKey(self.getId()) == 3: continue elif key == 'digestmaillist' and user.get_deliverySettingsByKey(self.getId()) != 3: continue
ec786fc696a268c9eaed9b4011eb7f6d0a0a3369 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/6274/ec786fc696a268c9eaed9b4011eb7f6d0a0a3369/XWFMailingList.py
def process_form(self): pass
def process_form(self): pass
ff470ace452b3bd8d494f6fe3da41f1d563254f2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/6274/ff470ace452b3bd8d494f6fe3da41f1d563254f2/view.py
'''Did the user write the email message?
"""Did the user write the email message?
def user_authored(self): '''Did the user write the email message? ARGUMENTS None. RETURNS A boolean that is "True" if the current user authored the email message, "False" otherwise. SIDE EFFECTS None.''' assert self.post assert self.request user = self.request.AUTHENTICATED_USER retval = user.getId() == self.post['mailUserId'] assert retval in (True, False) return retval
ff470ace452b3bd8d494f6fe3da41f1d563254f2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/6274/ff470ace452b3bd8d494f6fe3da41f1d563254f2/view.py
None.'''
None."""
def user_authored(self): '''Did the user write the email message? ARGUMENTS None. RETURNS A boolean that is "True" if the current user authored the email message, "False" otherwise. SIDE EFFECTS None.''' assert self.post assert self.request user = self.request.AUTHENTICATED_USER retval = user.getId() == self.post['mailUserId'] assert retval in (True, False) return retval
ff470ace452b3bd8d494f6fe3da41f1d563254f2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/6274/ff470ace452b3bd8d494f6fe3da41f1d563254f2/view.py
'''Does the author of the post exist?
"""Does the author of the post exist?
def author_exists(self): '''Does the author of the post exist? RETURNS True if the author of the post exists on the system, False otherwise. SIDE EFFECTS None.''' assert self.post retval = False authorId = self.post['mailUserId'] retval = self.context.Scripts.get.user_exists(authorId) assert retval in (True, False) return retval
ff470ace452b3bd8d494f6fe3da41f1d563254f2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/6274/ff470ace452b3bd8d494f6fe3da41f1d563254f2/view.py
None.'''
None."""
def author_exists(self): '''Does the author of the post exist? RETURNS True if the author of the post exists on the system, False otherwise. SIDE EFFECTS None.''' assert self.post retval = False authorId = self.post['mailUserId'] retval = self.context.Scripts.get.user_exists(authorId) assert retval in (True, False) return retval
ff470ace452b3bd8d494f6fe3da41f1d563254f2 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/6274/ff470ace452b3bd8d494f6fe3da41f1d563254f2/view.py
f = file('/home/richard/foo.txt', 'a+') f.write(str(urlparts))
def getAuthorizedURL(url, auth): # annoyingly, xmlrpclib only recognises user@pass style # authentication, so having gone to the trouble of parsing # it out, we now need to add it back in again if not auth: return url import urlparse urlparts = list(urlparse.urlparse(url)) urlparts[1] = auth+'@'+urlparts[1] f = file('/home/richard/foo.txt', 'a+') f.write(str(urlparts)) return urlparse.urlunparse(urlparts)
9ccf5804f6f4f9ff3a89a7391ea240841f648696 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/6274/9ccf5804f6f4f9ff3a89a7391ea240841f648696/smtp2zope.py
def thread_results(self, REQUEST, bstart, bsize, s_on, s_order):
def thread_results(self, REQUEST, b_start, b_size, s_on, s_order):
def thread_results(self, REQUEST, bstart, bsize, s_on, s_order):
b575cd3396d4a2cd53f070c1cde69d9188f36d24 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/6274/b575cd3396d4a2cd53f070c1cde69d9188f36d24/XWFVirtualMailingListArchive.py
if moderatedlist:
if moderated and moderatedlist:
def send_email(self, REQUEST, RESPONSE, group_id, email_address, email_id, message, subject=''): """ Send an email to the group. """ list_manager = self.get_xwfMailingListManager() sec = getSecurityManager() user = sec.getUser() if email_address not in user.get_emailAddresses(): raise 'Forbidden', 'Only the authenticated owner of an email address may use it to post' group = getattr(list_manager, group_id)
8f63c3b43a4fc55e0b746e29958983fc6abbf3f5 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/6274/8f63c3b43a4fc55e0b746e29958983fc6abbf3f5/XWFVirtualMailingListArchive.py
if getattr(self, '__initialised', 1): return 1
if getattr(item, '_initialised', False): return False
def manage_afterAdd(self, item, container): """ For configuring the object post-instantiation. """ if getattr(self, '__initialised', 1): return 1 item._setObject('Catalog', XWFCatalog()) wordsplitter = Record() wordsplitter.group = 'Word Splitter' wordsplitter.name = 'HTML aware splitter' casenormalizer = Record() casenormalizer.group = 'Case Normalizer' casenormalizer.name = 'Case Normalizer' stopwords = Record() stopwords.group = 'Stop Words' stopwords.name = 'Remove listed and single char words' item.Catalog.manage_addProduct['ZCTextIndex'].manage_addLexicon( 'Lexicon', 'Default Lexicon', (wordsplitter, casenormalizer, stopwords)) zctextindex_extras = Record() zctextindex_extras.index_type = 'Okapi BM25 Rank' zctextindex_extras.lexicon_id = 'Lexicon' for key, index in self.get_metadataIndexMap().items(): if index == 'ZCTextIndex': zctextindex_extras.doc_attr = key item.Catalog.addIndex(key, index, zctextindex_extras) elif index == 'MultiplePathIndex': # we need to shortcut this one item.Catalog._catalog.addIndex(key, MultiplePathIndex(key)) else: item.Catalog.addIndex(key, index) # add the metadata we need item.Catalog.addColumn('id') item.Catalog.addColumn('mailSubject') item.Catalog.addColumn('mailFrom') item.Catalog.addColumn('mailDate') item.manage_addProduct['MailHost'].manage_addMailHost('MailHost', smtp_host='127.0.0.1') return True
4d315aa55816c9429c4e833bd4884c6f7dbeecc0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/6274/4d315aa55816c9429c4e833bd4884c6f7dbeecc0/XWFMailingListManager.py
item.Catalog.manage_addProduct['ZCTextIndex'].manage_addLexicon( 'Lexicon', 'Default Lexicon', (wordsplitter, casenormalizer, stopwords))
def manage_afterAdd(self, item, container): """ For configuring the object post-instantiation. """ if getattr(self, '__initialised', 1): return 1 item._setObject('Catalog', XWFCatalog()) wordsplitter = Record() wordsplitter.group = 'Word Splitter' wordsplitter.name = 'HTML aware splitter' casenormalizer = Record() casenormalizer.group = 'Case Normalizer' casenormalizer.name = 'Case Normalizer' stopwords = Record() stopwords.group = 'Stop Words' stopwords.name = 'Remove listed and single char words' item.Catalog.manage_addProduct['ZCTextIndex'].manage_addLexicon( 'Lexicon', 'Default Lexicon', (wordsplitter, casenormalizer, stopwords)) zctextindex_extras = Record() zctextindex_extras.index_type = 'Okapi BM25 Rank' zctextindex_extras.lexicon_id = 'Lexicon' for key, index in self.get_metadataIndexMap().items(): if index == 'ZCTextIndex': zctextindex_extras.doc_attr = key item.Catalog.addIndex(key, index, zctextindex_extras) elif index == 'MultiplePathIndex': # we need to shortcut this one item.Catalog._catalog.addIndex(key, MultiplePathIndex(key)) else: item.Catalog.addIndex(key, index) # add the metadata we need item.Catalog.addColumn('id') item.Catalog.addColumn('mailSubject') item.Catalog.addColumn('mailFrom') item.Catalog.addColumn('mailDate') item.manage_addProduct['MailHost'].manage_addMailHost('MailHost', smtp_host='127.0.0.1') return True
4d315aa55816c9429c4e833bd4884c6f7dbeecc0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/6274/4d315aa55816c9429c4e833bd4884c6f7dbeecc0/XWFMailingListManager.py
item.Catalog.addIndex(key, index, zctextindex_extras) elif index == 'MultiplePathIndex': item.Catalog._catalog.addIndex(key, MultiplePathIndex(key))
try: item.Catalog.addIndex(key, index, zctextindex_extras) except CatalogError: pass
def manage_afterAdd(self, item, container): """ For configuring the object post-instantiation. """ if getattr(self, '__initialised', 1): return 1 item._setObject('Catalog', XWFCatalog()) wordsplitter = Record() wordsplitter.group = 'Word Splitter' wordsplitter.name = 'HTML aware splitter' casenormalizer = Record() casenormalizer.group = 'Case Normalizer' casenormalizer.name = 'Case Normalizer' stopwords = Record() stopwords.group = 'Stop Words' stopwords.name = 'Remove listed and single char words' item.Catalog.manage_addProduct['ZCTextIndex'].manage_addLexicon( 'Lexicon', 'Default Lexicon', (wordsplitter, casenormalizer, stopwords)) zctextindex_extras = Record() zctextindex_extras.index_type = 'Okapi BM25 Rank' zctextindex_extras.lexicon_id = 'Lexicon' for key, index in self.get_metadataIndexMap().items(): if index == 'ZCTextIndex': zctextindex_extras.doc_attr = key item.Catalog.addIndex(key, index, zctextindex_extras) elif index == 'MultiplePathIndex': # we need to shortcut this one item.Catalog._catalog.addIndex(key, MultiplePathIndex(key)) else: item.Catalog.addIndex(key, index) # add the metadata we need item.Catalog.addColumn('id') item.Catalog.addColumn('mailSubject') item.Catalog.addColumn('mailFrom') item.Catalog.addColumn('mailDate') item.manage_addProduct['MailHost'].manage_addMailHost('MailHost', smtp_host='127.0.0.1') return True
4d315aa55816c9429c4e833bd4884c6f7dbeecc0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/6274/4d315aa55816c9429c4e833bd4884c6f7dbeecc0/XWFMailingListManager.py
item.Catalog.addIndex(key, index)
try: item.Catalog.addIndex(key, index) except CatalogError: pass
def manage_afterAdd(self, item, container): """ For configuring the object post-instantiation. """ if getattr(self, '__initialised', 1): return 1 item._setObject('Catalog', XWFCatalog()) wordsplitter = Record() wordsplitter.group = 'Word Splitter' wordsplitter.name = 'HTML aware splitter' casenormalizer = Record() casenormalizer.group = 'Case Normalizer' casenormalizer.name = 'Case Normalizer' stopwords = Record() stopwords.group = 'Stop Words' stopwords.name = 'Remove listed and single char words' item.Catalog.manage_addProduct['ZCTextIndex'].manage_addLexicon( 'Lexicon', 'Default Lexicon', (wordsplitter, casenormalizer, stopwords)) zctextindex_extras = Record() zctextindex_extras.index_type = 'Okapi BM25 Rank' zctextindex_extras.lexicon_id = 'Lexicon' for key, index in self.get_metadataIndexMap().items(): if index == 'ZCTextIndex': zctextindex_extras.doc_attr = key item.Catalog.addIndex(key, index, zctextindex_extras) elif index == 'MultiplePathIndex': # we need to shortcut this one item.Catalog._catalog.addIndex(key, MultiplePathIndex(key)) else: item.Catalog.addIndex(key, index) # add the metadata we need item.Catalog.addColumn('id') item.Catalog.addColumn('mailSubject') item.Catalog.addColumn('mailFrom') item.Catalog.addColumn('mailDate') item.manage_addProduct['MailHost'].manage_addMailHost('MailHost', smtp_host='127.0.0.1') return True
4d315aa55816c9429c4e833bd4884c6f7dbeecc0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/6274/4d315aa55816c9429c4e833bd4884c6f7dbeecc0/XWFMailingListManager.py
item.Catalog.addColumn('id') item.Catalog.addColumn('mailSubject') item.Catalog.addColumn('mailFrom') item.Catalog.addColumn('mailDate')
for md in ('id','mailSubject','mailFrom','mailDate'): try: item.Catalog.addColumn(md) except CatalogError: pass
def manage_afterAdd(self, item, container): """ For configuring the object post-instantiation. """ if getattr(self, '__initialised', 1): return 1 item._setObject('Catalog', XWFCatalog()) wordsplitter = Record() wordsplitter.group = 'Word Splitter' wordsplitter.name = 'HTML aware splitter' casenormalizer = Record() casenormalizer.group = 'Case Normalizer' casenormalizer.name = 'Case Normalizer' stopwords = Record() stopwords.group = 'Stop Words' stopwords.name = 'Remove listed and single char words' item.Catalog.manage_addProduct['ZCTextIndex'].manage_addLexicon( 'Lexicon', 'Default Lexicon', (wordsplitter, casenormalizer, stopwords)) zctextindex_extras = Record() zctextindex_extras.index_type = 'Okapi BM25 Rank' zctextindex_extras.lexicon_id = 'Lexicon' for key, index in self.get_metadataIndexMap().items(): if index == 'ZCTextIndex': zctextindex_extras.doc_attr = key item.Catalog.addIndex(key, index, zctextindex_extras) elif index == 'MultiplePathIndex': # we need to shortcut this one item.Catalog._catalog.addIndex(key, MultiplePathIndex(key)) else: item.Catalog.addIndex(key, index) # add the metadata we need item.Catalog.addColumn('id') item.Catalog.addColumn('mailSubject') item.Catalog.addColumn('mailFrom') item.Catalog.addColumn('mailDate') item.manage_addProduct['MailHost'].manage_addMailHost('MailHost', smtp_host='127.0.0.1') return True
4d315aa55816c9429c4e833bd4884c6f7dbeecc0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/6274/4d315aa55816c9429c4e833bd4884c6f7dbeecc0/XWFMailingListManager.py
self.__initialised = 1
self._initialised = True
def upgrade(self): """ Upgrade to the latest version. """ currversion = getattr(self, '_version', 0) if currversion == self.version: return 'already running latest version (%s)' % currversion
4d315aa55816c9429c4e833bd4884c6f7dbeecc0 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/6274/4d315aa55816c9429c4e833bd4884c6f7dbeecc0/XWFMailingListManager.py
memberlist = self.lowerList(self.getValueFor('maillist'))
memberlist = self.lowerList(self.getValueFor('mailinlist'))
def requestMail(self, REQUEST): # Handles un-/subscribe-requests.
32aa7b5d70ddde143b78c7ad171f96172c749990 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/6274/32aa7b5d70ddde143b78c7ad171f96172c749990/XWFMailingList.py
custom_mailcheck = getattr(context, 'custom_mailcheck', None)
custom_mailcheck = getattr(self, 'custom_mailcheck', None)
def checkMail(self, REQUEST): # [email protected]: this is mostly the same as the MailBoxer parent, # only with notification. # Check for ip, loops and spam. # Check for correct IP mtahosts = self.getValueFor('mtahosts') if mtahosts: if 'HTTP_X_FORWARDED_FOR' in self.REQUEST.environ.keys(): REMOTE_IP = self.REQUEST.environ['HTTP_X_FORWARDED_FOR'] else: REMOTE_IP = self.REQUEST.environ['REMOTE_ADDR']
0b3ebbbba7958f74ba988f6253f61eedbc1a36c8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/6274/0b3ebbbba7958f74ba988f6253f61eedbc1a36c8/XWFMailingList.py
def get_userFromEmail(
def get_userFromEmail(
bee352c7e67679c322d57b7787d319212bf378d3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/6274/bee352c7e67679c322d57b7787d319212bf378d3/XWFMailingList.py
return sender_id
return ''
def get_mailUserId(self, from_addrs=[]): member_users = self.get_memberUserObjects() for addr in from_addrs: for member_user in member_users: addrs = member_user.getProperty('emailAddresses', []) for member_addr in addrs: if member_addr.lower() == addr.lower(): return member_user.getId() return sender_id
0af8ef0dcb7f331e91ac31a6371d1b9283b0ea9e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/6274/0af8ef0dcb7f331e91ac31a6371d1b9283b0ea9e/XWFMailingList.py
for group in member_groups: group = self.acl_users.getGroupById('%s_member' % self.listId())
for gid in member_groups: group = self.acl_users.getGroupById(gid)
def getValueFor(self, key): # getting the maillist is a special case, working in with the # XWFT group framework if key == 'maillist': # look for a maillist script maillist_script = getattr(self, 'maillist_members', None) if maillist_script: return maillist_script() maillist = [] try: member_groups = self.getProperty('member_groups', ['%s_member' % self.listId()]) uids = [] for group in member_groups: group = self.acl_users.getGroupById('%s_member' % self.listId()) uids += group.getUsers() for uid in uids: user = self.acl_users.getUser(uid) for email in user.get_preferredEmailAddresses(): email = email.strip() if email and email not in maillist: maillist.append(email) except: pass # last ditch effort if not maillist: maillist = self.getProperty('maillist') return maillist # Again, look for the property locally, then assume it is in the parent if self.aq_inner.hasProperty(key): return self.aq_inner.getProperty(key) else: return self.aq_parent.getProperty(key)
916688bb4ef729415cb978ad03a3a315cbfb529b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/6274/916688bb4ef729415cb978ad03a3a315cbfb529b/XWFMailingList.py
encoding = encoding_match and encoding_match.groups()[0]
encoding = encoding_match and encoding_match.groups()[0] or 'ascii'
def manage_addMail(self, mailString): """ Store mail & attachments in a folder and return it. """ import re archive = self.restrictedTraverse(self.getValueFor('storage'), default=None) # no archive available? then return immediately if archive is None: return None (header, body) = self.splitMail(mailString) # get the content type header, and re-encode the email to the default encoding ct = header.get('content-type',None) encoding = 'ascii' if ct: encoding_match = re.search('charset=[\'\"]?(.*?)[\'\"].*?;', ct) encoding = encoding_match and encoding_match.groups()[0] for try_encoding in (encoding, 'utf-8', 'iso-8859-1', 'iso-8859-15'): try: mailString = mailString.decode(try_encoding) mailString.encode(getConfiguration().default_zpublisher_encoding or 'UTF-8') (header, body) = self.splitMail(mailString) break except (UnicodeDecodeError, LookupError): pass # if 'keepdate' is set, get date from mail, if self.getValueFor('keepdate'): timetuple = rfc822.parsedate_tz(header.get('date')) time = DateTime(rfc822.mktime_tz(timetuple)) # ... take our own date, clients are always lying! else: time = DateTime() # let's create the mailObject mailFolder = archive subject = self.mime_decode_header(header.get('subject', 'No Subject')) # correct the subject subject = self.tidy_subject(subject) if subject.lower().find('re:', 0, 3) == 0 and len(subject) > 3: subject = subject[3:].strip() elif len(subject) == 0: subject = 'No Subject' compressedsubject = re.sub('\s+', '', subject) sender = self.mime_decode_header(header.get('from','No From')) title = "%s / %s" % (subject, sender) # we use our IdFactory to get the next ID, rather than trying something # ad-hoc id = str(self.get_nextId()) self.addMailBoxerMail(mailFolder, id, title) mailObject = getattr(mailFolder, id) # unpack attachments (TextBody, ContentType, HtmlBody, Attachments) = self.unpackMail( mailString) # ContentType is only set for the TextBody if ContentType: mailBody = TextBody else: mailBody = self.HtmlToText(HtmlBody) # and now add some properties to our new mailobject self.setMailBoxerMailProperty(mailObject, 'mailFrom', sender, 'ustring') self.setMailBoxerMailProperty(mailObject, 'mailSubject', subject, 'ustring') self.setMailBoxerMailProperty(mailObject, 'mailDate', time, 'date') self.setMailBoxerMailProperty(mailObject, 'mailBody', mailBody, 'utext') self.setMailBoxerMailProperty(mailObject, 'compressedSubject', compressedsubject, 'string') types = {'date': ('date', convert_date), 'from': ('lines', convert_addrs), 'to': ('lines', convert_addrs), 'received': ('lines', null_convert),} for key in header.keys(): if key in types: self.setMailBoxerMailProperty(mailObject, key, types[key][1](self.mime_decode_header(header.get(key,''))), types[key][0]) else: self.setMailBoxerMailProperty(mailObject, key, self.mime_decode_header(header.get(key,'')), 'text') sender_id = self.get_mailUserId(mailObject.getProperty('from', [])) self.setMailBoxerMailProperty(mailObject, 'mailUserId', sender_id, 'string') self.catalogMailBoxerMail(mailObject)
dffcaccef7a7162292cf942292fc89e33707c175 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/6274/dffcaccef7a7162292cf942292fc89e33707c175/XWFMailingList.py
mailString.encode(getConfiguration().default_zpublisher_encoding or 'UTF-8')
mailString.encode(getConfiguration().default_zpublisher_encoding or 'utf-8')
def manage_addMail(self, mailString): """ Store mail & attachments in a folder and return it. """ import re archive = self.restrictedTraverse(self.getValueFor('storage'), default=None) # no archive available? then return immediately if archive is None: return None (header, body) = self.splitMail(mailString) # get the content type header, and re-encode the email to the default encoding ct = header.get('content-type',None) encoding = 'ascii' if ct: encoding_match = re.search('charset=[\'\"]?(.*?)[\'\"].*?;', ct) encoding = encoding_match and encoding_match.groups()[0] for try_encoding in (encoding, 'utf-8', 'iso-8859-1', 'iso-8859-15'): try: mailString = mailString.decode(try_encoding) mailString.encode(getConfiguration().default_zpublisher_encoding or 'UTF-8') (header, body) = self.splitMail(mailString) break except (UnicodeDecodeError, LookupError): pass # if 'keepdate' is set, get date from mail, if self.getValueFor('keepdate'): timetuple = rfc822.parsedate_tz(header.get('date')) time = DateTime(rfc822.mktime_tz(timetuple)) # ... take our own date, clients are always lying! else: time = DateTime() # let's create the mailObject mailFolder = archive subject = self.mime_decode_header(header.get('subject', 'No Subject')) # correct the subject subject = self.tidy_subject(subject) if subject.lower().find('re:', 0, 3) == 0 and len(subject) > 3: subject = subject[3:].strip() elif len(subject) == 0: subject = 'No Subject' compressedsubject = re.sub('\s+', '', subject) sender = self.mime_decode_header(header.get('from','No From')) title = "%s / %s" % (subject, sender) # we use our IdFactory to get the next ID, rather than trying something # ad-hoc id = str(self.get_nextId()) self.addMailBoxerMail(mailFolder, id, title) mailObject = getattr(mailFolder, id) # unpack attachments (TextBody, ContentType, HtmlBody, Attachments) = self.unpackMail( mailString) # ContentType is only set for the TextBody if ContentType: mailBody = TextBody else: mailBody = self.HtmlToText(HtmlBody) # and now add some properties to our new mailobject self.setMailBoxerMailProperty(mailObject, 'mailFrom', sender, 'ustring') self.setMailBoxerMailProperty(mailObject, 'mailSubject', subject, 'ustring') self.setMailBoxerMailProperty(mailObject, 'mailDate', time, 'date') self.setMailBoxerMailProperty(mailObject, 'mailBody', mailBody, 'utext') self.setMailBoxerMailProperty(mailObject, 'compressedSubject', compressedsubject, 'string') types = {'date': ('date', convert_date), 'from': ('lines', convert_addrs), 'to': ('lines', convert_addrs), 'received': ('lines', null_convert),} for key in header.keys(): if key in types: self.setMailBoxerMailProperty(mailObject, key, types[key][1](self.mime_decode_header(header.get(key,''))), types[key][0]) else: self.setMailBoxerMailProperty(mailObject, key, self.mime_decode_header(header.get(key,'')), 'text') sender_id = self.get_mailUserId(mailObject.getProperty('from', [])) self.setMailBoxerMailProperty(mailObject, 'mailUserId', sender_id, 'string') self.catalogMailBoxerMail(mailObject)
dffcaccef7a7162292cf942292fc89e33707c175 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/6274/dffcaccef7a7162292cf942292fc89e33707c175/XWFMailingList.py
import random self.id = id self.title = title
MailBoxer.__init__(self, id, title)
def __init__(self, id, title, mailto): """ Setup a MailBoxer with reasonable defaults. """ import random self.id = id self.title = title self.mailto = mailto self.hashkey = str(random.random())
f42fda5fa2fcd29da63537e5e29397519881d78c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/6274/f42fda5fa2fcd29da63537e5e29397519881d78c/XWFMailingList.py
self.hashkey = str(random.random()) def get_property(self, id): """ """ return getattr(aq_base(self), id) def del_property(self, id): """ """ return delattr(aq_base(self), id)
def valid_property_id(self, id): if not id or id[:1]=='_' or (id[:3]=='aq_') \ or (' ' in id) or escape(id) != id: return False return True
def __init__(self, id, title, mailto): """ Setup a MailBoxer with reasonable defaults. """ import random self.id = id self.title = title self.mailto = mailto self.hashkey = str(random.random())
f42fda5fa2fcd29da63537e5e29397519881d78c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/6274/f42fda5fa2fcd29da63537e5e29397519881d78c/XWFMailingList.py
else: delattr(aq_base(self), item['id'])
else: try: self._delProperty(item['id']) except: pass
def init_properties(self): """ Tidy up the property sheet, since we don't want to control most of the properties that have already been defined in the parent MailingListManager. """ delete_properties = filter(lambda x: x not in self.mailinglist_properties, self.propertyIds()) props = [] for item in self._properties: if item['id'] not in delete_properties: props.append(item) else: delattr(aq_base(self), item['id']) self._properties = tuple(props) self._p_changed = 1 return True
f42fda5fa2fcd29da63537e5e29397519881d78c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/6274/f42fda5fa2fcd29da63537e5e29397519881d78c/XWFMailingList.py
def get_maillist(self): """ """ return self.getValueFor('maillist') def get_mailinlist(self): """ """ return self.getValueFor('mailinlist')
def get_maillist(self): """ """ return self.getValueFor('maillist')
f42fda5fa2fcd29da63537e5e29397519881d78c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/6274/f42fda5fa2fcd29da63537e5e29397519881d78c/XWFMailingList.py
def manage_addXWFMailingList(self, id, mailto, title='Mailing List', REQUEST=None): """ Add an XWFMailingList to a container. """ ob = XWFMailingList(id, title, mailto) self._setObject(id, ob) ob = getattr(self, id) ob.init_properties() manage_addFolder(ob, 'archive', 'mailing list archives') if REQUEST is not None: return self.manage_main(self,REQUEST)
f42fda5fa2fcd29da63537e5e29397519881d78c /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/6274/f42fda5fa2fcd29da63537e5e29397519881d78c/XWFMailingList.py
user = security.getUser()
sec = getSecurityManager() user = sec.getUser()
def send_email(self, REQUEST, RESPONSE, group_id, email_address, email_id, message, subject=''): """ Send an email to the group. We send the email via the mail server so it will handle things like message ID's for us. """ list_manager = self.get_xwfMailingListManager() user = security.getUser() if email_address not in user.get_emailAddresses(): raise 'Forbidden', 'Only the authenticated owner of an email address may use it to post' group = getattr(listmanager, group_id) group_email = group.getProperty('mailto') group_name = group.getProperty('title') message_id = None if email_id: orig_email = self.get_email(email_id) subject = 'Re: %s' % orig_email.getProperty('subject') message_id = orig_email.getProperty('message-id', '') name = '%s %s' % (user.preferredName, user.lastName) headers = """From: %s <%s>
42dc8dc194eb75140bc8ab5a797c38d6a1e84604 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/6274/42dc8dc194eb75140bc8ab5a797c38d6a1e84604/XWFVirtualMailingListArchive.py
class Service(component.Service):
class Service(component.Service, protocol.Factory):
def connectionLost(self, reason): if self.state == socks5.STATE_CONNECT_PENDING: self.service.removePendingConnection(self.addr, self) else: if self.peersock != None: self.peersock.peersock = None self.peersock.transport.loseConnection() self.peersock = None self.service.removeActiveConnection(self.addr, self)
210c80bbc412bb8a329b96ed20bd3411bfc2e5af /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3999/210c80bbc412bb8a329b96ed20bd3411bfc2e5af/proxy65.py
self.associateWithRouter(config["secret"], config["rhost"], config["rport"])
self.associateWithRouter(config["secret"], config["rhost"], int(config["rport"], 10))
def __init__(self, serviceParent, config): component.Service.__init__(self, config["jid"], serviceParent)
210c80bbc412bb8a329b96ed20bd3411bfc2e5af /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3999/210c80bbc412bb8a329b96ed20bd3411bfc2e5af/proxy65.py
i["name"] = "JEP-65 Proxy"
i["name"] = "SOCKS5 Bytestreams Service"
def onDisco(self, iq): iq.swapAttribs("to", "from") iq["type"] = "result" iq.query.children = [] i = iq.query.addElement("identity") i["category"] = "proxy" i["type"] = "bytestreams" i["name"] = "JEP-65 Proxy" iq.query.addElement("feature")["var"] = "http://jabber.org/protocol/bytestreams" self.xmlstream.send(iq)
210c80bbc412bb8a329b96ed20bd3411bfc2e5af /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3999/210c80bbc412bb8a329b96ed20bd3411bfc2e5af/proxy65.py
iq.query.addElement("error")["code"] = "405"
e = iq.addElement("error") e["code"] = "405" e["type"] = "cancel" c = e.addElement("condition") c["xmlns"] = "urn:ietf:params:xml:ns:xmpp-stanzas" c.addElement("not-allowed")
def onActivateStream(self, iq): sid = hashSID(iq.query["sid"], iq["from"], str(iq.query.activate))
210c80bbc412bb8a329b96ed20bd3411bfc2e5af /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3999/210c80bbc412bb8a329b96ed20bd3411bfc2e5af/proxy65.py
iq.query.addElement("error")["code"] = "404"
e = iq.addElement("error") e["code"] = "404" e["type"] = "cancel" c = e.addElement("condition") c["xmlns"] = "urn:ietf:params:xml:ns:xmpp-stanzas" c.addElement("item-not-found")
def onActivateStream(self, iq): sid = hashSID(iq.query["sid"], iq["from"], str(iq.query.activate))
210c80bbc412bb8a329b96ed20bd3411bfc2e5af /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3999/210c80bbc412bb8a329b96ed20bd3411bfc2e5af/proxy65.py
s["jid"] = self.jabberId
s["jid"] = self.jid
def onGetHostInfo(self, iq): iq.swapAttributeValues("to", "from") iq["type"] = "result" iq.query.children = [] s = iq.query.addElement("streamhost") s["jid"] = self.jabberId s["host"] = self.proxyIP s["port"] = str(self.proxyPort) self.send(iq)
bacf28a5a4a21576380cdfd2ed7e9b73b040b984 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3999/bacf28a5a4a21576380cdfd2ed7e9b73b040b984/proxy65.py
def __init__(self, service): socks5.SOCKSv5.__init__(self) self.service = service self.supportedAuthMechs = [socks5.AUTHMECH_ANON] self.supportedAddrs = [socks5.ADDR_DOMAINNAME] self.enabledCommands = [socks5.CMD_CONNECT] self.addr = ""
6f1bbcc313689a1392d118e8a025dcdd576189e6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3999/6f1bbcc313689a1392d118e8a025dcdd576189e6/proxy65.py
if self.service.addConnection(addr):
if self.service.addConnection(addr, self):
def connectRequested(self, addr, port): # Check for special connect to the namespace -- this signifies that the client # is just checking to ensure it can connect to the streamhost if addr == "http://jabber.org/protocol/bytestreams": self.connectCompleted(addr, 0) self.transport.loseConnection() return # Save addr, for cleanup self.addr = addr # Check to see if the requested address is already # activated -- send an error if so if self.service.isActive(addr): self.sendErrorReply(socks5.REPLY_CONN_NOT_ALLOWED) return
6f1bbcc313689a1392d118e8a025dcdd576189e6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3999/6f1bbcc313689a1392d118e8a025dcdd576189e6/proxy65.py
self.peersock.transport.loseConnection()
self.peersock.transport.unregisterProducer()
def connectionLost(self, reason): if self.state == socks5.STATE_CONNECT_PENDING: self.service.removePendingConnection(self.addr, self) else: if self.peersock != None: self.peersock.peersock = None self.peersock.transport.loseConnection() self.peersock = None self.service.removeActiveConnection(self.addr, self)
6f1bbcc313689a1392d118e8a025dcdd576189e6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3999/6f1bbcc313689a1392d118e8a025dcdd576189e6/proxy65.py
self.service.removeActiveConnection(self.addr, self)
self.service.removeActiveConnection(self.addr)
def connectionLost(self, reason): if self.state == socks5.STATE_CONNECT_PENDING: self.service.removePendingConnection(self.addr, self) else: if self.peersock != None: self.peersock.peersock = None self.peersock.transport.loseConnection() self.peersock = None self.service.removeActiveConnection(self.addr, self)
6f1bbcc313689a1392d118e8a025dcdd576189e6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3999/6f1bbcc313689a1392d118e8a025dcdd576189e6/proxy65.py
def componentDisconnected(self): if self.proxy != None: self.proxy.loseConnection()
6f1bbcc313689a1392d118e8a025dcdd576189e6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3999/6f1bbcc313689a1392d118e8a025dcdd576189e6/proxy65.py
iq.swapAttribs("to", "from")
iq.swapAttributeValues("to", "from")
def onGetHostInfo(self, iq): iq.swapAttribs("to", "from") iq["type"] = "result" iq.query.children = [] s = iq.query.addElement("streamhost") s["jid"] = self.jabberId s["host"] = self.proxyIP s["port"] = self.proxyPort self.xmlstream.send(iq)
6f1bbcc313689a1392d118e8a025dcdd576189e6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3999/6f1bbcc313689a1392d118e8a025dcdd576189e6/proxy65.py
s["port"] = self.proxyPort
s["port"] = str(self.proxyPort)
def onGetHostInfo(self, iq): iq.swapAttribs("to", "from") iq["type"] = "result" iq.query.children = [] s = iq.query.addElement("streamhost") s["jid"] = self.jabberId s["host"] = self.proxyIP s["port"] = self.proxyPort self.xmlstream.send(iq)
6f1bbcc313689a1392d118e8a025dcdd576189e6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3999/6f1bbcc313689a1392d118e8a025dcdd576189e6/proxy65.py
iq.swapAttribs("to", "from")
print iq.toXml() iq.swapAttributeValues("to", "from")
def onDisco(self, iq): iq.swapAttribs("to", "from") iq["type"] = "result" iq.query.children = [] i = iq.query.addElement("identity") i["category"] = "proxy" i["type"] = "bytestreams" i["name"] = "SOCKS5 Bytestreams Service" iq.query.addElement("feature")["var"] = "http://jabber.org/protocol/bytestreams" self.xmlstream.send(iq)
6f1bbcc313689a1392d118e8a025dcdd576189e6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3999/6f1bbcc313689a1392d118e8a025dcdd576189e6/proxy65.py
iq.swapAttribs("to", "from")
iq.swapAttributeValues("to", "from")
def onActivateStream(self, iq): sid = hashSID(iq.query["sid"], iq["from"], str(iq.query.activate))
6f1bbcc313689a1392d118e8a025dcdd576189e6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3999/6f1bbcc313689a1392d118e8a025dcdd576189e6/proxy65.py
iq.swapAttribs("to", "from")
iq.swapAttributeValues("to", "from")
def onActivateStream(self, iq): sid = hashSID(iq.query["sid"], iq["from"], str(iq.query.activate))
6f1bbcc313689a1392d118e8a025dcdd576189e6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3999/6f1bbcc313689a1392d118e8a025dcdd576189e6/proxy65.py
olist[0].transport.startReading() olist[1].transport.startReading()
olist[0].transport.registerProducer(olist[1], 0) olist[1].transport.registerProducer(olist[0], 0)
def onActivateStream(self, iq): sid = hashSID(iq.query["sid"], iq["from"], str(iq.query.activate))
6f1bbcc313689a1392d118e8a025dcdd576189e6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3999/6f1bbcc313689a1392d118e8a025dcdd576189e6/proxy65.py
iq.swapAttribs("to", "from")
iq.swapAttributeValues("to", "from")
def onActivateStream(self, iq): sid = hashSID(iq.query["sid"], iq["from"], str(iq.query.activate))
6f1bbcc313689a1392d118e8a025dcdd576189e6 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3999/6f1bbcc313689a1392d118e8a025dcdd576189e6/proxy65.py
c = e.addElement("condition")
c = e.addElement("not-allowed")
def onActivateStream(self, iq): sid = hashSID(iq.query["sid"], iq["from"], str(iq.query.activate)) log.msg("Activation requested for: ", sid)
39fe3988216936e81c57311302034fad477cb043 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3999/39fe3988216936e81c57311302034fad477cb043/proxy65.py
c.addElement("not-allowed")
def onActivateStream(self, iq): sid = hashSID(iq.query["sid"], iq["from"], str(iq.query.activate)) log.msg("Activation requested for: ", sid)
39fe3988216936e81c57311302034fad477cb043 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3999/39fe3988216936e81c57311302034fad477cb043/proxy65.py
c = e.addElement("condition")
c = e.addElement("item-not-found")
def onActivateStream(self, iq): sid = hashSID(iq.query["sid"], iq["from"], str(iq.query.activate)) log.msg("Activation requested for: ", sid)
39fe3988216936e81c57311302034fad477cb043 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3999/39fe3988216936e81c57311302034fad477cb043/proxy65.py
c.addElement("item-not-found")
def onActivateStream(self, iq): sid = hashSID(iq.query["sid"], iq["from"], str(iq.query.activate)) log.msg("Activation requested for: ", sid)
39fe3988216936e81c57311302034fad477cb043 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3999/39fe3988216936e81c57311302034fad477cb043/proxy65.py
sid = hashSID(iq.query["sid"], iq["from"], str(iq.query.activate))
fromJID = jid.internJID(iq["from"]) activateJID = jid.internJID(iq.query.activate) sid = hashSID(iq.query["sid"], fromJID, activateJID)
def onActivateStream(self, iq): sid = hashSID(iq.query["sid"], iq["from"], str(iq.query.activate)) log.msg("Activation requested for: ", sid)
06eb1f5ef63c6ec2add72825baddff3a87223ad4 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/3999/06eb1f5ef63c6ec2add72825baddff3a87223ad4/proxy65.py
sigpow += test_vec_out[k].r * test_vec_out[k].i +
sigpow += test_vec_out[k].r * test_vec_out[k].r +
def compare_func(): s="""
0364aa89b08ae121bbda2265351bcf5c9e93fc4a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/2975/0364aa89b08ae121bbda2265351bcf5c9e93fc4a/mk_test.py
err = test_vec_out[k].r - testbuf[k].r; noisepow += err * err; err = test_vec_out[k].i - testbuf[k].i; noisepow += err * err;
C_SUB(err,test_vec_out[k],testbuf[k].r); noisepow += err.r * err.r + err.i + err.i;
def compare_func(): s="""
0364aa89b08ae121bbda2265351bcf5c9e93fc4a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/2975/0364aa89b08ae121bbda2265351bcf5c9e93fc4a/mk_test.py