diff options
Diffstat (limited to '')
-rw-r--r-- | plugins/etc_proposals.py | 4 | ||||
-rw-r--r-- | plugins/new_version.py | 60 | ||||
-rw-r--r-- | plugins/notify.py | 5 | ||||
-rw-r--r-- | plugins/package_details.py | 6 |
4 files changed, 39 insertions, 36 deletions
diff --git a/plugins/etc_proposals.py b/plugins/etc_proposals.py index 83b38f7..052f3d3 100644 --- a/plugins/etc_proposals.py +++ b/plugins/etc_proposals.py @@ -10,8 +10,6 @@ # # Written by René 'Necoro' Neumann <necoro@necoro.net> -from portato.helper import error - import os from subprocess import Popen @@ -31,7 +29,7 @@ class EtcProposals (WidgetPlugin): if os.getuid() == 0: Popen(self.prog+options) else: - error("ETC_PROPOSALS :: %s",_("Cannot start etc-proposals. Not root!")) + helper.error("ETC_PROPOSALS :: %s",_("Cannot start etc-proposals. Not root!")) def hook (self, *args, **kwargs): """Entry point for this plugin.""" diff --git a/plugins/new_version.py b/plugins/new_version.py index 94e61ca..9fa5f4e 100644 --- a/plugins/new_version.py +++ b/plugins/new_version.py @@ -12,16 +12,11 @@ from portato.helper import debug, warning -try: - from bzrlib import plugin, branch -except ImportError: - plugin = branch = None - warning("NEW_VERSION :: Cannot import 'bzrlib'") - +from subprocess import Popen, PIPE import gobject from portato import get_listener -from portato.constants import REPOURI, VERSION, APP_ICON, APP +from portato.constants import REPOURI, REVISION, APP_ICON, APP from portato.gui.utils import GtkThread class NewVersionFinder(WidgetPlugin): @@ -29,7 +24,7 @@ class NewVersionFinder(WidgetPlugin): Checks for a new version of portato every 30 minutes and on startup. """ __author__ = "René 'Necoro' Neumann" - __dependency__ = ["dev-util/bzr"] + __dependency__ = ["dev-util/git"] def init (self): self.add_call("main", self.run) @@ -37,20 +32,30 @@ class NewVersionFinder(WidgetPlugin): def widget_init (self): self.create_widget("Plugin Menu", "Check for new _versions", activate = self.menu) + def get_notify_callback (self, rev): + def callback(): + get_listener().send_notify( + base = "New Portato Live Version Found", + descr = "The most recent revision is %s." % rev, + icon = APP_ICON) + return False + + return callback + def find_version (self, rev): - try: - b = branch.Branch.open(REPOURI) - 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) + + repo, branch = REPOURI.split('::') + + remote_rev = Popen(['git', 'ls-remote', repo, branch], stdout = PIPE).communicate()[0].strip().split('\t') + + if len(remote_rev) and remote_rev[1] not in (branch, 'refs/heads/'+branch, 'refs/tags/'+branch): + warning('NEW_VERSION :: Returned revision information looks strange: %s', str(remote_rev)) + else: + remote_rev = remote_rev[0] + debug("NEW_VERSION :: Installed rev: %s - Current rev: %s", remote_rev, rev) + + if rev != remote_rev: + gobject.idle_add(self.get_notify_callback(remote_rev)) def start_thread(self, rev): t = GtkThread(target = self.find_version, name = "Version Updater Thread", args = (rev,)) @@ -62,16 +67,11 @@ class NewVersionFinder(WidgetPlugin): """ Run the thread once. """ - v = VERSION.split() - if len(v) != 3: + if not REVISION: return None - - rev = v[-1] - - plugin.load_plugins() # to have lp: addresses parsed - self.start_thread(rev) - return rev + self.start_thread(REVISION) + return REVISION def run (self, *args, **kwargs): """ @@ -82,4 +82,4 @@ class NewVersionFinder(WidgetPlugin): if rev is not None: gobject.timeout_add(30*60*1000, self.start_thread, rev) # call it every 30 minutes -register(NewVersionFinder, (branch is None)) +register(NewVersionFinder, REVISION == '') diff --git a/plugins/notify.py b/plugins/notify.py index 3670e20..4aba2c6 100644 --- a/plugins/notify.py +++ b/plugins/notify.py @@ -14,14 +14,13 @@ disable = False from portato import get_listener -from portato.helper import warning, error, debug from portato.constants import APP_ICON, APP try: import pynotify except ImportError: disable = True - warning("NOTIFY :: %s", _("Cannot import 'pynotify'.")) + helper.warning("NOTIFY :: %s", _("Cannot import 'pynotify'.")) class Notify (Plugin): __author__ = "René 'Necoro' Neumann" @@ -33,7 +32,7 @@ class Notify (Plugin): def notify (self, retcode, **kwargs): if retcode is None: - warning("NOTIFY :: %s", _("Notify called while process is still running!")) + helper.warning("NOTIFY :: %s", _("Notify called while process is still running!")) else: icon = APP_ICON if retcode == 0: diff --git a/plugins/package_details.py b/plugins/package_details.py index 6a17f1e..19f3126 100644 --- a/plugins/package_details.py +++ b/plugins/package_details.py @@ -23,13 +23,19 @@ class Detail (WidgetPlugin): """ __author__ = "René 'Necoro' Neumann" + _view_ = None _old_pkg = None + _widget_ = None + _widget_name_ = None def init(self): self.add_call("update_table", self._update, type = "after") def widget_init (self): + if (self._widget_ is None) or (self._widget_name_ is None): + raise PluginLoadException, ("Has not set _widget_ or _widget_name_.") + self.add_widget("Package Notebook", (self._widget_, self._widget_name_)) # if the detail was updated before it was actually initialized, update it again :) |