예제 #1
0
 def append_xml(self, xmlbuf):
     if not self.document:
         raise RFNoDataException('No document given.')
     xmlbuf.write(
         '<XML_FAX_SUBMIT stylesheet="XML_FAX_SUBMIT.xslt" xmlns="x-schema:XML_FAX_SUBMIT.xdr">\r\n'
     )
     self.document.append_xml(xmlbuf)
     xmlbuf.write('</XML_FAX_SUBMIT>\r\n')
예제 #2
0
 def append_xml(self, xmlbuf):
     if not self.actions:
         raise RFNoDataException('No actions were provided.')
     xmlbuf.write(
         '<XML_FAX_ACTION xmlns="x-schema:../schemas/XML_FAX_ACTION_schema.xml">\r\n'
     )
     for action in self.actions:
         action.append_xml(xmlbuf)
     xmlbuf.write('</XML_FAX_ACTION>\r\n')
예제 #3
0
 def send_data(self, data, content_type, avt_type, target_url=None):
     if not data:
         raise RFNoDataException('No data provided to send.')
     if target_url:
         url = target_url
     else:
         url = self.target_url
     transporter = Transporter(url, content_type, avt_type)
     resp_str = transporter.do_transport(data)
     FaxCommand._logger.info('Message transported to RightFax Server.')
     return resp_str
예제 #4
0
 def append_xml(self, xmlbuf):
     if not self.queries:
         raise RFNoDataException('No queries were provided.')
     xmlbuf.write(
         '<XML_FAX_QUERY xmlns="x-schema:../schemas/XML_FAX_QUERY_schema.xml">\r\n'
     )
     xmlbuf.write('\t<QUERIES>\r\n')
     for query in self.queries:
         query.append_xml(xmlbuf)
     xmlbuf.write('\t</QUERIES>\r\n')
     xmlbuf.write('</XML_FAX_QUERY>\r\n')
예제 #5
0
 def _full_url(self, url):
     if not url:
         raise RFNoDataException('URL not specified.')
     url = url.lower()
     dllidx = url.find(Transporter.RFISAPIDLL)
     rfxidx = url.find('rfxml')
     if dllidx < 0:
         if rfxidx < 0:
             url = urljoin(url, 'rfxml/')
         url = urljoin(url, Transporter.RFISAPIDLL)
     else:
         if rfxidx < 0:
             url = urljoin(url[0:dllidx], 'rfxml/')
             url = urljoin(url, Transporter.RFISAPIDLL)
     return url
예제 #6
0
 def send_data_ex(self, data, content_type, avt_type, target_url=None):
     if not data:
         raise RFNoDataException('No data provided to send.')
     if target_url:
         url = target_url
     else:
         url = self.target_url
     transporter = Transporter(url, content_type, avt_type)
     resp_list = transporter.do_transport_ex(data)
     if resp_list:
         FaxCommand._logger.info(
             'Message successfully transported to RightFax Server.')
     else:
         FaxCommand._logger.warn(
             'Message failed transport to RightFax Server.')
     return resp_list
예제 #7
0
    def submit_ex(self, xml=None, attachments=None):
        if not xml:
            xml = self.get_xml()
        if xml:
            FaxSubmit._logger.debug('XML (attachments not added yet):\n%s' %
                                    xml)
        else:
            raise RFNoDataException('No XML data given.')

        if not attachments:
            attachments = self.attachments
        if not attachments:
            FaxSubmit._logger.debug('No attachments so submitting as text')
            resp_str = self.send_data(xml, CONTENT_TEXT, AVT_SUBMIT)
        else:
            FaxSubmit._logger.debug(
                'There are attachments so MIME encode the whole thing')
            resp_str = self.send_data(mime_encode(xml, attachments),
                                      CONTENT_MIME, AVT_SUBMIT)
        return resp_str
예제 #8
0
    def append_xml(self, xmlbuf):
        if not self.sender:
            raise RFNoDataException('No sender data given.')
        if not self.destinations:
            raise RFNoDestinationException('No destination(s) given.')

        if self.send_datatime:
            xmlbuf.write('\t<SEND_DATE_TIME>%s</SEND_DATE_TIME>\r\n' %
                         format_datetime_utc(self.send_datatime))
        if self.beg_inc:
            xmlbuf.write('\t<INCLUDE_BEG>%s</INCLUDE_BEG>\r\n' % self.beg_inc)
        self.sender.append_xml(xmlbuf)
        xmlbuf.write('\t<DESTINATIONS>\r\n')
        for dest in self.destinations:
            dest.append_xml(xmlbuf)
        xmlbuf.write('\t</DESTINATIONS>\r\n')
        if self.form_name:
            xmlbuf.write('\t<FORM xcoord="%f" ycoord="%f">%s</FORM>\r\n' %
                         (self.form_x, self.form_y, self.form_name))
        if self.cover_text:
            if self.cover_ext:
                cover_type = ' type="%s"' % self.cover_ext
            else:
                cover_type = ''
            if self.cover_enc == ENCODING_BASE64:
                encoding = ' encoding="BASE64"'
            else:
                encoding = ''
            xmlbuf.write('\t<COVER_TEXT%s%s>%s</COVER_TEXT>\r\n' %
                         (cover_type, encoding, escape(self.cover_text)))
        if self.body and self.body.has_data():
            self.body.append_xml(xmlbuf)
        if self.lib_doc_id:
            xmlbuf.write('\t<ADD_LIBDOC>%s</ADD_LIBDOC>\r\n' % self.lib_doc_id)
        if self.end_inc:
            xmlbuf.write('\t<INCLUDE_END>%s</INCLUDE_END>\r\n' % self.end_inc)