sys.__stderr__.write

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

25 Examples 7

Example 1

Project: RIDE
Source File: outputcapture.py
View license
    def _release_and_log(self):
        stdout, stderr = self._release()
        if stdout:
            LOGGER.log_output(stdout)
        if stderr:
            LOGGER.log_output(stderr)
            sys.__stderr__.write(encode_output(stderr+'\n'))

Example 2

Project: RIDE
Source File: signalhandler.py
View license
    def __call__(self, signum, frame):
        self._signal_count += 1
        LOGGER.info('Received signal: %s.' % signum)
        if self._signal_count > 1:
            sys.__stderr__.write('Execution forcefully stopped.\n')
            raise SystemExit()
        sys.__stderr__.write('Second signal will force exit.\n')
        if self._running_keyword and not sys.platform.startswith('java'):
            self._stop_execution_gracefully()

Example 3

View license
def start_test(name, attrs):
    template = attrs['template']
    expected = attrs['doc']
    if template != expected:
        sys.__stderr__.write("Expected template '%s' but got '%s'.\n"
                             % (expected, template))

Example 4

Project: robotframework
Source File: listenerlibrary.py
View license
    def _close(self):
        if self.ROBOT_LIBRARY_SCOPE == 'TEST CASE':
            level = ' (%s)' % self.level
        else:
            level = ''
        sys.__stderr__.write("CLOSING %s%s\n" % (self.ROBOT_LIBRARY_SCOPE, level))

Example 5

Project: robotframework
Source File: signalhandler.py
View license
    def __call__(self, signum, frame):
        self._signal_count += 1
        LOGGER.info('Received signal: %s.' % signum)
        if self._signal_count > 1:
            sys.__stderr__.write('Execution forcefully stopped.\n')
            raise SystemExit()
        sys.__stderr__.write('Second signal will force exit.\n')
        if self._running_keyword and not sys.platform.startswith('java'):
            self._stop_execution_gracefully()

Example 6

View license
    def release_and_log(self):
        stdout, stderr = self._release()
        if stdout:
            LOGGER.log_output(stdout)
        if stderr:
            LOGGER.log_output(stderr)
            sys.__stderr__.write(stderr+'\n')
        if self._library_import:
            LOGGER.disable_library_import_logging()

Example 7

View license
    def __call__(self, signum, frame):
        self._signal_count += 1
        LOGGER.info('Received signal: %s.' % signum)
        if self._signal_count > 1:
            sys.__stderr__.write('Execution forcefully stopped.\n')
            raise SystemExit()
        sys.__stderr__.write('Second signal will force exit.\n')
        if self._running_keyword and not sys.platform.startswith('java'):
            self._stop_execution_gracefully()

Example 8

Project: pypet
Source File: pypetlogging.py
View license
    def write(self, buf):
        """Writes data from buffer to logger"""
        if not self._recursion:
            self._recursion = True
            try:
                for line in buf.rstrip().splitlines():
                    self._logger.log(self._log_level, line.rstrip())
            finally:
                self._recursion = False
        else:
            # If stderr is redirected to stdout we can avoid further recursion by
            sys.__stderr__.write('ERROR: Recursion in Stream redirection!')

Example 9

Project: plip
Source File: plipxml.py
View license
    def load_data(self, xmlfile):
        """Loads/parses an XML file and saves it as a tree if successful."""
        try:
            self.doc = etree.parse(xmlfile)
        except IOError:
            sys.__stderr__.write("XML %s file could not be read." % xmlfile)
            sys.exit(1)

Example 10

Project: plip
Source File: plipxml.py
View license
    def load_data(self, pdbid):
        """Loads and parses an XML resource and saves it as a tree if successful"""
        #TODO Implement error handling
        f = urllib2.urlopen("http://projects.biotec.tu-dresden.de/plip-rest/pdb/%s?format=xml" % pdbid.lower())
        try:
            self.doc = etree.parse(f)
        except IOError:
            sys.__stderr__.write("XML file for PDB ID %s could not be read." % pdbid)
            sys.exit(1)

Example 11

Project: mayatools
Source File: debug.py
View license
    def __call__(self, *args, **kwargs):
        arg_spec = [repr(x) for x in args]
        arg_spec.extend('%s=%r' % (k, v) for k, v in sorted(kwargs.iteritems()))
        sys.__stderr__.write('%s %08x %s(%s)\n' % (
            datetime.datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S.%f'),
            thread.get_ident(),
            self.wrapped_cmd.__name__,
            ', '.join(arg_spec),
        ))
        sys.__stdout__.flush()
        return self.wrapped_cmd(*args, **kwargs)

Example 12

Project: IsisWorld
Source File: developerconsole.py
View license
  def writeErr(self, line, copy = True):
    if copy: sys.__stderr__.write(line)
    line = '\1err\1%s\2' % line
    lines = line.split('\n')
    firstline = lines.pop(0)
    self.lines[-1] += firstline
    self.lines += lines
    self.frame['text'] = '\n'.join(self.lines[-9:])

Example 13

