~kelemeng/update-manager/bug640906

« back to all changes in this revision

Viewing changes to DistUpgrade/DistUpgradeViewNonInteractive.py

  • Committer: Bazaar Package Importer
  • Author(s): Michael Vogt
  • Date: 2010-08-05 22:49:07 UTC
  • Revision ID: james.westby@ubuntu.com-20100805224907-afmvphfxside1aw6
Tags: 1:0.142.5
* more python-apt 0.8 porting
* less updates to the progressbar
* DistUpgrade/DistUpgradeViewNonInteractive.py:
  - fix crash in non-interactive upgrader when a conffile prompt
    is detected

Show diffs side-by-side

added added

removed removed

Lines of Context:
82
82
            self.timeout = self.config.getint("NonInteractive","TerminalTimeout")
83
83
        except Exception, e:
84
84
            pass
85
 
    
 
85
 
86
86
    def error(self, pkg, errormsg):
87
87
        logging.error("got a error from dpkg for pkg: '%s': '%s'" % (pkg, errormsg))
88
88
        # check if re-run of maintainer script is requested
207
207
        InstallProgress.update_interface(self)
208
208
        if self.statusfd == None:
209
209
            return
210
 
 
211
210
        if (self.last_activity + self.timeout) < time.time():
212
 
            logging.warning("no activity %s seconds (%s) - sending ctrl-c" % (self.timeout, self.status))
 
211
            logging.warning("no activity %s seconds (%s) - sending ctrl-c" % (
 
212
                    self.timeout, self.status))
213
213
            # ctrl-c
214
214
            os.write(self.master_fd,chr(3))
 
215
        # read master fd and write to stdout so that terminal output
 
216
        # actualy works
 
217
        res = select.select([self.master_fd],[],[],0.1)
 
218
        while len(res[0]) > 0:
 
219
           self.last_activity = time.time()
 
220
           try:
 
221
               s = os.read(self.master_fd, 1)
 
222
               sys.stdout.write("%s" % s)
 
223
           except OSError,e:
 
224
               # happens after we are finished because the fd is closed
 
225
               return
 
226
           res = select.select([self.master_fd],[],[],0.1)
 
227
        sys.stdout.flush()
 
228
    
215
229
 
216
230
    def fork(self):
217
231
        logging.debug("doing a pty.fork()")
219
233
        os.environ["TERM"] = "dumb"
220
234
        # unset PAGER so that we can do "diff" in the dpkg prompt
221
235
        os.environ["PAGER"] = "true"
222
 
        return InstallProgress.fork(self)
223
 
        
 
236
        (self.pid, self.master_fd) = pty.fork()
 
237
        if self.pid != 0:
 
238
            logging.debug("pid is: %s" % self.pid)
 
239
        return self.pid
224
240
 
225
241
class DistUpgradeViewNonInteractive(DistUpgradeView):
226
242
    " non-interactive version of the upgrade view "