summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.net>2009-10-23 23:03:49 +0200
committerRené 'Necoro' Neumann <necoro@necoro.net>2009-10-23 23:03:49 +0200
commit0869d7b4caa14ea17d6092a684af299da7545aa6 (patch)
tree553cea0edb237f92a8f9b86f80c02673b90d0c72
parent3d4e2da389013ebb61afbc4a6ec102697ff1cf5f (diff)
downloadportato-0869d7b4caa14ea17d6092a684af299da7545aa6.tar.gz
portato-0869d7b4caa14ea17d6092a684af299da7545aa6.tar.bz2
portato-0869d7b4caa14ea17d6092a684af299da7545aa6.zip
Change the new_version plugin to use git.
Use 'git ls-remote' to check for the current HEAD revision. Additionally the revision is no longer put into the version number, but into an extra variable REVISION.
Diffstat (limited to '')
-rw-r--r--plugins/new_version.py58
-rw-r--r--portato/constants.py7
2 files changed, 33 insertions, 32 deletions
diff --git a/plugins/new_version.py b/plugins/new_version.py
index 94e61ca..fd8e5cd 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,28 @@ 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)
+
+ remote_rev = Popen(['git', 'ls-remote', 'HEAD'], stdout = PIPE).communicate()[0].split('\t')
+
+ if len(remote_rev) and not remote_rev[1] == 'HEAD':
+ 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", rev, remove_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 +65,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 +80,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/portato/constants.py b/portato/constants.py
index 7d2a9d6..139f1a6 100644
--- a/portato/constants.py
+++ b/portato/constants.py
@@ -42,8 +42,10 @@ These should be set during the installation.
@var TEMPLATE_DIR: Directory containing the UI template files.
@type TEMPLATE_DIR: string
-@var REPOURI: the URI of the bzr repository -- only used in live versions
+@var REPOURI: the URI of the git repository -- only used in live versions
@type REPOURI: string
+@var REVISION: the revision of the live version
+@type REVISION: string
"""
import os
from os.path import join as pjoin
@@ -70,4 +72,5 @@ SETTINGS_DIR = pjoin(HOME, "."+APP)
TEMPLATE_DIR = "portato/gui/templates/"
# live versions only
-REPOURI = "lp:portato"
+REPOURI = "git://github.com/Necoro/portato.git"
+REVISION = ""