~qioeujqioejqioe-deactivatedaccount/exaile/missing-signals

« back to all changes in this revision

Viewing changes to plugins/updates.py

  • Committer: Adam Olsen
  • Date: 2007-08-31 19:36:41 UTC
  • Revision ID: arolsen@gmail.com-20070831193641-isghtp1fq2433m2m
Moving the plugins directory into the source directory

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
import gtk, gobject, time, urllib
 
3
from xl import common, xlmisc
 
4
import xl.plugins as plugins
 
5
 
 
6
PLUGIN_NAME = "Update Notifier"
 
7
PLUGIN_AUTHORS = ['Adam Olsen <arolsen' + chr(32+32) + 'gmail' + '.com>']
 
8
PLUGIN_VERSION = "0.3.1"
 
9
PLUGIN_DESCRIPTION = r"""Notifies the user of Exaile and plugin updates"""
 
10
 
 
11
PLUGIN_ENABLED = False
 
12
PLUGIN_ICON = None
 
13
PLUGIN = None
 
14
APP = None
 
15
 
 
16
def found_updates(found):
 
17
    message = "The following plugins have new versions available for install."
 
18
    message += " You can install them from the plugin manager.\n\n"
 
19
 
 
20
    for (name, version) in found:
 
21
        message += "%s\t%s\n" % (name, version)
 
22
 
 
23
    common.info(APP.window, message)
 
24
 
 
25
@common.threaded
 
26
def start_thread(exaile):
 
27
    # check exaile itself
 
28
    version = map(int, APP.get_version().replace('svn', '').split('.'))
 
29
    check_version = map(int,
 
30
        urllib.urlopen('http://exaile.org/current_version.txt').read().split('.'))
 
31
 
 
32
    if version < check_version:
 
33
        gobject.idle_add(common.info, APP.window, "Exaile version %s is "
 
34
            "available.  Grab it from http://www.exaile.org today!" % 
 
35
            '.'.join([str(i) for i in check_version]))
 
36
 
 
37
    # check plugins
 
38
    pmanager = APP.pmanager
 
39
    avail_url = 'http://www.exaile.org/files/plugins/%s/plugin_info.txt' % \
 
40
            APP.get_plugin_location()
 
41
 
 
42
    h = urllib.urlopen(avail_url)
 
43
    lines = h.readlines()
 
44
    h.close()
 
45
 
 
46
    found = []
 
47
 
 
48
    check = False
 
49
    for line in lines:
 
50
        line = line.strip()
 
51
        (file, name, version, author, description) = line.split('\t')
 
52
        
 
53
        for plugin in pmanager.plugins:
 
54
            if plugin.PLUGIN_NAME == name:
 
55
                installed_ver = map(int, plugin.PLUGIN_VERSION.split('.'))
 
56
                available_ver = map(int, version.split('.'))
 
57
 
 
58
                if installed_ver < available_ver:
 
59
                    found.append((name, version))
 
60
 
 
61
    if found:
 
62
        gobject.idle_add(found_updates, found)
 
63
 
 
64
def initialize():
 
65
    """
 
66
    Connect to the PluginEvents
 
67
    """
 
68
    global SIGNAL_ID
 
69
    SIGNAL_ID = APP.playlist_manager.connect('last-playlist-loaded', start_thread)
 
70
 
 
71
    return True
 
72
 
 
73
def destroy():
 
74
    global SIGNAL_ID
 
75
    if SIGNAL_ID:
 
76
        gobject.source_remove(SIGNAL_ID)