当前位置: 首页>>代码示例>>Python>>正文


Python sys.__stdout__方法代码示例

本文整理汇总了Python中sys.__stdout__方法的典型用法代码示例。如果您正苦于以下问题:Python sys.__stdout__方法的具体用法?Python sys.__stdout__怎么用?Python sys.__stdout__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sys的用法示例。


在下文中一共展示了sys.__stdout__方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testfile

# 需要导入模块: import sys [as 别名]
# 或者: from sys import __stdout__ [as 别名]
def testfile(self):
        try:
            with open(self.filename) as fd:
                exec(compile(fd.read(), self.filename, 'exec'), {})
        except KeyboardInterrupt:
            raise RuntimeError('Keyboard interrupt')
        except ImportError as ex:
            module = ex.args[0].split()[-1].replace("'", '').split('.')[0]
            if module in ['scipy', 'matplotlib', 'Scientific', 'lxml',
                          'flask', 'argparse']:
                sys.__stdout__.write('skipped (no {0} module) '.format(module))
            else:
                raise
        except NotAvailable as notavailable:
            sys.__stdout__.write('skipped ')
            msg = str(notavailable)
            if msg:
                sys.__stdout__.write('({0}) '.format(msg)) 
开发者ID:pyscf,项目名称:pyscf,代码行数:20,代码来源:__init__.py

示例2: write

# 需要导入模块: import sys [as 别名]
# 或者: from sys import __stdout__ [as 别名]
def write(self,text):
        proceed = 1
        lineNo = 0
        addText = ''
        if self.func != None:
            proceed,lineNo,newText = self.func(text)
            if proceed:
            	if text.split() == []:
            		self.origOut.write(text)
            	else:
                #if goint to stdout then only add line no file etc
                #for stderr it is already there
                    if self.out:
                    	if lineNo:
                            try:
               			raise "Dummy"
               	            except:
               			newText =  'line('+str(sys.exc_info()[2].tb_frame.f_back.f_lineno)+'):'+newText
               			codeObject = sys.exc_info()[2].tb_frame.f_back.f_code
              			fileName = codeObject.co_filename
              			funcName = codeObject.co_name
                    	self.origOut.write('file '+fileName+','+'func '+funcName+':')
                	self.origOut.write(newText)
    #pass all other methods to __stdout__ so that we don't have to override them 
开发者ID:rafasashi,项目名称:razzy-spinner,代码行数:26,代码来源:kimmo.py

示例3: __init__

# 需要导入模块: import sys [as 别名]
# 或者: from sys import __stdout__ [as 别名]
def __init__(self, stream, descriptions, verbosity):
        super(EC2ApiTestResult, self).__init__()
        self.stream = stream
        self.showAll = verbosity > 1
        self.num_slow_tests = 10
        self.slow_tests = []  # this is a fixed-sized heap
        self.colorizer = None
        # NOTE(vish): reset stdout for the terminal check
        stdout = sys.stdout
        sys.stdout = sys.__stdout__
        for colorizer in [_Win32Colorizer, _AnsiColorizer, _NullColorizer]:
            if colorizer.supported():
                self.colorizer = colorizer(self.stream)
                break
        sys.stdout = stdout
        self.start_time = None
        self.last_time = {}
        self.results = {}
        self.last_written = None 
开发者ID:openstack,项目名称:ec2-api,代码行数:21,代码来源:colorizer.py

示例4: __init__

# 需要导入模块: import sys [as 别名]
# 或者: from sys import __stdout__ [as 别名]
def __init__(self, outfile=sys.__stdout__, backlog=False):
        # get original stdout
        self._orig_outfile = outfile

        # just in case we wrap at runtime o the future,
        # as we did with `colorama_wrapper` in the past
        self.outfile = self._orig_outfile

        # handle back logging
        self._backlog = StringIO()
        if backlog:
            self._has_backlog = True
        else:
            self._has_backlog = False

        # are colors supported ?
        self._has_colors = ui.output.colors()

        self._write_lock = False 
