Work (only) in python3.
Leonardo Robol [2011-10-02 10:33]
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)