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


Python io.InputStreamReader方法代码示例

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


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

示例1: view_source

# 需要导入模块: from java import io [as 别名]
# 或者: from java.io import InputStreamReader [as 别名]
def view_source(context, web_view, filename):
    from base64 import b64encode
    from os.path import join
    from pygments import highlight
    from pygments.formatters import HtmlFormatter
    from pygments.lexers import get_lexer_for_filename

    from java.io import BufferedReader, InputStreamReader

    stream = context.getAssets().open(join(ASSET_SOURCE_DIR, filename))
    reader = BufferedReader(InputStreamReader(stream))
    text = "\n".join(iter(reader.readLine, None))

    formatter = HtmlFormatter()
    body = highlight(text, get_lexer_for_filename(filename), formatter)
    html = ("<html><head><style>{}\n{}</style></head><body>{}</body></html>"
            .format(formatter.get_style_defs(), EXTRA_CSS, body)).encode()
    web_view.loadData(b64encode(html).decode(), "text/html", "base64") 
开发者ID:chaquo,项目名称:chaquopy,代码行数:20,代码来源:ui_demo.py

示例2: run

# 需要导入模块: from java import io [as 别名]
# 或者: from java.io import InputStreamReader [as 别名]
def run(self):
        try:
            while (self.inStream.read() != -1):
                isr = InputStreamReader(self.inStream)
                br = BufferedReader(isr)
                print str(br.readLine())

        except BaseException as ex:
            print 'Could not read API input/output/error buffer\n' 
开发者ID:codewatchorg,项目名称:sqlipy,代码行数:11,代码来源:SQLiPy.py

示例3: _excmd

# 需要导入模块: from java import io [as 别名]
# 或者: from java.io import InputStreamReader [as 别名]
def _excmd(self, sshcmd):
        '''
        return (connected_ok, response_array)
        '''        
        connected_ok=True
        resp = []        
        try:
            conn = Connection(self.hostname)
            conn.connect()
            self.logger.info('ssh connection created.')
            isAuthenticated = conn.authenticateWithPassword(self.user, self.password)
            if not isAuthenticated:
                connected_ok=False
                self.logger.error('ssh failed to authenticatd.')
            else:
                self.logger.info('ssh authenticated.')
                sess = conn.openSession()
                
                self.logger.info('ssh session created.')
                sess.execCommand(sshcmd)
                self.logger.info('ssh command issued. cmd is %s'%sshcmd)
    
                stdout = StreamGobbler(sess.getStdout())
                br = BufferedReader(InputStreamReader(stdout))
                while True:
                    line = br.readLine()
                    if line is None:
                        break
                    else :
                        resp.append(line)
                self.logger.warning('ssh command output: '%resp)
        except IOException ,ex:
            connected_ok=False
            #print "oops..error,", ex            
            self.logger.error('ssh exception: %s'% ex) 
开发者ID:harryliu,项目名称:edwin,代码行数:37,代码来源:__init__.py

示例4: _stringio_as_reader

# 需要导入模块: from java import io [as 别名]
# 或者: from java.io import InputStreamReader [as 别名]
def _stringio_as_reader(s):
    return BufferedReader(InputStreamReader(ByteArrayInputStream(bytearray(s.getvalue())))) 
开发者ID:Acmesec,项目名称:CTFCrackTools-V2,代码行数:4,代码来源:_sslcerts.py


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