开发者ID:nil0x42,项目名称:phpsploit,代码行数:21,代码来源:wrapper.py

示例5: find_pep8_errors

# 需要导入模块: import sys [as 别名]
# 或者: from sys import __stdout__ [as 别名]
def find_pep8_errors(cls, filename=None, lines=None):
        try:
            sys.stdout = cStringIO.StringIO()
            config = {}

            # Ignore long lines on test files, as the test names can get long
            # when following our test naming standards.
            if cls._is_test(filename):
                config['ignore'] = ['E501']

            checker = pep8.Checker(filename=filename, lines=lines,
                                   **config)
            checker.check_all()
            output = sys.stdout.getvalue()
        finally:
            sys.stdout = sys.__stdout__

        errors = []
        for line in output.split('\n'):
            parts = line.split(' ', 2)
            if len(parts) == 3:
                location, error, desc = parts
                line_no = location.split(':')[1]
                errors.append('%s ln:%s %s' % (error, line_no, desc))
        return errors 
开发者ID:italia,项目名称:daf-recipes,代码行数:27,代码来源:test_coding_standards.py

示例6: quarterfinal

# 需要导入模块: import sys [as 别名]
# 或者: from sys import __stdout__ [as 别名]
def quarterfinal(FOLDER):    # 读取文件夹内的算法
    PLRS = []
    
    sys.path.append(os.path.abspath(FOLDER))    # 将AI文件夹加入环境路径
    for file in os.listdir(FOLDER):
        if file.endswith('.py') and len(PLRS) < 8:
            # 提取play函数
            try:
                name = file[:-3]
                ai = __import__(name)
                ai.play
                PLRS.append((name, ai))

            # 读取时出错
            except Exception as e:
                print('读取%r时出错:%s' % (file, e), file=sys.__stdout__)

    return PLRS


# 四分之一决赛 
开发者ID:chbpku,项目名称:paper.io.sessdsa,代码行数:23,代码来源:compN17Quarterfinal.py

示例7: quarterfinal

# 需要导入模块: import sys [as 别名]
# 或者: from sys import __stdout__ [as 别名]
def quarterfinal(FOLDER):# 读取文件夹内的算法
    PLRS = []
    
    sys.path.append(os.path.abspath(FOLDER))    # 将AI文件夹加入环境路径
    for file in os.listdir(FOLDER):
        if file.endswith('.py') and len(PLRS) < 2:
            # 提取play函数
            try:
                name = file[:-3]
                ai = __import__(name)
                ai.play
                PLRS.append((name, ai))

            # 读取时出错
            except Exception as e:
                print('读取%r时出错:%s' % (file, e), file=sys.__stdout__)

    return PLRS


# 半决赛 
开发者ID:chbpku,项目名称:paper.io.sessdsa,代码行数:23,代码来源:compF17Semifinal.py

示例8: quarterfinal

# 需要导入模块: import sys [as 别名]
# 或者: from sys import __stdout__ [as 别名]
def quarterfinal(FOLDER):# 读取文件夹内的算法
    PLRS = []
    
    sys.path.append(os.path.abspath(FOLDER))    # 将AI文件夹加入环境路径
    for file in os.listdir(FOLDER):
        if file.endswith('.py') and len(PLRS) < 8:
            # 提取play函数
            try:
                name = file[:-3]
                ai = __import__(name)
                ai.play
                PLRS.append((name, ai))

            # 读取时出错
            except Exception as e:
                print('读取%r时出错:%s' % (file, e), file=sys.__stdout__)

    return PLRS


# 半决赛 
开发者ID:chbpku,项目名称:paper.io.sessdsa,代码行数:23,代码来源:4.compN17Semifinal.py

示例9: cur_status

