From db139c2318dce5c361b5691fe2abe6747b1498c9 Mon Sep 17 00:00:00 2001 From: Leonardo Robol Date: Sun, 2 Oct 2011 12:33:54 +0200 Subject: [PATCH] Work (only) in python3. --- bundle.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) mode change 100644 => 100755 bundle.py diff --git a/bundle.py b/bundle.py old mode 100644 new mode 100755 index c245238..ebaccb8 --- a/bundle.py +++ b/bundle.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # # @@ -92,11 +92,11 @@ class Bundle(): def unbundle_app (self): """Unbundle app assuming that it is contained in this file""" with open(__file__, "rb") as handle: - self._bundle = handle.read () + self._bundle = handle.read ().decode ("utf-8") # Decode the content of the file start = self._bundle.index(15 * "#") - self._bundle = base64.b64decode (self._bundle[start + 14:]) + self._bundle = base64.b64decode (self._bundle[start + 14:].encode ("utf-8")) tmp_d = tempfile.mkdtemp () os.chdir (tmp_d) @@ -114,7 +114,12 @@ class Bundle(): shutil.rmtree (tmp_d) def ask (question): - return raw_input ("\033[32;1m> \033[0m" + question + ": ") + if sys.version_info > (3,0): + print ("\033[32;1m>\033[0m", str(question), ":", end=" ") + sys.stdout.flush () + return sys.stdin.readline ().strip ("\n") + else: + return raw_input ("\033[32;1m> \033[0m" + str(question) +": ") def print_msg (msg): print ("\033[31;1m> \033[0m%s" % msg) -- 2.1.4