diff options
| author | Sebastian Heinlein <sebi@sebi-desktop> | 2007-03-12 00:17:29 +0100 |
|---|---|---|
| committer | Sebastian Heinlein <sebi@sebi-desktop> | 2007-03-12 00:17:29 +0100 |
| commit | 3df4fd5eeb785bc335f8b996d13b39ea69d90770 (patch) | |
| tree | 18ec7a93cb4e7b2fa431e77240e988cd8f3a23d2 /apt/cdrom.py | |
| parent | e061e734914ef5f87f4754ac38100cb6614a9f42 (diff) | |
| parent | 89ac70a4cdc9507e6db3921497680aea95b6a7c2 (diff) | |
| download | python-apt-3df4fd5eeb785bc335f8b996d13b39ea69d90770.tar.gz | |
* merge
Diffstat (limited to 'apt/cdrom.py')
| -rw-r--r-- | apt/cdrom.py | 48 |
1 files changed, 48 insertions, 0 deletions
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 + |
