sys.__stdout__

Here are the examples of the python api sys.__stdout__ taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

177 Examples 7

Example 1

Project: LTLMoP
Source File: OMPLControllerHandler.py
View license
    def propagate(self, start, control, duration, state):
        if self.system_print is True:
            print >>sys.__stdout__,"control[0]: " + str(control[0])
            print >>sys.__stdout__,"control[1]: " + str(control[1])
            print >>sys.__stdout__,"duration: " + str(duration)
        state.setX( start.getX() + control[0] * duration * cos(start.getYaw()) )
        state.setY( start.getY() + control[0] * duration * sin(start.getYaw()) )
        state.setYaw(start.getYaw() + control[1] * duration)

Example 2

Project: robotframework
Source File: encodingsniffer.py
View license
def _get_stream_output_encoding():
    # Stream may not have encoding attribute if it is intercepted outside RF in
    # Python. Encoding is None if process output is redirected and Python < 3.
    for stream in sys.__stdout__, sys.__stderr__, sys.__stdin__:
        encoding = getattr(stream, 'encoding', None)
        if _is_valid(encoding):
            return encoding
    return None

Example 3

View license
    def __getattribute__(self, name):
        if name == '__members__':
            return dir(sys.__stdout__)
        try:
            stream = _local.stream
        except AttributeError:
            stream = sys.__stdout__
        return getattr(stream, name)

Example 4

View license
def _get_encoding_from_standard_streams():
    # Stream may not have encoding attribute if it is intercepted outside RF
    # in Python. Encoding is None if process's outputs are redirected.
    for stream in sys.__stdout__, sys.__stderr__, sys.__stdin__:
        encoding = getattr(stream, 'encoding', None)
        if _is_valid(encoding):
            return encoding
    return None

Example 5

Project: RIDE
Source File: librarylogger.py
View license
def console(msg, newline=True, stream='stdout'):
    msg = unic(msg)
    if newline:
        msg += '\n'
    stream = sys.__stdout__ if stream.lower() != 'stderr' else sys.__stderr__
    stream.write(encode_output(msg))
    stream.flush()

Example 6

Project: django-pipeline
Source File: utils.py
View license
def set_std_streams_blocking():
    """
    Set stdout and stderr to be blocking.

    This is called after Popen.communicate() to revert stdout and stderr back
    to be blocking (the default) in the event that the process to which they
    were passed manipulated one or both file descriptors to be non-blocking.
    """
    if not fcntl:
        return
    for f in (sys.__stdout__, sys.__stderr__):
        fileno = f.fileno()
        flags = fcntl.fcntl(fileno, fcntl.F_GETFL)
        fcntl.fcntl(fileno, fcntl.F_SETFL, flags & ~os.O_NONBLOCK)

Example 7

Project: babble
Source File: test_uuid.py
View license
    def test_getnode(self):
        import sys
        print >>sys.__stdout__, \
"""    WARNING: uuid.getnode is unreliable on many platforms.
        It is disabled until the code and/or test can be fixed properly."""
        return

        node1 = uuid.getnode()
        self.check_node(node1, "getnode1")

        # Test it again to ensure consistency.
        node2 = uuid.getnode()
        self.check_node(node2, "getnode2")

        self.assertEqual(node1, node2)

Example 8

Project: dashboard
Source File: console.py
View license
    def __getattribute__(self, name):
        if name == '__members__':
            return dir(sys.__stdout__)
        try:
            stream = _local.stream
        except AttributeError:
            stream = sys.__stdout__
        return getattr(stream, name)

Example 9

Project: mavelous
Source File: console.py
View license
    def __getattribute__(self, name):
        if name == '__members__':
            return dir(sys.__stdout__)
        try:
            stream = _local.stream
        except AttributeError:
            stream = sys.__stdout__
        return getattr(stream, name)

Example 10

