summaryrefslogtreecommitdiff
path: root/portato
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.net>2009-01-15 13:29:30 +0100
committerRené 'Necoro' Neumann <necoro@necoro.net>2009-01-15 13:29:30 +0100
commit199a2ec3b17bc59e6854db2a96ed223d21803ce7 (patch)
treeafe43205298d4df838087dc778fd68fa9b6b8409 /portato
parent2aa260c13d2b23141a6644af6b27da243d1f3641 (diff)
downloadportato-199a2ec3b17bc59e6854db2a96ed223d21803ce7.tar.gz
portato-199a2ec3b17bc59e6854db2a96ed223d21803ce7.tar.bz2
portato-199a2ec3b17bc59e6854db2a96ed223d21803ce7.zip
Add prerequisite checking before startup
Diffstat (limited to 'portato')
-rw-r--r--portato/gui/__init__.py17
-rw-r--r--portato/gui/dialogs.py9
-rw-r--r--portato/gui/exceptions.py17
-rw-r--r--portato/gui/windows/main.py24
4 files changed, 59 insertions, 8 deletions
diff --git a/portato/gui/__init__.py b/portato/gui/__init__.py
index 5bbe4c8..e3f1172 100644
--- a/portato/gui/__init__.py
+++ b/portato/gui/__init__.py
@@ -3,7 +3,7 @@
# File: portato/gui/__init__.py
# This file is part of the Portato-Project, a graphical portage-frontend.
#
-# Copyright (C) 2006-2008 René 'Necoro' Neumann
+# Copyright (C) 2006-2009 René 'Necoro' Neumann
# This is free software. You may redistribute copies of it under the terms of
# the GNU General Public License version 2.
# There is NO WARRANTY, to the extent permitted by law.
@@ -12,8 +12,10 @@
from __future__ import absolute_import
-from .. import get_listener
+from ..helper import error
from .exception_handling import register_ex_handler
+from .exceptions import PreReqError
+from .dialogs import prereq_error_dialog
def run ():
from .windows.splash import SplashScreen
@@ -23,6 +25,11 @@ def run ():
s.show()
from .windows.main import MainWindow
- m = MainWindow(s)
- s.hide()
- m.main()
+ try:
+ m = MainWindow(s)
+ s.hide()
+ m.main()
+ except PreReqError, e:
+ error("Prerequisite not matched. Aborting.")
+ prereq_error_dialog(e)
+ s.hide()
diff --git a/portato/gui/dialogs.py b/portato/gui/dialogs.py
index f178d2b..edf34b7 100644
--- a/portato/gui/dialogs.py
+++ b/portato/gui/dialogs.py
@@ -3,7 +3,7 @@
# File: portato/gui/dialogs.py
# This file is part of the Portato-Project, a graphical portage-frontend.
#
-# Copyright (C) 2006-2008 René 'Necoro' Neumann
+# Copyright (C) 2006-2009 René 'Necoro' Neumann
# This is free software. You may redistribute copies of it under the terms of
# the GNU General Public License version 2.
# There is NO WARRANTY, to the extent permitted by law.
@@ -106,3 +106,10 @@ def file_chooser_dialog (title, parent):
fc.destroy()
return ret
+
+def prereq_error_dialog (e):
+ dialog = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, _("A prerequisite for starting Portato was not matched."))
+ dialog.format_secondary_text(e.message)
+ ret = dialog.run()
+ dialog.destroy()
+ return ret
diff --git a/portato/gui/exceptions.py b/portato/gui/exceptions.py
new file mode 100644
index 0000000..11bc83d
--- /dev/null
+++ b/portato/gui/exceptions.py
@@ -0,0 +1,17 @@
+# -*- coding: utf-8 -*-
+#
+# File: portato/gui/exceptions.py
+# This file is part of the Portato-Project, a graphical portage-frontend.
+#
+# Copyright (C) 2009 René 'Necoro' Neumann
+# This is free software. You may redistribute copies of it under the terms of
+# the GNU General Public License version 2.
+# There is NO WARRANTY, to the extent permitted by law.
+#
+# Written by René 'Necoro' Neumann <necoro@necoro.net>
+
+
+"""Arbitrary exceptions."""
+
+class PreReqError (Exception):
+ pass
diff --git a/portato/gui/windows/main.py b/portato/gui/windows/main.py
index 08c2033..970dcba 100644
--- a/portato/gui/windows/main.py
+++ b/portato/gui/windows/main.py
@@ -3,7 +3,7 @@
# File: portato/gui/windows/main.py
# This file is part of the Portato-Project, a graphical portage-frontend.
#
-# Copyright (C) 2006-2008 René 'Necoro' Neumann
+# Copyright (C) 2006-2009 René 'Necoro' Neumann
# This is free software. You may redistribute copies of it under the terms of
# the GNU General Public License version 2.
# There is NO WARRANTY, to the extent permitted by law.
@@ -38,6 +38,7 @@ from ..views import LogView, HighlightView, InstalledOnlyView, LazyStoreView
from ..dialogs import (blocked_dialog, changed_flags_dialog, io_ex_dialog,
nothing_found_dialog, queue_not_empty_dialog, remove_deps_dialog,
remove_queue_dialog, remove_updates_dialog, unmask_dialog)
+from ..exceptions import PreReqError
# even more GUI stuff
from .basic import Window, Popup
@@ -424,6 +425,8 @@ class MainWindow (Window):
@type splash: SplashScreen
"""
+ self.check_prereqs()
+
if splash is None:
splash = lambda x: True
@@ -1865,7 +1868,24 @@ class MainWindow (Window):
Calls main_quit().
"""
gtk.main_quit()
-
+
+ def check_prereqs (self):
+
+ def fail (m):
+ error("PreReqError: %s", m)
+ raise PreReqError(m)
+
+ pdir = system.get_global_settings("PORTDIR")
+
+ if not os.path.exists(pdir):
+ fail(_("The portage tree is not existing."))
+
+ ls = os.listdir(system.get_global_settings("PORTDIR"))
+ if not "eclass" in ls:
+ fail(_("The portage tree seems to be empty."))
+
+ debug("All prereqs matched. Fine :)")
+
def main (self):
"""
Main.