def _get_value(self, stream):
     try:
         return console_decode(stream.getvalue())
     except UnicodeError:
         # Error occurs if non-ASCII chars logged both as str and unicode.
         stream.buf = console_decode(stream.buf)
         stream.buflist = [console_decode(item) for item in stream.buflist]
         return stream.getvalue()
예제 #2
0
 def _get_value(self, stream):
     try:
         return console_decode(stream.getvalue())
     except UnicodeError:
         # Error occurs if non-ASCII chars logged both as str and unicode.
         stream.buf = console_decode(stream.buf)
         stream.buflist = [console_decode(item) for item in stream.buflist]
         return stream.getvalue()
def get_variables(interpreter=None):
    variables = VARIABLES.copy()
    if _running_on_iron_python(interpreter):
        variables.update(exp_return_msg=b'ty\xf6paikka',
                         exp_error_msg=u'hyv\xe4',
                         exp_log_msg=u'\xe4iti',
                         exp_log_multiline_msg=u'\xe4iti\nis\xe4')
    elif _running_on_py3(interpreter):
        variables.update(exp_error_msg="b'hyv\\xe4'",
                         exp_log_msg="b'\\xe4iti'",
                         exp_log_multiline_msg="b'\\xe4iti\\nis\\xe4'")
    elif _high_bytes_ok():
        variables.update(exp_log_msg=console_decode(b'\xe4iti'),
                         exp_log_multiline_msg=console_decode(b'\xe4iti\nis\xe4'))
    return variables
예제 #4
0
def get_variables(interpreter=None):
    variables = VARIABLES.copy()
    if _running_on_iron_python(interpreter):
        variables.update(exp_return_msg=b'ty\xf6paikka',
                         exp_error_msg=u'hyv\xe4',
                         exp_log_msg=u'\xe4iti',
                         exp_log_multiline_msg=u'\xe4iti\nis\xe4')
    elif _running_on_py3(interpreter):
        variables.update(exp_error_msg="b'hyv\\xe4'",
                         exp_log_msg="b'\\xe4iti'",
                         exp_log_multiline_msg="b'\\xe4iti\\nis\\xe4'")
    elif _high_bytes_ok():
        variables.update(
            exp_log_msg=console_decode('\xe4iti'),
            exp_log_multiline_msg=console_decode('\xe4iti\nis\xe4'))
    return variables
예제 #5
0
 def run_libdoc(self, args):
     cmd = self._libdoc + self._split_args(args)
     cmd[-1] = cmd[-1].replace('/', os.sep)
     logger.info(' '.join(cmd))
     stdout = tempfile.TemporaryFile()
     call(cmd, cwd=ROBOT_SRC, stdout=stdout, stderr=STDOUT)
     stdout.seek(0)
     output = stdout.read().replace('\r\n', '\n')
     logger.info(output)
     return console_decode(output, encoding=self._encoding)
예제 #6
0
 def run_tidy(self, options, input, output=None, tidy=None):
     """Runs tidy in the operating system and returns output."""
     command = (tidy or self._tidy)[:]
     if options:
         command.extend([e.decode('utf8') for e in split(options.encode('utf8'))])
     command.append(self._path(input))
     if output:
         command.append(output)
     print ' '.join(command)
     with tempfile.TemporaryFile() as stdout:
         rc = call(command, stdout=stdout, stderr=STDOUT,
                   cwd=ROBOT_SRC, shell=os.sep=='\\')
         stdout.seek(0)
         content = console_decode(stdout.read().strip())
         if rc:
             raise RuntimeError(content)
         return content
예제 #7
0
 def run_tidy(self, options, input, output=None, tidy=None):
     """Runs tidy in the operating system and returns output."""
     command = (tidy or self._tidy)[:]
     if options:
         command.extend(
             [e.decode('utf8') for e in split(options.encode('utf8'))])
     command.append(self._path(input))
     if output:
         command.append(output)
     print ' '.join(command)
     with tempfile.TemporaryFile() as stdout:
         rc = call(command,
                   stdout=stdout,
                   stderr=STDOUT,
                   cwd=ROBOT_SRC,
                   shell=os.sep == '\\')
         stdout.seek(0)
         content = console_decode(stdout.read().strip())
         if rc:
             raise RuntimeError(content)
         return content
예제 #8
0
 def _format_output(self, output):
     output = console_decode(output, self._output_encoding, force=True)
     output = output.replace('\r\n', '\n')
     if output.endswith('\n'):
         output = output[:-1]
     return output
예제 #9
0
 def _format_output(self, output):
     output = console_decode(output, self._output_encoding, force=True)
     output = output.replace('\r\n', '\n')
     if output.endswith('\n'):
         output = output[:-1]
     return output
예제 #10
0
def _high_bytes_ok():
    return console_decode('\xe4') != '\\xe4'
def _high_bytes_ok():
    return console_decode('\xe4') != '\\xe4'
예제 #12
0
파일: popen.py 프로젝트: jichen3000/codes
 def _process_output(self, output):
     if '\r\n' in output:
         output = output.replace('\r\n', '\n')
     if output.endswith('\n'):
         output = output[:-1]
     return console_decode(output, force=True)