Пример #1
0
def main(args):
    arguments = apt_pkg.parse_commandline(
        apt_pkg.config, [('h', "help", "help"), ('v', "version", "version"),
                         ('d', "cdrom", "Acquire::cdrom::mount", "HasArg"),
                         ('r', "rename", "APT::CDROM::Rename"),
                         ('m', "no-mount", "APT::CDROM::NoMount"),
                         ('f', "fast", "APT::CDROM::Fast"),
                         ('n', "just-print", "APT::CDROM::NoAct"),
                         ('n', "recon", "APT::CDROM::NoAct"),
                         ('n', "no-act", "APT::CDROM::NoAct"),
                         ('a', "thorough", "APT::CDROM::Thorough"),
                         ('c', "config-file", "", "ConfigFile"),
                         ('o', "option", "", "ArbItem")], args)

    if apt_pkg.config.find_b("help") or apt_pkg.config.find_b("version"):
        return show_help()

    progress = apt.progress.text.CdromProgress()
    cdrom = apt_pkg.Cdrom()

    if not arguments:
        return show_help()
    elif arguments[0] == 'add':
        cdrom.add(progress)
    elif arguments[0] == 'ident':
        cdrom.ident(progress)
    else:
        sys.stderr.write('E: Invalid operation %s\n' % arguments[0])
        return 1
Пример #2
0
 def _writeDatabase(self):
     """ update apts cdrom.list """
     dbfile = apt_pkg.config.find_file("Dir::State::cdroms")
     cdrom = apt_pkg.Cdrom()
     id = cdrom.ident(apt.progress.base.CdromProgress())
     label = self._readDiskName()
     out = open(dbfile, "a")
     out.write('CD::%s "%s";\n' % (id, label))
     out.write('CD::%s::Label "%s";\n' % (id, label))
Пример #3
0
def main(args):
    arguments = apt_pkg.parse_commandline(apt_pkg.config,
                    [('h', "help", "help"),
                     ('v', "version", "version"),
                     ('d', "cdrom", "Acquire::cdrom::mount", "HasArg"),], args)

    if apt_pkg.config.find_b("help") or apt_pkg.config.find_b("version"):
        return show_help()

    progress = apt.progress.text.CdromProgress()
    cdrom = apt_pkg.Cdrom()

    if not arguments:
        return show_help()
    elif arguments[0] == 'add':
        cdrom.add(progress)
    elif arguments[0] == 'ident':
        cdrom.ident(progress)
    else:
        sys.stderr.write('E: Invalid operation %s\n' % arguments[0])
        return 1
    def on_button_add_cdrom_clicked(self):
        '''Show a dialog that allows to add a repository located on a CDROM
       or DVD'''
        # testing
        #apt_pkg.config.set("APT::CDROM::Rename","true")

        saved_entry = apt_pkg.config.find("Dir::Etc::sourcelist")
        tmp = tempfile.NamedTemporaryFile()
        apt_pkg.config.set("Dir::Etc::sourcelist", tmp.name)
        progress = CdromProgress(self.datadir, self, kapp)
        cdrom = apt_pkg.Cdrom()
        # if nothing was found just return
        try:
            res = cdrom.add(progress)
        except SystemError as msg:
            title = _("CD Error")
            primary = _("Error scanning the CD")
            text = "%s\n\n<small>%s</small>" % (primary, msg)
            #KMessageBox.sorry(self.userinterface, text, title)
            QMessageBox.warning(self.userinterface, title, text)
            return
        finally:
            apt_pkg.config.set("Dir::Etc::sourcelist", saved_entry)
            progress.close()

        if res == False:
            return
        # read tmp file with source name (read only last line)
        line = ""
        for x in open(tmp.name):
            line = x
        if line != "":
            full_path = "%s%s" % (apt_pkg.config.find_dir("Dir::Etc"),
                                  saved_entry)
            # insert cdrom source first, so that it has precedence over network sources
            self.sourceslist.list.insert(0, SourceEntry(line, full_path))
            self.set_modified_sourceslist()
Пример #5
0
#!/usr/bin/python
# example how to deal with the depcache

import apt_pkg
import sys

from progress import TextCdromProgress

# init
apt_pkg.init()

cdrom = apt_pkg.Cdrom()
print cdrom

progress = TextCdromProgress()

(res, ident) = cdrom.Ident(progress)
print "ident result is: %s (%s) " % (res, ident)

apt_pkg.Config.Set("APT::CDROM::Rename", "True")
cdrom.Add(progress)

print "Exiting"
sys.exit(0)