Project: python-mode
Source File: logging_ext.py
View license
def _colorable_terminal():
    isatty = hasattr(sys.__stdout__, 'isatty') and sys.__stdout__.isatty()
    if not isatty:
        return False
    if os.name == 'nt':
        try:
            from colorama import init as init_win32_colors
        except ImportError:
            return False
        init_win32_colors()
    return True

Example 11

Project: robotframework
Source File: runningtestcase.py
View license
    def tearDown(self):
        sys.__stdout__ = self.orig__stdout__
        sys.__stderr__ = self.orig__stderr__
        sys.stdout = self.orig_stdout
        sys.stderr = self.orig_stderr
        self._remove_files()

Example 12

Project: RIDE
Source File: verbose.py
View license
    def __init__(self, width=78, colors='AUTO', markers='AUTO', stdout=None,
                 stderr=None):
        self._width = width
        self._stdout = HighlightingStream(stdout or sys.__stdout__, colors)
        self._stderr = HighlightingStream(stderr or sys.__stderr__, colors)
        self._keyword_marker = KeywordMarker(self._stdout, markers)
        self._last_info = None

Example 13

Project: cloud-playground
Source File: console.py
View license
    def __getattribute__(self, name):
        if name == '__members__':
            return dir(sys.__stdout__)
        try:
            stream = _local.stream
        except AttributeError:
            stream = sys.__stdout__
        return getattr(stream, name)

Example 14

View license
    def test_no_encoding(self):
        sys.__stdout__ = object()
        sys.__stderr__ = object()
        sys.__stdin__ = StreamStub('ascii')
        assert_equal(get_console_encoding(), 'ascii')
        sys.__stdin__ = object()
        assert_not_none(get_console_encoding())

Example 15

Project: emailed-me
Source File: console.py
View license
    def __getattribute__(self, name):
        if name == '__members__':
            return dir(sys.__stdout__)
        try:
            stream = _local.stream
        except AttributeError:
            stream = sys.__stdout__
        return getattr(stream, name)

Example 16

Project: babble
Source File: test_uuid.py
View license
    def test_ifconfig_getnode(self):
        import sys
        print >>sys.__stdout__, \
"""    WARNING: uuid._ifconfig_getnode is unreliable on many platforms.
        It is disabled until the code and/or test can be fixed properly."""
        return

        import os
        if os.name == 'posix':
            node = uuid._ifconfig_getnode()
            if node is not None:
                self.check_node(node, 'ifconfig')

Example 17

Project: robotframework
Source File: verbose.py
View license
    def __init__(self, width=78, colors='AUTO', markers='AUTO', stdout=None,
                 stderr=None):
        self._width = width
        self._stdout = HighlightingStream(stdout or sys.__stdout__, colors)
        self._stderr = HighlightingStream(stderr or sys.__stderr__, colors)
        self._keyword_marker = KeywordMarker(self._stdout, markers)
        self._last_info = None

Example 18

Project: robotframework
Source File: librarylogger.py
View license
def console(msg, newline=True, stream='stdout'):
    msg = unic(msg)
    if newline:
        msg += '\n'
    stream = sys.__stdout__ if stream.lower() != 'stderr' else sys.__stderr__
    stream.write(console_encode(msg, stream=stream))
    stream.flush()

Example 19

Project: emailed-me
Source File: console.py
View license
    def __getattribute__(self, name):
        if name == '__members__':
            return dir(sys.__stdout__)
        try:
            stream = _local.stream
        except AttributeError:
            stream = sys.__stdout__
        return getattr(stream, name)

Example 20

Project: ReproWeb
Source File: console.py
View license
    def __getattribute__(self, name):
        if name == '__members__':
            return dir(sys.__stdout__)
        try:
            stream = _local.stream
        except AttributeError:
            stream = sys.__stdout__
        return getattr(stream, name)

Example 21

Project: python-mode
Source File: logging_ext.py
View license
def _colorable_terminal():
    isatty = hasattr(sys.__stdout__, 'isatty') and sys.__stdout__.isatty()
    if not isatty:
        return False
    if os.name == 'nt':
        try:
            from colorama import init as init_win32_colors
        except ImportError:
            return False
        init_win32_colors()
    return True

