sys.stdout.close

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

18 Examples 7

Example 1

Project: hospital
Source File: cli.py
View license
    def __exit__(self, exc_type, exc_value, traceback):
        self.stdout = self.stdout.getvalue()
        self.stderr = self.stderr.getvalue()
        sys.stdout.close()
        sys.stderr.close()
        sys.stdout = self.stdout_backup
        sys.stderr = self.stderr_backup

Example 2

View license
    def tearDown( self ):
        #close any open sockets
        for s in self.sockets:
            s.close()

        #stop any running monitors - this might be open if an exception was thrown before a test called monitor.stop()
        if self.monitor != None:
            self.monitor.stop( wait_on_join=False )

        self.logger.removeHandler( self.handler )
        self.handler.close()

        #restore stdout
        sys.stdout.close()
        sys.stdout = self.old

Example 3

Project: xraylarch
Source File: utils.py
View license
    def tearDown(self):
        sys.stdout.close()
        try:
            os.unlink(sys.stdout.name)
        except:
            pass

Example 4

Project: btc
Source File: btc.py
View license
def finish():
    try:
        sys.stdout.close()
    except:
        pass
    try:
        sys.stderr.close()
    except:
        pass

Example 5

Project: ceph-deploy
Source File: cli.py
View license
def main(args=None, namespace=None):
    try:
        _main(args=args, namespace=namespace)
    finally:
        # This block is crucial to avoid having issues with
        # Python spitting non-sense thread exceptions. We have already
        # handled what we could, so close stderr and stdout.
        if not os.environ.get('CEPH_DEPLOY_TEST'):
            try:
                sys.stdout.close()
            except:
                pass
            try:
                sys.stderr.close()
            except:
                pass

Example 6

Project: dtags
Source File: utils.py
View license
def close_stdio():
    """Close stdout and stderr."""
    try:
        sys.stdout.close()
    except IOError:
        pass
    try:
        sys.stderr.close()
    except IOError:
        pass

Example 7

Project: dtags
Source File: utils.py
View license
def close_stdio():
    """Close stdout and stderr."""
    try:
        sys.stdout.close()
    except IOError:
        pass
    try:
        sys.stderr.close()
    except IOError:
        pass

Example 8

Project: django-vmail
Source File: command_tests.py
View license
    def tearDown(self):
        sys.stdout.close()
        sys.stdout = self.sysout

        sys.stderr.close()
        sys.stderr = self.syserr

Example 9

Project: pytest-plugins
Source File: run.py
View license
def _run_in_subprocess_redirect_stdout(fd):
    import os  # @Reimport
    import sys  # @Reimport
    sys.stdout.close()
    os.dup2(fd, 1)
    os.close(fd)
    sys.stdout = os.fdopen(1, 'w', 1)

Example 10

Project: pytest-plugins
Source File: run.py
View license
def _run_in_subprocess_redirect_stdout(fd):
    import os  # @Reimport
    import sys  # @Reimport
    sys.stdout.close()
    os.dup2(fd, 1)
    os.close(fd)
    sys.stdout = os.fdopen(1, 'w', 1)

Example 11

Project: bottle-nt-service
Source File: bottle_service.py
View license
    def redirectOutput(self):
        """ Redirect stdout and stderr to the bit-bucket.

        Windows NT Services do not do well with data being written to stdout/stderror.
        """
        sys.stdout.close()
        sys.stderr.close()
        sys.stdout = NullOutput()
        sys.stderr = NullOutput()

Example 12

Project: github-cli
Source File: base.py
View license
    def tearDown(self):
        sys.stdout.close()
        sys.stdout = self.stdout

Example 13

Project: names
Source File: test_names.py
View license
    def __exit__(self, exc_type, exc_value, traceback):
        sys.stdout.close()
        sys.stdout = self.real_stdout

Example 14

Project: Ezhil-Lang
Source File: EzhilTestRunner.py
View license
    def tearDown(self):
        sys.stdout.close()
        sys.stderr.close()

        sys.stdout = self.old
        sys.stdout = self.olderr

        if self.debug:
            print("############### STDOUT #################")
            fp = codecs.open(self.get_filename(),"r","utf-8")
            print(fp.read())
            fp.close()
            print("################ STDERR #################")
            fp = codecs.open("err_"+self.get_filename(),"r","utf-8")
            print(fp.read())
            fp.close()
            print("################ END QUIET TEST ##########")
        
        os.unlink(self.get_filename())
        os.unlink("err_"+self.get_filename())

Example 15

Project: kde-plasma-mail-checker
Source File: main.py
View license
	def eventClose(self):
		print dateStamp() ,  '  eventCloseMethod'
		self.initStat = False
		self.disconnect(self, SIGNAL('refresh'), self.refreshData)
		self.disconnect(self, SIGNAL('access'), self.processInit)
		self.disconnect(self, SIGNAL('destroyed()'), self.eventClose)
		self.disconnect(self, SIGNAL('killThread'), self.killMailCheckerThread)
		self.idleThreadMessage.disconnect(self.idleMessage)
		self.idleingStopped.disconnect(self.idleingStoppedEvent)
		self.disableIconClick()
		self.deleteAkonadiMonitor()
		x = ''
		try :
			self.Timer.stop()
			if not(self.wallet is None) :
				self.wallet.closeWallet(self.appletName, True)
				print dateStamp() ,  ' wallet closed'
		except Exception, x :
			print dateStamp() , x, '  eventClose_1'
		finally : pass
		try :
			self.someFunctions.savePOP3Cache()
		except IOError, x :
			print dateStamp() ,x, '  eventClose_2'
		finally : pass
		self.killMailCheckerThread()
		self.GeneralLOCK.unlock()
		count = self.initValue('stayDebLog', '5')
		cleanDebugOutputLogFiles(int(count))
		print dateStamp() , "MailChecker destroyed manually."
		#sys.stderr.close()
		sys.stdout.close()

Example 16

Project: gpkit
Source File: helpers.py
View license
    def __exit__(self, *args):
        "Return stdout"
        sys.stdout.close()
        sys.stdout = self.original_stdout

Example 17

Project: Tale
Source File: test_console_io.py
View license
    def tearDown(self):
        sys.stdout.close()
        sys.stdout = self._orig_stdout

Example 18

Project: browser_invaders
Source File: tests.py
View license
    def tearDown(self):
        sys.stdout.close()
        sys.stdout = self.stdout
        sys.modules.pop("game", "")