예제 #1
0
 def start_update(self):
     InstallProgress.start_update(self)
     self.last_activity = time.time()
     progress_log = self.config.getWithDefault("NonInteractive","DpkgProgressLog", False)
     if progress_log:
         fullpath = os.path.join(self.logdir, "dpkg-progress.%s.log" % self.install_run_number)
         logging.debug("writing dpkg progress log to '%s'" % fullpath)
         self.dpkg_progress_log = open(fullpath, "w")
     else:
         self.dpkg_progress_log = open(os.devnull, "w")
     self.dpkg_progress_log.write("%s: Start\n" % time.time())
class DistUpgradeViewText(DistUpgradeView):
    " text frontend of the distUpgrade tool "

    def __init__(self, datadir=None, logdir=None):
        # indicate that we benefit from using gnu screen
        self.needs_screen = True
        # its important to have a debconf frontend for
        # packages like "quagga"
        if not os.environ.has_key("DEBIAN_FRONTEND"):
            os.environ["DEBIAN_FRONTEND"] = "dialog"
        if not datadir:
            localedir = os.path.join(os.getcwd(), "mo")
        else:
            localedir = "/usr/share/locale/update-manager"

        try:
            gettext.bindtextdomain("update-manager", localedir)
            gettext.textdomain("update-manager")
        except Exception, e:
            logging.warning("Error setting locales (%s)" % e)

        self.last_step = 0  # keep a record of the latest step
        self._opCacheProgress = apt.progress.text.OpProgress()
        self._fetchProgress = TextFetchProgress()
        self._cdromProgress = TextCdromProgressAdapter()
        self._installProgress = InstallProgress()
        sys.excepthook = self._handleException
예제 #3
0
 def update_interface(self):
     InstallProgress.update_interface(self)
     if self.statusfd == None:
         return
     if (self.last_activity + self.timeout) < time.time():
         logging.warning("no activity %s seconds (%s) - sending ctrl-c" % (
                 self.timeout, self.status))
         # ctrl-c
         os.write(self.master_fd,chr(3))
     # read master fd and write to stdout so that terminal output
     # actualy works
     res = select.select([self.master_fd],[],[],0.1)
     while len(res[0]) > 0:
        self.last_activity = time.time()
        try:
            s = os.read(self.master_fd, 1)
            sys.stdout.write("%s" % s)
        except OSError:
            # happens after we are finished because the fd is closed
            return
        res = select.select([self.master_fd],[],[],0.1)
     sys.stdout.flush()
 def __init__(self, logdir):
     InstallProgress.__init__(self)
     logging.debug("setting up environ for non-interactive use")
     os.environ["DEBIAN_FRONTEND"] = "noninteractive"
     os.environ["APT_LISTCHANGES_FRONTEND"] = "none"
     os.environ["RELEASE_UPRADER_NO_APPORT"] = "1"
     self.config = DistUpgradeConfig(".")
     self.logdir = logdir
     self.install_run_number = 0
     try:
         if self.config.getWithDefault("NonInteractive","ForceOverwrite", False):
             apt_pkg.config.set("DPkg::Options::","--force-overwrite")
     except (NoSectionError, NoOptionError):
         pass
     # more debug
     #apt_pkg.Config.Set("Debug::pkgOrderList","true")
     #apt_pkg.Config.Set("Debug::pkgDPkgPM","true")
     # default to 2400 sec timeout
     self.timeout = 2400
     try:
         self.timeout = self.config.getint("NonInteractive","TerminalTimeout")
     except Exception:
         pass
예제 #5
0
 def __init__(self, logdir):
     InstallProgress.__init__(self)
     logging.debug("setting up environ for non-interactive use")
     if not os.environ.has_key("DEBIAN_FRONTEND"):
         os.environ["DEBIAN_FRONTEND"] = "noninteractive"
     os.environ["APT_LISTCHANGES_FRONTEND"] = "none"
     os.environ["RELEASE_UPRADER_NO_APPORT"] = "1"
     self.config = DistUpgradeConfig(".")
     self.logdir = logdir
     self.install_run_number = 0
     try:
         if self.config.getWithDefault("NonInteractive","ForceOverwrite", False):
             apt_pkg.config.set("DPkg::Options::","--force-overwrite")
     except (NoSectionError, NoOptionError):
         pass
     # more debug
     #apt_pkg.Config.Set("Debug::pkgOrderList","true")
     #apt_pkg.Config.Set("Debug::pkgDPkgPM","true")
     # default to 2400 sec timeout
     self.timeout = 2400
     try:
         self.timeout = self.config.getint("NonInteractive","TerminalTimeout")
     except Exception:
         pass
예제 #6
0
 def finish_update(self):
     InstallProgress.finish_update(self)
     self.dpkg_progress_log.write("%s: Finished\n" % time.time())
     self.dpkg_progress_log.close()
     self.install_run_number += 1