def _get_value(self, stream):
     try:
         return decode_output(stream.getvalue())
     except UnicodeError:
         stream.buf = decode_output(stream.buf)
         stream.buflist = [decode_output(item) for item in stream.buflist]
         return stream.getvalue()
 def _get_value(self, stream):
     try:
         return decode_output(stream.getvalue())
     except UnicodeError:
         stream.buf = decode_output(stream.buf)
         stream.buflist = [decode_output(item) for item in stream.buflist]
         return stream.getvalue()
 def _get_value(self, stream):
     try:
         return decode_output(stream.getvalue())
     except UnicodeError:
         # Error occurs if non-ASCII chars logged both as str and unicode.
         stream.buf = decode_output(stream.buf)
         stream.buflist = [decode_output(item) for item in stream.buflist]
         return stream.getvalue()
 def _get_value(self, stream):
     try:
         return decode_output(stream.getvalue())
     except UnicodeError:
         # Error occurs if non-ASCII chars logged both as str and unicode.
         stream.buf = decode_output(stream.buf)
         stream.buflist = [decode_output(item) for item in stream.buflist]
         return stream.getvalue()
Exemple #5
0
def get_variables(executor=None):
    variables = VARIABLES.copy()
    if _running_on_iron_python(executor):
        variables.update(exp_return_msg=u'ty\xf6paikka',
                         exp_error_msg=u'hyv\xe4',
                         exp_log_msg=u'\xe4iti',
                         exp_log_multiline_msg=u'\xe4iti\nis\xe4')
    elif _high_bytes_ok():
        variables.update(exp_log_msg=decode_output('\xe4iti'),
                         exp_log_multiline_msg=decode_output('\xe4iti\nis\xe4'))
    return variables
 def release(self):
     # Original stream must be restored before closing the current
     self._set_stream(self._original)
     self._stream.flush()
     output = self._stream.getvalue()
     self._stream.close()
     return output if isinstance(output, unicode) else decode_output(output)
Exemple #7
0
 def run_libdoc(self, args):
     cmd = self._cmd + [a for a in args.split(' ') if a]
     cmd[-1] = cmd[-1].replace('/', os.sep)
     logger.info(' '.join(cmd))
     stdout = tempfile.TemporaryFile()
     call(cmd, cwd=ROBOT_SRC, stdout=stdout, stderr=STDOUT, shell=os.sep=='\\')
     stdout.seek(0)
     output = stdout.read().replace('\r\n', '\n')
     logger.info(output)
     return decode_output(output)
Exemple #8
0
 def run_libdoc(self, args):
     cmd = self._cmd + [a for a in args.split(" ") if a]
     cmd[-1] = cmd[-1].replace("/", os.sep)
     logger.info(" ".join(cmd))
     stdout = tempfile.TemporaryFile()
     call(cmd, cwd=ROBOT_SRC, stdout=stdout, stderr=STDOUT, shell=os.sep == "\\")
     stdout.seek(0)
     output = stdout.read().replace("\r\n", "\n")
     logger.info(output)
     return decode_output(output)
 def run_libdoc(self, args):
     cmd = self._cmd + [a for a in args.split(' ') if a]
     cmd[-1] = cmd[-1].replace('/', os.sep)
     logger.info(' '.join(cmd))
     # In Python 3, explicitly open in text mode (w+, default w+b)
     # causes less problems (works with str, not bytes):
     stdout = tempfile.TemporaryFile('w+')
     call(cmd, cwd=ROBOT_SRC, stdout=stdout, stderr=STDOUT, shell=os.sep=='\\')
     stdout.seek(0)
     output = stdout.read().replace('\r\n', '\n')
     logger.info(output)
     # Python 3 compatibility is handled by robot.utils.unic:
     return decode_output(output)
Exemple #10
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(options.split(' '))
     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 = decode_output(stdout.read().strip())
         if rc:
             raise RuntimeError(content)
         return content
Exemple #11
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(options.split(' '))
     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 = decode_output(stdout.read().strip())
         if rc:
             raise RuntimeError(content)
         return content
Exemple #12
0
 def run_libdoc(self, args):
     cmd = self._cmd + [a for a in args.split(' ') if a]
     cmd[-1] = cmd[-1].replace('/', os.sep)
     logger.info(' '.join(cmd))
     # In Python 3, explicitly open in text mode (w+, default w+b)
     # causes less problems (works with str, not bytes):
     stdout = tempfile.TemporaryFile('w+')
     call(cmd,
          cwd=ROBOT_SRC,
          stdout=stdout,
          stderr=STDOUT,
          shell=os.sep == '\\')
     stdout.seek(0)
     output = stdout.read().replace('\r\n', '\n')
     logger.info(output)
     # Python 3 compatibility is handled by robot.utils.unic:
     return decode_output(output)
Exemple #13
0
 def _format_output(self, output):
     if output.endswith('\n'):
         output = output[:-1]
     return decode_output(output, force=True)
Exemple #14
0
def _high_bytes_ok():
    return decode_output('\xe4') != '\\xe4'
Exemple #15
0
 def _format_output(self, output):
     if output.endswith("\n"):
         output = output[:-1]
     return decode_output(output, force=True)