Python java.io.BufferedReader() Examples

The following are 7 code examples of java.io.BufferedReader(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module java.io , or try the search function .
Example #1
Source File: ui_demo.py    From chaquopy with MIT License 6 votes vote down vote up
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") 
Example #2
Source File: SQLiPy.py    From sqlipy with The Unlicense 5 votes vote down vote up
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' 
Example #3
Source File: __init__.py    From edwin with Apache License 2.0 5 votes vote down vote up
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) 
Example #4
Source File: _sslcerts.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
def _stringio_as_reader(s):
    return BufferedReader(InputStreamReader(ByteArrayInputStream(bytearray(s.getvalue())))) 
Example #5
Source File: _sslcerts.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
def _stringio_as_reader(s):
    return BufferedReader(InputStreamReader(ByteArrayInputStream(bytearray(s.getvalue())))) 
Example #6
Source File: _sslcerts.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
def _stringio_as_reader(s):
    return BufferedReader(InputStreamReader(ByteArrayInputStream(bytearray(s.getvalue())))) 
Example #7
Source File: _sslcerts.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
def _stringio_as_reader(s):
    return BufferedReader(InputStreamReader(ByteArrayInputStream(bytearray(s.getvalue()))))