diff options
| author | Sebastian Heinlein <sebi@sebi-laptop> | 2007-02-26 19:51:04 +0100 |
|---|---|---|
| committer | Sebastian Heinlein <sebi@sebi-laptop> | 2007-02-26 19:51:04 +0100 |
| commit | 8e179c8fd3b02b0dacac7ecbfbd08447d9c9ba43 (patch) | |
| tree | 7bf9742f184310820922f7465a33578b7af28384 | |
| parent | a775bc53771d2c0665205fbec407014eea239682 (diff) | |
| parent | fb94875bd4e108c6d22e05d5312de7ed9f86b057 (diff) | |
| download | python-apt-8e179c8fd3b02b0dacac7ecbfbd08447d9c9ba43.tar.gz | |
* merge with mvo
| -rw-r--r-- | apt/__init__.py | 1 | ||||
| -rw-r--r-- | apt/cdrom.py | 48 | ||||
| -rw-r--r-- | apt/progress.py | 2 | ||||
| -rw-r--r-- | debian/changelog | 9 | ||||
| -rw-r--r-- | python/string.cc | 6 |
5 files changed, 64 insertions, 2 deletions
diff --git a/apt/__init__.py b/apt/__init__.py index 15df6990..c6a2ff39 100644 --- a/apt/__init__.py +++ b/apt/__init__.py @@ -7,6 +7,7 @@ import os from apt.package import Package from apt.cache import Cache from apt.progress import OpProgress, FetchProgress, InstallProgress, CdromProgress +from apt.cdrom import Cdrom from apt_pkg import SizeToStr, TimeToStr, VersionCompare # init the package system diff --git a/apt/cdrom.py b/apt/cdrom.py new file mode 100644 index 00000000..d499b30a --- /dev/null +++ b/apt/cdrom.py @@ -0,0 +1,48 @@ + +import apt_pkg +from apt.progress import CdromProgress + +class Cdrom(object): + def __init__(self, progress=None, mountpoint=None, nomount=True): + """ Support for apt-cdrom like features. + Options: + - progress: optional progress.CdromProgress() subclass + - mountpoint: optional alternative mountpoint + - nomount: do not mess with mount/umount the CD + """ + self._cdrom = apt_pkg.GetCdrom() + if progress is None: + self._progress = apt.progress.CdromProgress() + else: + self._progress = progress + # see if we have a alternative mountpoint + if mountpoint is not None: + apt_pkg.Config.Set("Acquire::cdrom::mount",mountpoint) + # do not mess with mount points by default + if nomount is True: + apt_pkg.Config.Set("APT::CDROM::NoMount", "true") + else: + apt_pkg.Config.Set("APT::CDROM::NoMount", "false") + def add(self): + " add cdrom to the sources.list " + return self._cdrom.Add(self._progress) + def ident(self): + " identify the cdrom " + (res, ident) = self._cdrom.Ident(self._progress) + if res: + return ident + return None + @property + def inSourcesList(self): + " check if the cdrom is already in the current sources.list " + cdid = self.ident() + if cdid is None: + # FIXME: throw exception instead + return False + # FIXME: check sources.list.d/ as well + for line in open(apt_pkg.Config.FindFile("Dir::Etc::sourcelist")): + line = line.strip() + if not line.startswith("#") and cdid in line: + return True + return False + diff --git a/apt/progress.py b/apt/progress.py index 5169adf7..bb1bce35 100644 --- a/apt/progress.py +++ b/apt/progress.py @@ -28,6 +28,8 @@ from errno import * import select import apt_pkg +import apt + class OpProgress(object): """ Abstract class to implement reporting on cache opening Subclass this class to implement simple Operation progress reporting diff --git a/debian/changelog b/debian/changelog index 79e6d078..7833dc00 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,12 @@ +python-apt (0.6.21) unstable; urgency=low + + * apt/cdrom.py: + - better cdrom handling support + * python/string.cc: + - SizeToString supports PyLong too + + -- + python-apt (0.6.20) unstable; urgency=low * python/generic.h: diff --git a/python/string.cc b/python/string.cc index 16adc8cd..d0926da5 100644 --- a/python/string.cc +++ b/python/string.cc @@ -53,9 +53,11 @@ PyObject *StrSizeToStr(PyObject *Self,PyObject *Args) if (PyArg_ParseTuple(Args,"O",&Obj) == 0) return 0; if (PyInt_Check(Obj)) - return CppPyString(SizeToStr(PyInt_AS_LONG(Obj))); + return CppPyString(SizeToStr(PyInt_AsLong(Obj))); + if (PyLong_Check(Obj)) + return CppPyString(SizeToStr(PyLong_AsLong(Obj))); if (PyFloat_Check(Obj)) - return CppPyString(SizeToStr(PyFloat_AS_DOUBLE(Obj))); + return CppPyString(SizeToStr(PyFloat_AsDouble(Obj))); PyErr_SetString(PyExc_TypeError,"Only understand integers and floats"); return 0; |