Example 22

Project: robotframework
Source File: runningtestcase.py
View license
    def setUp(self):
        self.orig__stdout__ = sys.__stdout__
        self.orig__stderr__ = sys.__stderr__
        self.orig_stdout = sys.stdout
        self.orig_stderr = sys.stderr
        self._setup_output_streams()
        self._remove_files()

Example 23

Project: uliweb
Source File: util.py
View license
    def __getattribute__(self, name):
        if name == '__members__':
            return dir(sys.__stdout__)
        try:
            stream = local.stream
        except AttributeError:
            stream = sys.__stdout__
        return getattr(stream, name)

Example 24

Project: WAPT
Source File: console.py
View license
    def __getattribute__(self, name):
        if name == '__members__':
            return dir(sys.__stdout__)
        try:
            stream = _local.stream
        except AttributeError:
            stream = sys.__stdout__
        return getattr(stream, name)

Example 25

Project: curtsies
Source File: window.py
View license
    def __init__(self, out_stream=None, hide_cursor=True):
        logger.debug('-------initializing Window object %r------' % self)
        if out_stream is None:
            out_stream = sys.__stdout__
        self.t = blessings.Terminal(stream=out_stream, force_styling=True)
        self.out_stream = out_stream
        self.hide_cursor = hide_cursor
        self._last_lines_by_row = {}
        self._last_rendered_width = None
        self._last_rendered_height = None

Example 26

View license
    def __getattribute__(self, name):
        if name == '__members__':
            return dir(sys.__stdout__)
        try:
            stream = _local.stream
        except AttributeError:
            stream = sys.__stdout__
        return getattr(stream, name)

Example 27

Project: asiaq
Source File: disco_logging.py
View license
def configure_logging(debug):
    '''Sets the default logger and the boto logger to appropriate levels of chattiness.'''
    logger = logging.getLogger('')
    boto_logger = logging.getLogger('boto')
    botocore_logger = logging.getLogger('botocore')
    if debug:
        logger.setLevel(logging.DEBUG)
        boto_logger.setLevel(logging.INFO)
        botocore_logger.setLevel(logging.DEBUG)
    else:
        logger.setLevel(logging.INFO)
        boto_logger.setLevel(logging.CRITICAL)
        botocore_logger.setLevel(logging.CRITICAL)

    stream_handler = logging.StreamHandler(sys.__stdout__)
    stream_handler.setLevel(logging.DEBUG)
    stream_handler.setFormatter(logging.Formatter('%(asctime)s %(name)s %(levelname)s %(message)s'))
    logger.addHandler(stream_handler)

Example 28

Project: hurry-app
Source File: console.py
View license
    def __getattribute__(self, name):
        if name == '__members__':
            return dir(sys.__stdout__)
        try:
            stream = _local.stream
        except AttributeError:
            stream = sys.__stdout__
        return getattr(stream, name)

Example 29

Project: appengine-flask-skeleton
Source File: console.py
View license
    def __getattribute__(self, name):
        if name == '__members__':
            return dir(sys.__stdout__)
        try:
            stream = _local.stream
        except AttributeError:
            stream = sys.__stdout__
        return getattr(stream, name)

Example 30

Project: hurry-app
Source File: console.py
View license
    def __getattribute__(self, name):
        if name == '__members__':
            return dir(sys.__stdout__)
        try:
            stream = _local.stream
        except AttributeError:
            stream = sys.__stdout__
        return getattr(stream, name)

Example 31

Project: RIDE
Source File: encodingsniffer.py
View license
def _get_stream_output_encoding():
    # Stream may not have encoding attribute if it is intercepted outside RF
    # in Python. Encoding is None if process's outputs are redirected.
    for stream in sys.__stdout__, sys.__stderr__, sys.__stdin__:
        encoding = getattr(stream, 'encoding', None)
        if _is_valid(encoding):
            return encoding
    return None

Example 32

