View Single Post
Old 10-06-2017, 05:17 PM   #443
SKK
Addict
SKK makes transoceanic flights without the assistance of an airplaneSKK makes transoceanic flights without the assistance of an airplaneSKK makes transoceanic flights without the assistance of an airplaneSKK makes transoceanic flights without the assistance of an airplaneSKK makes transoceanic flights without the assistance of an airplaneSKK makes transoceanic flights without the assistance of an airplaneSKK makes transoceanic flights without the assistance of an airplaneSKK makes transoceanic flights without the assistance of an airplaneSKK makes transoceanic flights without the assistance of an airplaneSKK makes transoceanic flights without the assistance of an airplaneSKK makes transoceanic flights without the assistance of an airplane
 
Posts: 217
Karma: 55570
Join Date: Jun 2016
Location: N/A
Device: N/A
Quote:
Originally Posted by sergeyvl12 View Post
SKK,

This is because python is running without tty and thus buffers it's stdout. Probably I can't develop real terminal emulator for kobo because it has limited kernel (without pseudo terminal support)

For now the only solution I have is to put these lines at the beginning of your script:

class Unbuffered(object):
def __init__(self, stream):
self.stream = stream
def write(self, data):
self.stream.write(data)
self.stream.flush()
def writelines(self, datas):
self.stream.writelines(datas)
self.stream.flush()
def __getattr__(self, attr):
return getattr(self.stream, attr)

import sys
sys.stdout = Unbuffered(sys.stdout)
Thanks for your help! I added that code but now it says unbuffered object has no attribute write. So I guess I will just have to give up for now on getting python programs to run on a kobo.

Edit: Actually I made a mistake in the spacing on the code. It doesn't give that error anymore when I test it on the computer. Now to test it on the kobo.

Last edited by SKK; 10-06-2017 at 05:20 PM.
SKK is offline   Reply With Quote