Project: firefox-flicks
Source File: log.py
View license
    def write(self, data):
        """Write message to logging object."""
        if in_sighandler:
            return sys.__stderr__.write(safe_str(data))
        if getattr(self._thread, 'recurse_protection', False):
            # Logger is logging back to this file, so stop recursing.
            return
        data = data.strip()
        if data and not self.closed:
            self._thread.recurse_protection = True
            try:
                self.logger.log(self.loglevel, safe_str(data))
            finally:
                self._thread.recurse_protection = False

Example 14

Project: firefox-flicks
Source File: log.py
View license
def _patch_logger_class():
    """Make sure loggers don't log while in a signal handler."""

    logging._acquireLock()
    try:
        OldLoggerClass = logging.getLoggerClass()
        if not getattr(OldLoggerClass, '_signal_safe', False):

            class SigSafeLogger(OldLoggerClass):
                _signal_safe = True

                def log(self, *args, **kwargs):
                    if in_sighandler:
                        sys.__stderr__.write('CANNOT LOG IN SIGHANDLER')
                        return
                    return OldLoggerClass.log(self, *args, **kwargs)
            logging.setLoggerClass(SigSafeLogger)
    finally:
        logging._releaseLock()

Example 15

Project: firefox-flicks
Source File: log.py
View license
    def write(self, data):
        """Write message to logging object."""
        if in_sighandler:
            return sys.__stderr__.write(safe_str(data))
        if getattr(self._thread, 'recurse_protection', False):
            # Logger is logging back to this file, so stop recursing.
            return
        data = data.strip()
        if data and not self.closed:
            self._thread.recurse_protection = True
            try:
                self.logger.log(self.loglevel, safe_str(data))
            finally:
                self._thread.recurse_protection = False

Example 16

Project: firefox-flicks
Source File: log.py
View license
def _patch_logger_class():
    """Make sure loggers don't log while in a signal handler."""

    logging._acquireLock()
    try:
        OldLoggerClass = logging.getLoggerClass()
        if not getattr(OldLoggerClass, '_signal_safe', False):

            class SigSafeLogger(OldLoggerClass):
                _signal_safe = True

                def log(self, *args, **kwargs):
                    if in_sighandler:
                        sys.__stderr__.write('CANNOT LOG IN SIGHANDLER')
                        return
                    return OldLoggerClass.log(self, *args, **kwargs)
            logging.setLoggerClass(SigSafeLogger)
    finally:
        logging._releaseLock()

Example 17

Project: golismero
Source File: doctest_driver.py
View license
    def report_start(self, out, test, example):
        if 1 <= self._verbosity <= 2:
            src = example.source.split('\n')[0]
            if len(src) > 60: src = src[:57]+'...'
            if isinstance(src, unicode): src = src.encode('utf8')
            lineno = test.lineno + example.lineno + 1
            if self._verbosity == 1:
                if self._stderr_term.CLEAR_LINE:
                    sys.__stderr__.write(self._stderr_term.CLEAR_LINE)
                else:
                    sys.__stderr__.write('\n')
            sys.__stderr__.write('%s  [Line %s] %s%s' %
                                 (self._stderr_term.BOLD, lineno,
                                  self._stderr_term.NORMAL, src))
            if self._verbosity == 2:
                sys.__stderr__.write('\n')

        else:
            DocTestRunner.report_start(self, out, test, example)
        sys.__stdout__.flush()
        self._current_test = (test, example)

        # Total hack warning: This munges the original source to
        # catch any keyboard interrupts, and turn them into special
        # ValueError interrupts.
        example.original_source = example.source
        if self._kbinterrupt_continue:
            example.source = ('try:\n%sexcept KeyboardInterrupt:\n    '
                              'raise ValueError("KEYBOARD-INTERRUPT")\n' %
                              doctest._indent(example.source))

Example 18

Project: qLib
Source File: OnCreated.py
View license
def msg(m):
	msg = "[%s OnCreated.py] %s" % (datetime.datetime.now().strftime("%y%m%d %H:%M.%S"), m)
	sys.__stderr__.write(msg+"\n")

Example 19

View license
    def _stderr(self, msg):
        sys.__stderr__.write("%s\n" % msg)

Example 20

Project: robotframework
Source File: listenerlibrary3.py
View license
    def close(self):
        sys.__stderr__.write('CLOSING Listener library 3\n')

Example 21

Project: b2bua
Source File: SipLogger.py
View license
    def write_stderr(self, *args, **kwargs):
        if kwargs.get('level', SIPLOG_INFO) < self.level:
            return
        sys.__stderr__.write(self.format(args, kwargs))

Example 22

Project: pypet
Source File: ioutils.py
View license
def errwrite(text):
    """Writes to stderr with linebreak"""
    sys.__stderr__.write(text + '\n')

Example 23

Project: mayatools
Source File: mayatools_batchgui.py
View license
def log(msg, *args):
    if args:
        msg = msg % args
    sys.__stderr__.write('[mayatools.batchgui:client] %s\n' % msg)
    sys.__stderr__.flush()

Example 24

Project: firefox-flicks
Source File: worker.py
View license
def safe_say(msg):
    sys.__stderr__.write('\n%s\n' % msg)

Example 25

Project: firefox-flicks
Source File: worker.py
View license
def safe_say(msg):
    sys.__stderr__.write('\n%s\n' % msg)