summaryrefslogtreecommitdiffstats
path: root/presentty/text.py
diff options
context:
space:
mode:
Diffstat (limited to 'presentty/text.py')
-rw-r--r--presentty/text.py23
1 files changed, 13 insertions, 10 deletions
diff --git a/presentty/text.py b/presentty/text.py
index 92c0a26..37c3316 100644
--- a/presentty/text.py
+++ b/presentty/text.py
@@ -13,9 +13,12 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+from __future__ import absolute_import, division, print_function
+
import subprocess
import urwid
+from six.moves import input
class FigletText(urwid.WidgetWrap):
def __init__(self, text, attr=None):
@@ -34,17 +37,17 @@ class FigletText(urwid.WidgetWrap):
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
- except OSError, e:
+ except OSError as e:
if e.errno == 2:
print("ERROR: figlet is used but is not installed.")
else:
print("ERROR: unable to run figlet: %s" % e)
- raw_input("Press ENTER to continue.")
+ input("Press ENTER to continue.")
data = "[Unable to run figlet]"
else:
- p.stdin.write(self.text)
+ p.stdin.write(self.text.encode('utf-8'))
p.stdin.close()
- data = p.stdout.read()
+ data = p.stdout.read().decode('utf-8')
p.stderr.read()
p.wait()
return data
@@ -66,23 +69,23 @@ class CowsayText(urwid.WidgetWrap):
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
- except OSError, e:
+ except OSError as e:
if e.errno == 2:
print("ERROR: cowsay is used but is not installed.")
else:
print("ERROR: unable to run cowsay: %s" % e)
- raw_input("Press ENTER to continue.")
+ input("Press ENTER to continue.")
data = "[Unable to run cowsay]"
else:
- p.stdin.write(self.text)
+ p.stdin.write(self.text.encode('utf-8'))
p.stdin.close()
- data = p.stdout.read()
+ data = p.stdout.read().decode('utf-8')
p.stderr.read()
p.wait()
return data
def main():
- import slide
+ from . import slide
w = FigletText("Testing")
slpile = slide.SlidePile([])
slpile.contents.append((w, slpile.options()))
@@ -94,6 +97,6 @@ def main():
if True:
with screen.start():
screen.draw_screen((80,25), fill.render((80,25)))
- raw_input()
+ input()
if __name__=='__main__':
main()