summaryrefslogtreecommitdiff
path: root/DistUpgrade
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2006-03-27 15:22:54 +0200
committerMichael Vogt <michael.vogt@ubuntu.com>2006-03-27 15:22:54 +0200
commit376af57686222fcddc489ca6a6088b6a23ec1ca1 (patch)
treed26b939e2ca0892675cff8bd76f8e5097c6cf75b /DistUpgrade
parent2592b1a3ce1da07de5bd40798be04d60879a8a69 (diff)
downloadpython-apt-376af57686222fcddc489ca6a6088b6a23ec1ca1.tar.gz
* if apt fails, try to recover with "dpkg --configure -a"
Diffstat (limited to 'DistUpgrade')
-rw-r--r--DistUpgrade/DistUpgradeControler.py7
-rw-r--r--DistUpgrade/DistUpgradeView.py8
-rw-r--r--DistUpgrade/DistUpgradeViewGtk.py21
3 files changed, 30 insertions, 6 deletions
diff --git a/DistUpgrade/DistUpgradeControler.py b/DistUpgrade/DistUpgradeControler.py
index 972ea2dc..874eaf0b 100644
--- a/DistUpgrade/DistUpgradeControler.py
+++ b/DistUpgrade/DistUpgradeControler.py
@@ -213,9 +213,10 @@ class DistUpgradeControler(object):
# installing the packages failed, can't be retried
self._view.error(_("Could not install the upgrades"),
_("The upgrade aborts now. Your system "
- "can be in an unusable state. Please "
- "try 'sudo apt-get install -f' or Synaptic "
- "to fix your system."), "%s" % e)
+ "can be in an unusable state. A recovery "
+ "is now run (dpkg --configure -a)."),
+ "%s" % e)
+ self._view.getTerminal().call(["dpkg","--configure","-a"])
return False
except IOError, e:
# fetch failed, will be retried
diff --git a/DistUpgrade/DistUpgradeView.py b/DistUpgrade/DistUpgradeView.py
index 8e9a3d3f..02894939 100644
--- a/DistUpgrade/DistUpgradeView.py
+++ b/DistUpgrade/DistUpgradeView.py
@@ -19,6 +19,12 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA
+class DumbTerminal(object):
+ def run(self, cmd):
+ " expects a command in the subprocess style (as a list) "
+ subprocess.call(cmd)
+
+
class DistUpgradeView(object):
" abstraction for the upgrade view "
def __init__(self):
@@ -32,6 +38,8 @@ class DistUpgradeView(object):
def getInstallProgress(self):
" return a install progress object "
return apt.progress.InstallProgress()
+ def getTerminal(self):
+ return DumbTerminal()
def updateStatus(self, msg):
""" update the current status of the distUpgrade based
on the current view
diff --git a/DistUpgrade/DistUpgradeViewGtk.py b/DistUpgrade/DistUpgradeViewGtk.py
index 1e1edc67..b095478c 100644
--- a/DistUpgrade/DistUpgradeViewGtk.py
+++ b/DistUpgrade/DistUpgradeViewGtk.py
@@ -210,6 +210,14 @@ class GtkInstallProgressAdapter(InstallProgress):
gtk.main_iteration()
time.sleep(0.02)
+class DistUpgradeVteTerminal(object):
+ def __init__(self, parent, term):
+ self.term = term
+ self.parent = parent
+ def call(self, cmd):
+ self.term.show()
+ self.parent.expander_terminal.set_expanded(True)
+ self.term.fork_command(command=cmd[0],argv=cmd)
class DistUpgradeViewGtk(DistUpgradeView,SimpleGladeApp):
" gtk frontend of the distUpgrade tool "
@@ -258,13 +266,20 @@ class DistUpgradeViewGtk(DistUpgradeView,SimpleGladeApp):
"\n".join(lines))
sys.exit(1)
+ def getTerminal(self):
+ return DistUpgradeVteTerminal(self, self._term)
+
def create_terminal(self, arg1,arg2,arg3,arg4):
" helper to create a vte terminal "
self._term = vte.Terminal()
self._term.set_font_from_string("monospace 10")
self._term.connect("contents-changed", self._term_content_changed)
self._terminal_lines = []
- self._terminal_log = open("/var/log/dist-upgrade-term.log","w")
+ try:
+ self._terminal_log = open("/var/log/dist-upgrade-term.log","w")
+ except IOError:
+ # if something goes wrong (permission denied etc), use stdout
+ self._terminal_log = sys.stdout
return self._term
def _term_content_changed(self, term):
@@ -437,7 +452,8 @@ if __name__ == "__main__":
view = DistUpgradeViewGtk()
ip = GtkInstallProgressAdapter(view)
ip.conffile("TODO","TODO~")
-
+ view.getTerminal().call(["dpkg","--configure","-a"])
+ #view.getTerminal().call(["ls"])
view.error("short","long",
"asfds afsdj af asdf asdf asf dsa fadsf asdf as fasf sextended\n"
"asfds afsdj af asdf asdf asf dsa fadsf asdf as fasf sextended\n"
@@ -448,4 +464,3 @@ if __name__ == "__main__":
"asfds afsdj af asdf asdf asf dsa fadsf asdf as fasf sextended\n"
)
#view.confirmChanges("xx",[], 100)
-