summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--_shm/shm_wrapper.py9
-rw-r--r--doc/Hooks16
-rw-r--r--etc/portato.cfg5
-rw-r--r--plugins/dbus_init.xml4
-rw-r--r--plugins/new_version.xml16
-rw-r--r--portato/backend/package.py5
-rw-r--r--portato/constants.py2
-rw-r--r--portato/dependency.py39
-rw-r--r--portato/gui/windows/main.py15
-rw-r--r--portato/gui/windows/preference.py12
-rw-r--r--portato/plistener.py5
-rw-r--r--portato/plugins/etc_proposals.py2
-rw-r--r--portato/plugins/new_version.py42
-rw-r--r--portato/plugins/notify.py2
14 files changed, 132 insertions, 42 deletions
diff --git a/_shm/shm_wrapper.py b/_shm/shm_wrapper.py
index bf29f65..851f588 100644
--- a/_shm/shm_wrapper.py
+++ b/_shm/shm_wrapper.py
@@ -24,6 +24,7 @@ import sys
# Third party modules
import shm
+from shm import error as shmerror
r"""shm_wrapper - A wrapper for the shm module which provides access
to System V shared memory and semaphores on *nix systems.
@@ -49,7 +50,7 @@ def create_memory(size, permissions = 0666, InitCharacter = ' '):
key = random.randint(1, sys.maxint - 1)
try:
memory = shm.create_memory(key, size, permissions)
- except shm.error, ExtraData:
+ except shmerror, ExtraData:
if shm.memory_haskey(key):
# Oops, bad luck, the key exists. I'll try another. I can't call
# memory_haskey() before calling create_memory() because that would create
@@ -59,7 +60,7 @@ def create_memory(size, permissions = 0666, InitCharacter = ' '):
pass
else:
# Uh-oh, something fundamental is wrong.
- raise shm.error, ExtraData
+ raise shmerror, ExtraData
# Here I implicitly discard the memory handle object returned to me by shm and instead
# return my own handle to the shared memory segment.
@@ -90,7 +91,7 @@ class SharedMemoryHandle(object):
try:
if self._MemoryHandle.attached:
self._MemoryHandle.detach()
- except shm.error:
+ except shmerror:
pass
@@ -187,7 +188,7 @@ def create_semaphore(InitialValue = 1, permissions = 0666):
key = random.randint(1, sys.maxint - 1)
try:
semaphore = shm.create_semaphore(key, InitialValue, permissions)
- except shm.error, ExtraData:
+ except shmerror, ExtraData:
if shm.semaphore_haskey(key):
# Oops, bad luck, the key exists. I'll try another. I can't call
# memory_haskey() before calling create_semaphore() because that would create
diff --git a/doc/Hooks b/doc/Hooks
index e0469e9..647dd56 100644
--- a/doc/Hooks
+++ b/doc/Hooks
@@ -7,7 +7,7 @@ Called: When emerge or every other command given by e.g. the synccmd preference
Parameters:
- string[] packages: Packages to emerge (includes "world", "system").
- string[] command: The exact command to execute.
- - portato.gui.wrapper.Console console: The console the output will be written to.
+ - vte.Console console: The console the output will be written to.
- function(string) -> None title_update: Function which updates the console title in the GUIs.
Return if override: Nothing
@@ -23,12 +23,10 @@ Parameters:
Return if override: Nothing
Comment: This uses an extra hook as emerge is started in an extra thread and thus all plugins being wanting to come "after" will be called while emerge is still running.
-open_ebuild:
-------------
-Called: When an ebuild window is opened.
-Parameters:
- - portato.backend.Package package: The current package whose is going to be displayed.
- - Window parent: The parent window. Exact type depends on the frontend.
+main:
+-----
+Called: When the main routine is being entered. Everything in the application is done inside this main routine. Hooks connecting "after" will be run, when the application is shutdown.
+Parameters: None
+Return if override: Nothing
-Return if override: Window-object which can be called by the frontends. Please see the explicit code to see what is expected.
-Comment: If you want to override - do this only for ONE specific frontend.
+Comment: DO NOT OVERRIDE :)
diff --git a/etc/portato.cfg b/etc/portato.cfg
index b653810..cab0414 100644
--- a/etc/portato.cfg
+++ b/etc/portato.cfg
@@ -75,11 +75,6 @@ searchontype = true
; show slots in the version list
showslots = true
-#
-# GTK-Section for options of the GTK-Frontend
-#
-[Gtk]
-
; sets the font of the console - string values
consolefont = Monospace 11
diff --git a/plugins/dbus_init.xml b/plugins/dbus_init.xml
index 8b93718..b17f269 100644
--- a/plugins/dbus_init.xml
+++ b/plugins/dbus_init.xml
@@ -7,9 +7,7 @@
<import>portato.plugins.dbus_init</import>
<hooks>
- <hook type="thread_init" call="dbus_init">
- <connect type="after" />
- </hook>
+ <hook type="main" call="dbus_init" />
</hooks>
</plugin>
diff --git a/plugins/new_version.xml b/plugins/new_version.xml
new file mode 100644
index 0000000..41c9ccb
--- /dev/null
+++ b/plugins/new_version.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<plugin xmlns="http://portato.sourceforge.net/plugin" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://portato.sourceforge.net/plugin http://portato.sourceforge.net/plugin.xsd">
+
+ <author>René 'Necoro' Neumann</author>
+ <name>New Version Reminder</name>
+
+ <import>portato.plugins.new_version</import>
+
+ <hooks>
+ <hook type="main" call="find_version" />
+ </hooks>
+
+ <menu>
+ <item call="find_version">Check for new _versions</item>
+ </menu>
+</plugin>
diff --git a/portato/backend/package.py b/portato/backend/package.py
index 4d3803f..78a4b1f 100644
--- a/portato/backend/package.py
+++ b/portato/backend/package.py
@@ -177,6 +177,7 @@ class Package (_Package):
"""
deps = " ".join(map(self.get_package_settings, ("RDEPEND", "PDEPEND", "DEPEND")))
deps = paren_reduce(deps)
+ debug("Dependencies: %s", deps)
tree = DependencyTree()
@@ -193,9 +194,9 @@ class Package (_Package):
elif dep == "||":
n = iter.next() # skip
if not hasattr(n, "__iter__"):
- n = tuple(n,)
+ n = [n]
else:
- n = tuple(n)
+ n = list(n)
tree.add_or(n)
diff --git a/portato/constants.py b/portato/constants.py
index 50975d1..1257256 100644
--- a/portato/constants.py
+++ b/portato/constants.py
@@ -63,7 +63,7 @@ SU_COMMAND = "gksu -D 'Portato'"
USE_CATAPULT = True
# config
-CONFIG_DIR = "/home/necoro/dev/portato/version_list/etc/"
+CONFIG_DIR = "/etc/portato/"
CONFIG_LOCATION = pjoin(CONFIG_DIR, "portato.cfg")
SESSION_DIR = pjoin(os.environ["HOME"], ".portato")
diff --git a/portato/dependency.py b/portato/dependency.py
index a52a630..cefc6ad 100644
--- a/portato/dependency.py
+++ b/portato/dependency.py
@@ -77,8 +77,8 @@ class OrDependency (Dependency):
:IVariables:
- dep : tuple(string,...)
- The dependency strings. The tuple and the strings are immutable.
+ dep : tuple(`Dependency`,...)
+ The dependencies. The tuple and the dependencies are immutable.
"""
def __init__ (self, deps):
@@ -89,13 +89,46 @@ class OrDependency (Dependency):
:type deps: iter<string>
"""
- self._dep = tuple(Dependency(dep) for dep in deps)
+ _dep = []
+ for dep in deps:
+ if not hasattr(dep, "__iter__"):
+ _dep.append(Dependency(dep))
+ else:
+ _dep.append(AllOfDependency(dep))
+
+ self._dep = tuple(_dep)
def __str__ (self):
return "<|| %s>" % str(self.dep)
__repr__ = __str__
+class AllOfDependency (Dependency):
+ """
+ Dependency representing a set of packages inside "or".
+ If the or is: ``|| (a ( b c ) )`` the `AllOfDependency` would be the ``( b c )``.
+
+ :IVariables:
+
+ dep : tuple(`Dependency`,...)
+ The dependencies . The tuple and the deps are immutable.
+ """
+
+ def __init__ (self, deps):
+ """
+ Creates an or-dependency out of a list (or tuple) of deps.
+
+ :param deps: The dependencies.
+ :type deps: iter<string>
+ """
+
+ self._dep = tuple(Dependency(dep) for dep in deps)
+
+ def __str__ (self):
+ return "<ALL %s>" % str(self.dep)
+
+ __repr__ = __str__
+
class DependencyTree (object):
"""
diff --git a/portato/gui/windows/main.py b/portato/gui/windows/main.py
index 7ce66b8..cde7461 100644
--- a/portato/gui/windows/main.py
+++ b/portato/gui/windows/main.py
@@ -254,7 +254,12 @@ class PackageTable:
orit = store.append(it, [self.icons["or"], _("One of the following")])
for dep in ordep.dep:
- store.append(orit, [get_icon(dep), dep.dep])
+ if isinstance(dep, dependency.AllOfDependency): # a list inside or
+ allit = store.append(orit, [None, _("All of the following")])
+ for adep in dep.dep:
+ store.append(allit, [get_icon(adep), adep.dep])
+ else:
+ store.append(orit, [get_icon(dep), dep.dep])
# normal
def sort_key (x):
@@ -744,7 +749,7 @@ class MainWindow (Window):
# notebooks
self.sysNotebook = self.tree.get_widget("systemNotebook")
self.pkgNotebook = self.tree.get_widget("packageNotebook")
- self.set_notebook_tabpos(map(PreferenceWindow.tabpos.get, map(int, (self.cfg.get("packageTabPos", "GTK"), self.cfg.get("systemTabPos", "GTK")))))
+ self.set_notebook_tabpos(map(PreferenceWindow.tabpos.get, map(int, (self.cfg.get("packageTabPos", "GUI"), self.cfg.get("systemTabPos", "GUI")))))
# the different scrolls
ebuildScroll = self.tree.get_widget("ebuildScroll")
@@ -820,7 +825,7 @@ class MainWindow (Window):
self.console.set_scrollback_lines(1024)
self.console.set_scroll_on_output(True)
- self.console.set_font_from_string(self.cfg.get("consolefont", "GTK"))
+ self.console.set_font_from_string(self.cfg.get("consolefont", "GUI"))
self.console.connect("button-press-event", self.cb_right_click)
self.termHB.pack_start(self.console, True, True)
@@ -1687,7 +1692,7 @@ class MainWindow (Window):
"""
Main.
"""
- plugin.hook("thread_init")(gobject.threads_init)()
+ gobject.threads_init()
# now subthreads can run normally, but are not allowed to touch the GUI. If threads should change sth there - use gobject.idle_add().
# for more informations on threading and gtk: http://www.async.com.br/faq/pygtk/index.py?req=show&file=faq20.006.htp
- gtk.main()
+ plugin.hook("main")(gtk.main)()
diff --git a/portato/gui/windows/preference.py b/portato/gui/windows/preference.py
index d69c99c..41db921 100644
--- a/portato/gui/windows/preference.py
+++ b/portato/gui/windows/preference.py
@@ -104,7 +104,7 @@ class PreferenceWindow (AbstractDialog):
# the console font button
self.consoleFontBtn = self.tree.get_widget("consoleFontBtn")
- self.consoleFontBtn.set_font_name(self.cfg.get("consolefont", section = "GTK"))
+ self.consoleFontBtn.set_font_name(self.cfg.get("consolefont", section = "GUI"))
# the comboboxes
self.systemTabCombo = self.tree.get_widget("systemTabCombo")
@@ -116,8 +116,8 @@ class PreferenceWindow (AbstractDialog):
for i in (_("Top"), _("Bottom"), _("Left"), _("Right")):
m.append((i,))
- self.systemTabCombo.set_active(int(self.cfg.get("systemTabPos", section = "GTK"))-1)
- self.pkgTabCombo.set_active(int(self.cfg.get("packageTabPos", section = "GTK"))-1)
+ self.systemTabCombo.set_active(int(self.cfg.get("systemTabPos", section = "GUI"))-1)
+ self.pkgTabCombo.set_active(int(self.cfg.get("packageTabPos", section = "GUI"))-1)
self.window.show_all()
@@ -137,14 +137,14 @@ class PreferenceWindow (AbstractDialog):
self.cfg.set(val,self.tree.get_widget(edit).get_text())
font = self.consoleFontBtn.get_font_name()
- self.cfg.set("consolefont", font, section = "GTK")
+ self.cfg.set("consolefont", font, section = "GUI")
self.console_fn(font)
pkgPos = self.pkgTabCombo.get_active()+1
sysPos = self.systemTabCombo.get_active()+1
- self.cfg.set("packageTabPos", str(pkgPos), section = "GTK")
- self.cfg.set("systemTabPos", str(sysPos), section = "GTK")
+ self.cfg.set("packageTabPos", str(pkgPos), section = "GUI")
+ self.cfg.set("systemTabPos", str(sysPos), section = "GUI")
self.tabpos_fn(map(self.tabpos.get, (pkgPos, sysPos)))
diff --git a/portato/plistener.py b/portato/plistener.py
index b5948ca..2e35ccb 100644
--- a/portato/plistener.py
+++ b/portato/plistener.py
@@ -71,7 +71,7 @@ class PListener (object):
Popen(cmdlist)
- def do_notify(self, base, descr, icon, urgency):
+ def do_notify(self, base, descr, icon, urgency = None):
"""Displays a notify.
This will do nothing if pynotify is not present and/or root is running the listener."""
@@ -80,7 +80,8 @@ class PListener (object):
pynotify.init(APP)
n = pynotify.Notification(base, descr, icon)
- n.set_urgency(int(urgency))
+ if urgency is not None and urgency != "":
+ n.set_urgency(int(urgency))
n.show()
def set_send (self, mem = None, sig = None, rw = None):
diff --git a/portato/plugins/etc_proposals.py b/portato/plugins/etc_proposals.py
index 77b6be5..62605c8 100644
--- a/portato/plugins/etc_proposals.py
+++ b/portato/plugins/etc_proposals.py
@@ -22,7 +22,7 @@ def launch (options = []):
if os.getuid() == 0:
Popen(PROG+options)
else:
- error(_("Cannot start etc-proposals. Not root!"))
+ error("ETC_PROPOSALS :: %s",_("Cannot start etc-proposals. Not root!"))
def etc_prop (*args, **kwargs):
"""Entry point for this plugin."""
diff --git a/portato/plugins/new_version.py b/portato/plugins/new_version.py
new file mode 100644
index 0000000..687e107
--- /dev/null
+++ b/portato/plugins/new_version.py
@@ -0,0 +1,42 @@
+try:
+ from bzrlib import plugin, branch
+except ImportError:
+ plugin = branch = None
+
+from threading import Thread
+
+import gobject
+
+from portato.helper import debug, warning
+from portato import get_listener
+from portato.constants import VERSION, APP_ICON, APP
+
+def find_thread (rev):
+ try:
+ b = branch.Branch.open("lp:portato")
+ except Exception, e:
+ warning("NEW_VERSION :: Exception occured while accessing the remote branch: %s", str(e))
+ return
+
+ debug("NEW_VERSION :: Installed rev: %s - Current rev: %s", rev, b.revno())
+ if int(rev) < int(b.revno()):
+ def callback():
+ get_listener().send_notify(base = "New Portato Live Version Found", descr = "You have rev. %s, but the most recent revision is %s." % (rev, b.revno()), icon = APP_ICON)
+ return False
+
+ gobject.idle_add(callback)
+
+def find_version (*args, **kwargs):
+ if not all((plugin, branch)):
+ return
+
+ v = VERSION.split()
+ if len(v) != 3 or v[0] != "9999":
+ return
+
+ rev = v[-1]
+
+ plugin.load_plugins() # to have lp: addresses parsed
+ t = Thread(target = find_thread, args=(rev,))
+ t.setDaemon(True)
+ t.start()
diff --git a/portato/plugins/notify.py b/portato/plugins/notify.py
index ae2addd..8bb0a87 100644
--- a/portato/plugins/notify.py
+++ b/portato/plugins/notify.py
@@ -8,7 +8,7 @@ from portato.constants import APP_ICON, APP
def notify (retcode, **kwargs):
if retcode is None:
- warning(_("Notify called while process is still running!"))
+ warning("NOTIFY :: %s", _("Notify called while process is still running!"))
else:
icon = APP_ICON
if retcode == 0: