summaryrefslogtreecommitdiff
path: root/apt/progress
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2014-01-06 13:42:46 +0100
committerJulian Andres Klode <jak@debian.org>2014-01-06 13:47:31 +0100
commit86b1fa71cf952c5f4aae1cabef332ba0d4f5885c (patch)
tree1ef5ca37678cd559f50d4235a05c9fecc14ab6ad /apt/progress
parent8b8a55f10ca47fe297fbb9b16a8e100658c60df3 (diff)
downloadpython-apt-86b1fa71cf952c5f4aae1cabef332ba0d4f5885c.tar.gz
Use a single code base for Python 2 and 3
This is much better than running 2to3 during the build, as it gives us more control over the Python 3 code.
Diffstat (limited to 'apt/progress')
-rw-r--r--apt/progress/base.py3
-rw-r--r--apt/progress/text.py15
2 files changed, 12 insertions, 6 deletions
diff --git a/apt/progress/base.py b/apt/progress/base.py
index 66d56173..95eca9ec 100644
--- a/apt/progress/base.py
+++ b/apt/progress/base.py
@@ -271,7 +271,8 @@ class InstallProgress(object):
try:
select.select([self.status_stream], [], [],
self.select_timeout)
- except select.error as (errno_, _errstr):
+ except select.error as error:
+ (errno_, _errstr) = error.args
if errno_ != errno.EINTR:
raise
diff --git a/apt/progress/text.py b/apt/progress/text.py
index 880a112c..d1f87539 100644
--- a/apt/progress/text.py
+++ b/apt/progress/text.py
@@ -25,6 +25,11 @@ from apt.progress import base
__all__ = ['AcquireProgress', 'CdromProgress', 'OpProgress']
+if sys.version_info.major < 3:
+ input = raw_input
+else:
+ long = int
+
def _(msg):
"""Translate the message, also try apt if translation is missing."""
@@ -93,7 +98,7 @@ class AcquireProgress(base.AcquireProgress, TextProgress):
base.AcquireProgress.__init__(self)
self._signal = None
self._width = 80
- self._id = 1
+ self._id = long(1)
def start(self):
"""Start an Acquire progress.
@@ -106,7 +111,7 @@ class AcquireProgress(base.AcquireProgress, TextProgress):
self._signal = signal.signal(signal.SIGWINCH, self._winch)
# Get the window size.
self._winch()
- self._id = 1L
+ self._id = long(1)
def _winch(self, *dummy):
"""Signal handler for window resize signals."""
@@ -217,7 +222,7 @@ class AcquireProgress(base.AcquireProgress, TextProgress):
self._write(_("Media change: please insert the disc labeled\n"
" '%s'\n"
"in the drive '%s' and press enter\n") % (medium, drive))
- return raw_input() not in ('c', 'C')
+ return input() not in ('c', 'C')
def stop(self):
"""Invoked when the Acquire process stops running."""
@@ -242,7 +247,7 @@ class CdromProgress(base.CdromProgress, TextProgress):
self._write(_("Please provide a name for this Disc, such as "
"'Debian 2.1r1 Disk 1'"), False)
try:
- return raw_input(":")
+ return input(":")
except KeyboardInterrupt:
return
@@ -258,6 +263,6 @@ class CdromProgress(base.CdromProgress, TextProgress):
self._write(_("Please insert a Disc in the drive and press enter"),
False)
try:
- return (raw_input() == '')
+ return (input() == '')
except KeyboardInterrupt:
return False