def confirmChanges(self,
                    summary,
                    changes,
                    demotions,
                    downloadSize,
                    actions=None,
                    removal_bold=True):
     DistUpgradeView.confirmChanges(self, summary, changes, demotions,
                                    downloadSize, actions)
     print
     print twrap(summary)
     print twrap(self.confirmChangesMessage)
     print " %s %s" % (_("Continue [yN] "), _("Details [d]")),
     while True:
         res = sys.stdin.readline()
         # TRANSLATORS: the "y" is "yes"
         if res.strip().lower().startswith(_("y")):
             return True
         # TRANSLATORS: the "n" is "no"
         elif res.strip().lower().startswith(_("n")):
             return False
         # TRANSLATORS: the "d" is "details"
         elif res.strip().lower().startswith(_("d")):
             output = ""
             if len(self.demotions) > 0:
                 output += "\n"
                 output += twrap(_("No longer supported: %s\n") %
                                 " ".join([p.name for p in self.demotions]),
                                 subsequent_indent='  ')
             if len(self.toRemove) > 0:
                 output += "\n"
                 output += twrap(_("Remove: %s\n") %
                                 " ".join([p.name for p in self.toRemove]),
                                 subsequent_indent='  ')
             if len(self.toRemoveAuto) > 0:
                 output += twrap(
                     _("Remove (was auto installed) %s") %
                     " ".join([p.name for p in self.toRemoveAuto]),
                     subsequent_indent='  ')
                 output += "\n"
             if len(self.toInstall) > 0:
                 output += "\n"
                 output += twrap(_("Install: %s\n") %
                                 " ".join([p.name for p in self.toInstall]),
                                 subsequent_indent='  ')
             if len(self.toUpgrade) > 0:
                 output += "\n"
                 output += twrap(_("Upgrade: %s\n") %
                                 " ".join([p.name for p in self.toUpgrade]),
                                 subsequent_indent='  ')
             self.showInPager(output)
         print "%s %s" % (_("Continue [yN] "), _("Details [d]")),
 def askYesNoQuestion(self, summary, msg, default='No'):
     print
     print twrap(summary)
     print twrap(msg)
     if default == 'No':
         print _("Continue [yN] "),
         res = sys.stdin.readline()
         # TRANSLATORS: first letter of a positive (yes) answer
         if res.strip().lower().startswith(_("y")):
             return True
         return False
     else:
         print _("Continue [Yn] "),
         res = sys.stdin.readline()
         # TRANSLATORS: first letter of a negative (no) answer
         if res.strip().lower().startswith(_("n")):
             return False
         return True
 def askYesNoQuestion(self, summary, msg, default='No'):
   print
   print twrap(summary)
   print twrap(msg)
   if default == 'No':
       print _("Continue [yN] "),
       res = sys.stdin.readline()
       # TRANSLATORS: first letter of a positive (yes) answer
       if res.strip().lower().startswith(_("y")):
           return True
       return False
   else:
       print _("Continue [Yn] "),
       res = sys.stdin.readline()
       # TRANSLATORS: first letter of a negative (no) answer
       if res.strip().lower().startswith(_("n")):
           return False
       return True
 def confirmChanges(self, summary, changes, demotions, downloadSize,
                    actions=None, removal_bold=True):
   DistUpgradeView.confirmChanges(self, summary, changes, demotions, 
                                  downloadSize, actions)
   print
   print twrap(summary)
   print twrap(self.confirmChangesMessage)
   print " %s %s" % (_("Continue [yN] "), _("Details [d]")),
   while True:
     res = sys.stdin.readline()
     # TRANSLATORS: the "y" is "yes"
     if res.strip().lower().startswith(_("y")):
       return True
     # TRANSLATORS: the "n" is "no"
     elif res.strip().lower().startswith(_("n")):
       return False
     # TRANSLATORS: the "d" is "details"
     elif res.strip().lower().startswith(_("d")):
       output = ""
       if len(self.demotions) > 0:
           output += "\n"  
           output += twrap(
               _("No longer supported: %s\n") % " ".join([p.name for p in self.demotions]),
               subsequent_indent='  ')
       if len(self.toRemove) > 0:
           output += "\n"  
           output += twrap(
               _("Remove: %s\n") % " ".join([p.name for p in self.toRemove]),
               subsequent_indent='  ')
       if len(self.toRemoveAuto) > 0:
           output += twrap(
               _("Remove (was auto installed) %s") % " ".join([p.name for p in self.toRemoveAuto]), 
               subsequent_indent='  ')
           output += "\n"
       if len(self.toInstall) > 0:
           output += "\n"
           output += twrap(
               _("Install: %s\n") % " ".join([p.name for p in self.toInstall]),
               subsequent_indent='  ')
       if len(self.toUpgrade) > 0:
           output += "\n"  
           output += twrap(
               _("Upgrade: %s\n") % " ".join([p.name for p in self.toUpgrade]),
               subsequent_indent='  ')
       self.showInPager(output)
     print "%s %s" % (_("Continue [yN] "), _("Details [d]")),
 def error(self, summary, msg, extended_msg=None):
     print
     print twrap(summary)
     print twrap(msg)
     if extended_msg:
         print twrap(extended_msg)
     return False
 def error(self, summary, msg, extended_msg=None):
   print
   print twrap(summary)
   print twrap(msg)
   if extended_msg:
     print twrap(extended_msg)
   return False
 def information(self, summary, msg, extended_msg=None):
     print
     print twrap(summary)
     print twrap(msg)
     if extended_msg:
         print twrap(extended_msg)
     print _("To continue please press [ENTER]")
     sys.stdin.readline()
 def information(self, summary, msg, extended_msg=None):
   print
   print twrap(summary)
   print twrap(msg)
   if extended_msg:
     print twrap(extended_msg)
   print _("To continue please press [ENTER]")
   sys.stdin.readline()
 def showDemotions(self, summary, msg, demotions):
     self.information(summary, msg,
                      _("Demoted:\n") + twrap(", ".join(demotions)))
    def confirmRestart(self):
        return self.askYesNoQuestion(_("Restart required"),
                                     _("To finish the upgrade, a restart is "
                                       "required.\n"
                                       "If you select 'y' the system "
                                       "will be restarted."),
                                     default='No')