# 需要导入模块: import sys [as 别名]
# 或者: from sys import __stdout__ [as 别名]
def cur_status():
    firstRowOfTable = [' ']
    for i in range(len(players)):
        firstRowOfTable += [players[i][0]]
    x = PrettyTable(firstRowOfTable + ['Score'])

    for i in range(len(players)):
        x.add_row([players[i][0]] + boardRaw[i] + [board[i][4]])
        x.add_row([' '] * (len(players) + 2))

    os.system('clear')
    print(x, file=sys.__stdout__)

    # 积分条
    out = sorted(board, key=itemgetter(-1, 1, 0), reverse=True)
    for i in range(len(out)):
        print(
            '%15s%3d %s' % (out[i][0], out[i][-1], "----" * out[i][-1]),
            file=sys.__stdout__) 
开发者ID:chbpku,项目名称:paper.io.sessdsa,代码行数:21,代码来源:roundRobinWithScoreboard.py

示例10: execute_code

# 需要导入模块: import sys [as 别名]
# 或者: from sys import __stdout__ [as 别名]
def execute_code(cls, code):
        """ Executes supplied code as pure python and returns a list of stdout, stderr

        Args:
            code (string): Python code to execute

        Results:
            (list): stdout, stderr of executed python code

        Raises:
            ExecutionError when supplied python is incorrect

        Examples:
            >>> execute_code('print "foobar"')
            'foobar'
        """

        output = StringIO.StringIO()
        err = StringIO.StringIO()

        sys.stdout = output
        sys.stderr = err

        try:
            # pylint: disable=exec-used
            exec(code)
        # If the code is invalid, just skip the block - any actual code errors
        # will be raised properly
        except TypeError:
            pass
        sys.stdout = sys.__stdout__
        sys.stderr = sys.__stderr__

        results = list()
        results.append(output.getvalue())
        results.append(err.getvalue())
        results = ''.join(results)

        return results 
开发者ID:jpsenior,项目名称:sphinx-execute-code,代码行数:41,代码来源:__init__.py

示例11: Start

# 需要导入模块: import sys [as 别名]
# 或者: from sys import __stdout__ [as 别名]
def Start(self,func=None):
    	if self.out:
            sys.stdout = self
            self.origOut = sys.__stdout__
        else:
       	    sys.stderr= self
            self.origOut = sys.__stderr__
        if func:
            self.func = func
        else:
            self.func = self.TestHook
    #Stop will stop routing of print statements thru this class 
开发者ID:rafasashi,项目名称:razzy-spinner,代码行数:14,代码来源:kimmo.py

示例12: Stop

# 需要导入模块: import sys [as 别名]
# 或者: from sys import __stdout__ [as 别名]
def Stop(self):
    	self.origOut.flush()
    	if self.out:
            sys.stdout = sys.__stdout__
        else:
            sys.stderr = sys.__stderr__
            self.func = None
    #override write of stdout 
开发者ID:rafasashi,项目名称:razzy-spinner,代码行数:10,代码来源:kimmo.py

示例13: _decode_stdoutdata

# 需要导入模块: import sys [as 别名]
# 或者: from sys import __stdout__ [as 别名]
def _decode_stdoutdata(stdoutdata):
    """ Convert data read from stdout/stderr to unicode """
    if not isinstance(stdoutdata, bytes):
        return stdoutdata
    
    encoding = getattr(sys.__stdout__, "encoding", locale.getpreferredencoding())
    if encoding is None:
        return stdoutdata.decode()
    return stdoutdata.decode(encoding)

##########################################################################
# Import Stdlib Module
########################################################################## 
开发者ID:rafasashi,项目名称:razzy-spinner,代码行数:15,代码来源:internals.py

示例14: __dir__

# 需要导入模块: import sys [as 别名]
# 或者: from sys import __stdout__ [as 别名]
def __dir__(self):
        return dir(sys.__stdout__) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:4,代码来源:console.py

示例15: __getattribute__

# 需要导入模块: import sys [as 别名]
# 或者: from sys import __stdout__ [as 别名]
def __getattribute__(self, name):
        if name == "__members__":
            return dir(sys.__stdout__)
        try:
            stream = _local.stream
        except AttributeError:
            stream = sys.__stdout__
        return getattr(stream, name) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:10,代码来源:console.py


注:本文中的sys.__stdout__方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。