Example #1
0
	def get_content(self):
		"""Returns the content of the message"""
                
                text = self.parsed_obj.get_payload()
                
                output = ''
                
                if isinstance(text, types.ListType) and self.parsed_obj.is_multipart():
                    for i in text:
                        if i.get_filename():
                            logging.error('Attachment found!!!')
                            output += "\nSorry but the attachment has been stripped from this message!"
                            continue
                        if (i.get_content_type() == "text/plain" or i.get_content_type() == "text/html"):
                            output+=(i.get_payload()) + '\n\n'
                            #logging.debug("Appending %s to output" % i.get_payload())
                else:
                    output = text
                    
                #logging.error("get_content(): Output before wrap is %s" % output)
                
                output = escape(output)
                output = nl2br(output)
                output1 = textwrap.wrap(output, 65)
                output = ''
                for i in output1:
                    output += i + '<br />'
                    
                #logging.error("get_content returning %s" % output)
                
		return output
Example #2
0
 def GET(self, id):
     """ View single post """
     id = int(id)
     post_data = model.get_post(id)
     if not post_data:
         argument_error()
     if session.admin and not model.authorized_user(session.userId, post_data.contactId):
         authorization_error()
     # Modify details of post_data for display.  Need to be able to handle
     # newlines in textarea data in a websafe way.
     post_data.details = web.net.websafe(post_data.details)
     post_data.details = utils.nl2br(post_data.details)
     item_data = model.get_items(id)
     contact_data = model.get_contact_data(post_data.contactId)
     return render.view(post_data, item_data, contact_data)
Example #3
0
 def GET(self, id):
     """ View single post """
     id = int(id)
     post_data = model.get_post(id)
     if not post_data:
         argument_error()
     if session.admin and not model.authorized_user(session.userId,
                                                    post_data.contactId):
         authorization_error()
     # Modify details of post_data for display.  Need to be able to handle
     # newlines in textarea data in a websafe way.
     post_data.details = web.net.websafe(post_data.details)
     post_data.details = utils.nl2br(post_data.details)
     item_data = model.get_items(id)
     contact_data = model.get_contact_data(post_data.contactId)
     return render.view(post_data, item_data, contact_data)
Example #4
0
    def send_command_by_polling(self, command, process=None):
        """"""
        if command == 'quit':
            return process, {'commands': ['Try harder.']}

        # start bconsole session if it's not initialized
        if process is None:
            process = self.start_process()

        poll = process.poll()
        if poll is not None:
            process = None
            return process, {'error': 'Connection to director terminated with status %d. Refresh to reconnect.' % poll}

        # send bconsole command
        if command:
            process.stdin.write(command.strip().encode('utf-8') + '\n')

        # make stdout fileobject nonblockable
        fp = process.stdout.fileno()
        flags = fcntl.fcntl(fp, fcntl.F_GETFL)
        fcntl.fcntl(fp, fcntl.F_SETFL, flags | os.O_NONBLOCK)

        output = ''

        while 1:
            # wait for data or timeout
            [i, o, e] = select.select([fp], [], [], 1)
            if i:
                # we have more data
                output += process.stdout.read(1000)
            else:
                # we have a timeout
                output = nl2br(output)

                return process, {"commands": [output]}