if __name__ == "__main__":
    view = DistUpgradeViewText()

    #while True:
    #    view.processEvents()

    print twrap(
        "89 packages are going to be upgraded.\nYou have to download a total of 82.7M.\nThis download will take about 10 minutes with a 1Mbit DSL connection and about 3 hours 12 minutes with a 56k modem.",
        subsequent_indent=" ")
    #sys.exit(1)

    view = DistUpgradeViewText()
    print view.askYesNoQuestion("hello", "Icecream?", "No")
    print view.askYesNoQuestion("hello", "Icecream?", "Yes")

    #view.confirmChangesMessage = "89 packages are going to be upgraded.\n You have to download a total of 82.7M.\n This download will take about 10 minutes with a 1Mbit DSL connection and about 3 hours 12 minutes with a 56k modem."
    #view.confirmChanges("xx",[], 100)
    sys.exit(0)

    view.confirmRestart()

    cache = apt.Cache()
    fp = view.getFetchProgress()
예제 #11
0
 def showDemotions(self, summary, msg, demotions):
     self.information(summary, msg, 
                      _("Demoted:\n")+twrap(", ".join(demotions)))
예제 #12
0
    def confirmRestart(self):
      return self.askYesNoQuestion(_("Restart required"),
                                   _("To finish the upgrade, a restart is "
                                     "required.\n"
                                     "If you select 'y' the system "
                                     "will be restarted."), default='No')


if __name__ == "__main__":
  view = DistUpgradeViewText()

  #while True:
  #    view.processEvents()
  
  print twrap("89 packages are going to be upgraded.\nYou have to download a total of 82.7M.\nThis download will take about 10 minutes with a 1Mbit DSL connection and about 3 hours 12 minutes with a 56k modem.", subsequent_indent=" ")
  #sys.exit(1)

  view = DistUpgradeViewText()
  print view.askYesNoQuestion("hello", "Icecream?", "No")
  print view.askYesNoQuestion("hello", "Icecream?", "Yes")
  

  #view.confirmChangesMessage = "89 packages are going to be upgraded.\n You have to download a total of 82.7M.\n This download will take about 10 minutes with a 1Mbit DSL connection and about 3 hours 12 minutes with a 56k modem."
  #view.confirmChanges("xx",[], 100)
  sys.exit(0)

  view.confirmRestart()

  cache = apt.Cache()
  fp = view.getFetchProgress()