Example #1
0
 def _repr_html_(self):
     """The tabbed log and report HTML code
        to be displayed as notebook cell output.
     """
     return """
       <div class="robotshell-test-result">
         <ul>
           <li><a href="#robotshell-test-result-tab-log">Log</a>
           </li>
           <li><a href="#robotshell-test-result-tab-report">Report</a>
           </li>
         </ul>
         <div id="robotshell-test-result-tab-log"
              class="robotshell-test-result-tab"
              >
           <iframe width="100%%" height="100%%" frameborder="0"
                   src="data:text/html;charset=utf-8,%s"
                   > """ % urlquote(self.log_html) + """
           </iframe>
         </div>
         <div id="robotshell-test-result-tab-report"
              class="robotshell-test-result-tab"
              >
           <iframe width="100%%" height="100%%" frameborder="0"
                   src="data:text/html;charset=utf-8,%s"
                   > """ % urlquote(self.report_html) + """
Example #2
0
    def paste(self, s):
        """Upload to pastebin via json interface."""

        url = urljoin(self.url, '/json/new')
        payload = {
            'code': s,
            'lexer': 'pycon',
            'expiry': self.expiry
        }

        try:
            response = requests.post(url, data=payload, verify=True)
            response.raise_for_status()
        except requests.exceptions.RequestException as exc:
            raise PasteFailed(exc.message)

        data = response.json()

        paste_url_template = Template(self.show_url)
        paste_id = urlquote(data['paste_id'])
        paste_url = paste_url_template.safe_substitute(paste_id=paste_id)

        removal_url_template = Template(self.removal_url)
        removal_id = urlquote(data['removal_id'])
        removal_url = removal_url_template.safe_substitute(
            removal_id=removal_id)

        return (paste_url, removal_url)
Example #3
0
    def paste(self, s):
        """Upload to pastebin via json interface."""

        url = urljoin(self.url, '/json/new')
        payload = {
            'code': s,
            'lexer': 'pycon',
            'expiry': self.expiry
        }

        try:
            response = requests.post(url, data=payload, verify=True)
            response.raise_for_status()
        except requests.exceptions.RequestException as exc:
            raise PasteFailed(exc.message)

        data = response.json()

        paste_url_template = Template(self.show_url)
        paste_id = urlquote(data['paste_id'])
        paste_url = paste_url_template.safe_substitute(paste_id=paste_id)

        removal_url_template = Template(self.removal_url)
        removal_id = urlquote(data['removal_id'])
        removal_url = removal_url_template.safe_substitute(
            removal_id=removal_id)

        return (paste_url, removal_url)
Example #4
0
 def _repr_html_(self):
     """The tabbed log and report HTML code
        to be displayed as notebook cell output.
     """
     return """
       <div class="robotshell-test-result">
         <ul>
           <li><a href="#robotshell-test-result-tab-log">Log</a>
           </li>
           <li><a href="#robotshell-test-result-tab-report">Report</a>
           </li>
         </ul>
         <div id="robotshell-test-result-tab-log"
              class="robotshell-test-result-tab"
              >
           <iframe width="100%%" height="100%%" frameborder="0"
                   src="data:text/html;charset=utf-8,%s"
                   > """ % urlquote(self.log_html) + """
           </iframe>
         </div>
         <div id="robotshell-test-result-tab-report"
              class="robotshell-test-result-tab"
              >
           <iframe width="100%%" height="100%%" frameborder="0"
                   src="data:text/html;charset=utf-8,%s"
                   > """ % urlquote(self.report_html) + """
