本文整理汇总了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")
示例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'
示例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)
示例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()))))