Project: flasktodo
Source File: console.py
View license
    def __getattribute__(self, name):
        if name == '__members__':
            return dir(sys.__stdout__)
        try:
            stream = _local.stream
        except AttributeError:
            stream = sys.__stdout__
        return getattr(stream, name)

Example 33

View license
    def test_none_encoding(self):
        sys.__stdout__ = StreamStub(None)
        sys.__stderr__ = StreamStub(None)
        sys.__stdin__ = StreamStub('ascii')
        assert_equal(get_console_encoding(), 'ascii')
        sys.__stdin__ = StreamStub(None)
        assert_not_none(get_console_encoding())

Example 34

Project: pyspecs
Source File: _reporting.py
View license
    def __init__(self, registry):
        self.out = sys.__stdout__
        self.duration = 0
        self.steps = 0
        self._errors = 0
        self._failures = 0
        self._passed = 0
        self._problem_reports = []
        self._registry = registry
        self.captured = StringIO()

Example 35

Project: avocado-vt
Source File: mock.py
View license
    def _append_error(self, error):
        if self._debug:
            print >> sys.__stdout__, ' *** ' + error
        if self._fail_fast:
            raise CheckPlaybackError(error)
        self.errors.append(error)

Example 36

Project: PipelineConstructionSet
Source File: utils.py
View license
def shellLogHandler():
    """
    Adds an additional handler to the root logger to print to sys.__stdout__
    Returns the handler.
    """
    global _shellLogHandler
    if _shellLogHandler is not None:
        return _shellLogHandler
    shellStream = os.environ.get('MAYA_SHELL_LOGGER_STREAM', '__stdout__')
    shellStream = getattr(sys, shellStream, sys.__stdout__)
    _shellLogHandler = logging.StreamHandler(shellStream)
    format = os.environ.get('MAYA_SHELL_LOGGER_FORMAT', '%(name)s : %(levelname)s : %(message)s')
    _shellLogHandler.setFormatter( logging.Formatter(format) )
    log = logging.getLogger(appLoggerName)
    log.addHandler(_shellLogHandler)
    log.setLevel(logging.INFO)
    return _shellLogHandler

Example 37

Project: babble
Source File: test_uuid.py
View license
    def test_unixdll_getnode(self):
        import sys
        print >>sys.__stdout__, \
"""    WARNING: uuid._unixdll_getnode is unreliable on many platforms.
        It is disabled until the code and/or test can be fixed properly."""
        return

        import os
        if importable('ctypes') and os.name == 'posix':
            self.check_node(uuid._unixdll_getnode(), 'unixdll')

Example 38

Project: norc
Source File: log.py
View license
    def write(self, msg, format_prefix):
        if format_prefix:
            msg = Log.format(msg, format_prefix)
        self.file.write(msg)
        self.file.flush()
        if self.echo:
            print >>sys.__stdout__, msg,

Example 39

Project: autotest
Source File: mock.py
View license
    def _append_error(self, error):
        if self._debug:
            print >> sys.__stdout__, ' *** ' + error
        if self._fail_fast:
            raise CheckPlaybackError(error)
        self.errors.append(error)

Example 40

Project: gae-flask-todo
Source File: console.py
View license
    def __getattribute__(self, name):
        if name == '__members__':
            return dir(sys.__stdout__)
        try:
            stream = _local.stream
        except AttributeError:
            stream = sys.__stdout__
        return getattr(stream, name)

Example 41

Project: sublime-robot-plugin
Source File: monitor.py
View license
    def __init__(self, width=78, colors='AUTO', markers='AUTO', stdout=None,
                 stderr=None):
        self._width = width
        self._stdout = stdout or sys.__stdout__
        self._stderr = stderr or sys.__stderr__
        self._highlighter = StatusHighlighter(colors, self._stdout, self._stderr)
        self._keyword_marker = KeywordMarker(markers, self._stdout, self._highlighter)
        self._last_info = None

Example 42