Example #5
0
def test_quote():
    """
    Adding test for INT-3117 - working with URLs and reference sets causes an error.
    The issue is that forward slash doesn't get replaced by urllib.quote, and it causes issue with URL routing.
    """
    from six.moves.urllib_parse import quote as urlquote
    assert (qradar_utils.quote("/") == urlquote(qradar_utils.FORWARD_SLASH))

    test_val = "å∫ç∂´ƒ:_%^.abcdef1234"
    assert qradar_utils.quote(test_val) == urlquote(test_val)
 def _repr_html_(self):
     """The tabbed log and report HTML code
        to be displayed as notebook cell output.
     """
     return (
         """
       <div class="robotshell-test-result">
         <ul>
           <li><a href="#robotshell-test-result-tab-log">Log</a>
           </li>
           <li><a href="#robotshell-test-result-tab-report">Report</a>
           </li>
         </ul>
         <div id="robotshell-test-result-tab-log"
              class="robotshell-test-result-tab"
              >
           <iframe width="100%%" height="100%%" frameborder="0"
                   src="data:text/html;charset=utf-8,%s"
                   > """
         % urlquote(self.log_html)
         + """
           </iframe>
         </div>
         <div id="robotshell-test-result-tab-report"
              class="robotshell-test-result-tab"
              >
           <iframe width="100%%" height="100%%" frameborder="0"
                   src="data:text/html;charset=utf-8,%s"
                   > """
         % urlquote(self.report_html)
         + """
           </iframe>
         </div>
       </div>
       <script type="text/javascript">
         $("div.robotshell-test-result").tabs();
         $("div.robotshell-test-result-tab").resizable({
           autoHide: true,
           handles: "s"
         });
       </script>
       """
     )
Example #7
0
    def do_pastebin_json(self, s):
        """Upload to pastebin via json interface."""

        url = urljoin(self.config.pastebin_url, '/json/new')
        payload = {
            'code': s,
            'lexer': 'pycon',
            'expiry': self.config.pastebin_expiry
        }

        self.interact.notify(_('Posting data to pastebin...'))
        try:
            response = requests.post(url, data=payload, verify=True)
            response.raise_for_status()
        except requests.exceptions.RequestException as exc:
            self.interact.notify(_('Upload failed: %s') % (str(exc), ))
            return

        self.prev_pastebin_content = s
        data = response.json()

        paste_url_template = Template(self.config.pastebin_show_url)
        paste_id = urlquote(data['paste_id'])
        paste_url = paste_url_template.safe_substitute(paste_id=paste_id)

        removal_url_template = Template(self.config.pastebin_removal_url)
        removal_id = urlquote(data['removal_id'])
        removal_url = removal_url_template.safe_substitute(
            removal_id=removal_id)

        self.prev_pastebin_url = paste_url
        self.prev_removal_url = removal_url
        self.interact.notify(
            _('Pastebin URL: %s - Removal URL: %s') % (paste_url, removal_url),
            10)

        return paste_url
    def do_pastebin_json(self, s):
        """Upload to pastebin via json interface."""

        url = urljoin(self.config.pastebin_url, '/json/new')
        payload = {
            'code': s,
            'lexer': 'pycon',
            'expiry': self.config.pastebin_expiry
        }

        self.interact.notify(_('Posting data to pastebin...'))
        try:
            response = requests.post(url, data=payload, verify=True)
            response.raise_for_status()
        except requests.exceptions.RequestException as exc:
            self.interact.notify(_('Upload failed: %s') % (str(exc), ))
            return

        self.prev_pastebin_content = s
        data = response.json()

        paste_url_template = Template(self.config.pastebin_show_url)
        paste_id = urlquote(data['paste_id'])
        paste_url = paste_url_template.safe_substitute(paste_id=paste_id)

        removal_url_template = Template(self.config.pastebin_removal_url)
        removal_id = urlquote(data['removal_id'])
        removal_url = removal_url_template.safe_substitute(
            removal_id=removal_id)

        self.prev_pastebin_url = paste_url
        self.prev_removal_url = removal_url
        self.interact.notify(_('Pastebin URL: %s - Removal URL: %s') %
                             (paste_url, removal_url), 10)

        return paste_url
 def _repr_html_(self):
     html = libdoc.html(self.name)
     return """
       <iframe width="100%%" height="100%%" frameborder="0"
               src="data:text/html;charset=utf-8,%s"
               > """ % urlquote(html) + """
 def _encode_uri_component(self, value):
     # Emulates encodeURIComponent javascript function
     return urlquote(value.encode('UTF-8'), safe="-_.!~*'()")