def main(): messages = [] for url in RSS_URLS: messages += download_nzbs(url) #if len(messages) > 0: # from xmlrpclib import ServerProxy # server = ServerProxy('http://caliburn.csh.rit.edu:9611/') # for msg in messages: # server.message('hella: %s' %msg) if MAIL_ENABLED and len(messages) > 0: from email.Message import Message #print 'Sending email to %s' % EMAIL_TO email = Message() email.set_unixfrom(MAIL_FROM) email.add_header('Subject', '[hella] Queued %s files' % len(messages)) content = '' for msg in messages: content += '%s\r\n' % msg email.set_payload(content) email = email.as_string() server = SMTP(MAIL_SERVER) server.sendmail(MAIL_FROM, MAIL_TO, email) server.quit()
def comment(self, text='', username='', time='', note=None, use_heading=None, REQUEST=None, subject_heading='', message_id=None, in_reply_to=None, exclude_address=None, sendmail=1): """Add a comment to this page. We try to do this efficiently, avoiding re-rendering the full page if possible. The comment will be mailed out to any subscribers. If auto-subscription is in effect, we subscribe the poster to this page. subject_heading is so named to avoid a clash with some existing zope subject attribute. note and use_heading are not used and kept only for backwards compatibility. """ if not self.checkSufficientId(REQUEST): return self.denied( _("Sorry, this wiki doesn't allow anonymous edits. Please configure a username in options first.")) if self.isDavLocked(): return self.davLockDialog() # gather info oldtext = self.read() text = text and self.cleanupText(text) subject_heading = subject_heading and self.cleanupText(subject_heading) if not username: username = self.usernameFrom(REQUEST) if re.match(r'^(?:\d{1,3}\.){3}\d{1,3}$',username): username = '' username = username and self.tounicode(username) firstcomment = self.messageCount()==0 # ensure the page comment and mail-out will have the same # message-id, and the same timestamp if possible (helps threading # & troubleshooting) if time: dtime = DateTime(time) else: dtime = self.ZopeTime() time = dtime.rfc822() if not message_id: message_id = self.messageIdFromTime(dtime) # format this comment as standard rfc2822 m = Message() m.set_charset(self.encoding()) m.set_payload(self.toencoded(text)) m['From'] = self.toencoded(username) m['Date'] = time m['Subject'] = self.toencoded(subject_heading) m['Message-ID'] = message_id if in_reply_to: m['In-Reply-To'] = in_reply_to m.set_unixfrom(self.fromLineFrom(m['From'],m['Date'])[:-1]) t = self.tounicode(str(m)) # discard junk comments if not (m['Subject'] or m.get_payload()): return self.checkForSpam(t) # do it self.saveRevision() # append to the raw source t = '\n\n' + t self.raw += t # and to the _prerendered cache, carefully mimicking a full # prerender. This works with current page types at least. t = self.pageType().preRenderMessage(self,m) if firstcomment: t=self.pageType().discussionSeparator(self) + t t = self.pageType().preRender(self,t) self.setPreRendered(self.preRendered()+t) self.cookDtmlIfNeeded() # extras self.setLastEditor(REQUEST) self.setLastLog(subject_heading) if self.autoSubscriptionEnabled(): self.subscribeThisUser(REQUEST) self.index_object() if REQUEST: REQUEST.cookies['zwiki_username'] = m['From'] # use real from address if sendmail: self.sendMailToSubscribers( m.get_payload(), REQUEST, subject=m['Subject'], message_id=m['Message-ID'], in_reply_to=m['In-Reply-To'], exclude_address=exclude_address) if REQUEST: REQUEST.RESPONSE.redirect(REQUEST['URL1']+'#bottom')