summaryrefslogtreecommitdiff
path: root/apt
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2009-01-26 09:08:54 +0100
committerMichael Vogt <michael.vogt@ubuntu.com>2009-01-26 09:08:54 +0100
commit328db7f7d2c8779f2851479df1c28386701000bd (patch)
treef891d55759a73fa66da0708d651ab43416003eb6 /apt
parent029acf72fdc00598bedaf873a18854367043d4f9 (diff)
parent82fda8b9fa514ed8a268650f21ae9e76d713e1d4 (diff)
downloadpython-apt-328db7f7d2c8779f2851479df1c28386701000bd.tar.gz
* apt/cache.py:
- when running with the rootdir option, run InitConfig() again to ensure that the config from the rootdir is read, not from the host (lp: #243550) * apt/package.py: - make sure to set the defaulttimeout back to the original value (in getChangelog(), LP: #314212)
Diffstat (limited to 'apt')
-rw-r--r--apt/cache.py1
-rw-r--r--apt/package.py11
2 files changed, 8 insertions, 4 deletions
diff --git a/apt/cache.py b/apt/cache.py
index 0065d14c..a8432a32 100644
--- a/apt/cache.py
+++ b/apt/cache.py
@@ -55,6 +55,7 @@ class Cache(object):
apt_pkg.Config.Set("Dir", rootdir)
apt_pkg.Config.Set("Dir::State::status",
rootdir + "/var/lib/dpkg/status")
+ apt_pkg.InitConfig()
self.open(progress)
def _runCallbacks(self, name):
diff --git a/apt/package.py b/apt/package.py
index ecfd8b61..5a7da1f3 100644
--- a/apt/package.py
+++ b/apt/package.py
@@ -32,10 +32,6 @@ import apt_pkg
__all__ = 'BaseDependency', 'Dependency', 'Origin', 'Package', 'Record'
-# Set a timeout for the changelog download
-socket.setdefaulttimeout(2)
-
-
def _(string):
"""Return the translation of the string."""
return gettext.dgettext("python-apt", string)
@@ -596,7 +592,12 @@ class Package(object):
"prefix": prefix,
"src_pkg": src_pkg,
"src_ver": src_ver}
+
+ timeout = socket.getdefaultimeout()
try:
+ # Set a timeout for the changelog download
+ socket.setdefaulttimeout(2)
+
# Check if the download was canceled
if cancel_lock and cancel_lock.isSet():
return ""
@@ -649,6 +650,8 @@ class Package(object):
except (IOError, httplib.BadStatusLine):
return _("Failed to download the list of changes. \nPlease "
"check your Internet connection.")
+ finally:
+ socket.setdefaulttimeout(timeout)
return self._changelog
@property