Project: popcorn_maker
Source File: __init__.py
View license
    def _height_and_width(self):
        """Return a tuple of (terminal height, terminal width)."""
        # tigetnum('lines') and tigetnum('cols') update only if we call
        # setupterm() again.
        for descriptor in self._init_descriptor, sys.__stdout__:
            try:
                return struct.unpack('hhhh', ioctl(descriptor, TIOCGWINSZ, '\000' * 8))[0:2]
            except IOError:
                pass
        return None, None  # Should never get here

Example 43

Project: pyforms
Source File: BaseWidget.py
View license
	def executeCommand(self, cmd, cwd=None):
		if cwd is not None:
			currentdirectory = os.getcwd()
			os.chdir(cwd)

		out = FlushFile(sys.__stdout__)

		proc = subprocess.Popen(cmd, stdout=out, stderr=out)
		(output, error) = proc.communicate()
		if cwd is not None:
			os.chdir(currentdirectory)
		if error:
			print('Error: ' + error)
		return output

Example 44

Project: robotframework
Source File: test_running.py
View license
    def test_stdout_and_stderr(self):
        self._run()
        self._assert_output(sys.__stdout__,
                            [('My Suite', 2), ('My Test', 1),
                             ('1 critical test, 1 passed, 0 failed', 1)])
        self._assert_output(sys.__stderr__, [('Hello, world!', 1)])

Example 45

Project: maraschino
Source File: console.py
View license
    def __getattribute__(self, name):
        if name == '__members__':
            return dir(sys.__stdout__)
        try:
            stream = _local.stream
        except AttributeError:
            stream = sys.__stdout__
        return getattr(stream, name)

Example 46

Project: popcorn_maker
Source File: __init__.py
View license
    def _height_and_width(self):
        """Return a tuple of (terminal height, terminal width)."""
        # tigetnum('lines') and tigetnum('cols') update only if we call
        # setupterm() again.
        for descriptor in self._init_descriptor, sys.__stdout__:
            try:
                return struct.unpack('hhhh', ioctl(descriptor, TIOCGWINSZ, '\000' * 8))[0:2]
            except IOError:
                pass
        return None, None  # Should never get here

Example 47

Project: uliweb
Source File: util.py
View license
    def __getattribute__(self, name):
        if name == '__members__':
            return dir(sys.__stdout__)
        try:
            stream = local.stream
        except AttributeError:
            stream = sys.__stdout__
        return getattr(stream, name)

Example 48

Project: dashboard
Source File: console.py
View license
    def __getattribute__(self, name):
        if name == '__members__':
            return dir(sys.__stdout__)
        try:
            stream = _local.stream
        except AttributeError:
            stream = sys.__stdout__
        return getattr(stream, name)

Example 49

Project: cgstudiomap
Source File: console.py
View license
    def __getattribute__(self, name):
        if name == '__members__':
            return dir(sys.__stdout__)
        try:
            stream = _local.stream
        except AttributeError:
            stream = sys.__stdout__
        return getattr(stream, name)

Example 50

Project: robotframework
Source File: test_running.py
View license
    def test_run_multiple_times_with_different_stdout_and_stderr(self):
        stdout, stderr = StringIO(), StringIO()
        self._run(stdout, stderr)
        self._assert_normal_stdout_stderr_are_empty()
        self._assert_output(stdout, [('My Suite', 2), ('My Test', 1)])
        self._assert_output(stderr, [('Hello, world!', 1)])
        stdout.close(); stderr.close()
        output = StringIO()
        self._run(output, output, variable='MESSAGE:Hi, again!')
        self._assert_normal_stdout_stderr_are_empty()
        self._assert_output(output, [('My Suite', 2), ('My Test', 1),
                                     ('Hi, again!', 1), ('Hello, world!', 0)])
        output.close()
        self._run(variable='MESSAGE:Last hi!')
        self._assert_output(sys.__stdout__, [('My Suite', 2), ('My Test', 1)])
        self._assert_output(sys.__stderr__, [('Last hi!', 1), ('Hello, world!', 0)])