def gather_sample(self):
        # Query the URL
        try:
            opener = urllib2.build_opener(NoRedirection, urllib2.HTTPCookieProcessor(cookielib.CookieJar()))
            response = opener.open(self.url, None, self.timeout)
        except urllib2.HTTPError, e:
            self._logger.error((self.url, e) % "HTTPError retrieving %s: %s")
            return
        except urllib2.URLError, e:
            self._logger.error("URLError retrieving %s: %s" % (self.url, e))
            return

        # Read the response, and apply any extraction pattern
        response_body = response.read()
        response.close()
        if self.extractor is not None:
            match = self.extractor.search(response_body)
            if match is not None:
                response_body = match.group(1)

        # Apply log_all_lines and max_characters, and record the result.
        if self.log_all_lines:
            s = response_body
        else:
            first_line = first_line_pattern.search(response_body)
            s = ''
            if first_line is not None:
                s = first_line.group().strip()

        if len(s) > self.max_characters:
            s = s[:self.max_characters] + "..."
        self._logger.emit_value('response', s, extra_fields={'url': self.url, 'status': response.getcode(),
                                                             'length': len(response_body)})
dataset/ETHPy150Open scalyr/scalyr-agent-2/scalyr_agent/builtin_monitors/url_monitor.py/UrlMonitor.gather_sample/swapped operands of `%`