File: update_checker_plugin.py

package info (click to toggle)
python-envisageplugins 3.2.0-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 1,600 kB
  • sloc: python: 6,968; sh: 11; makefile: 8; lisp: 1
file content (69 lines) | stat: -rw-r--r-- 2,166 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69

# Enthought library imports
from enthought.envisage.api import Plugin
from enthought.traits.api import Bool, Callable, Event, Int, Instance, Str, Trait

# Local, relative imports
from update_info import UpdateInfo


# The globally unique ID of this plugin
ID = "enthought.plugins.update_checker"


class UpdateCheckerPlugin(Plugin):

    name = "Update Checker Plugin"

    # The URI to an updates.xml file.  Although this can be a local path,
    # typically it will be a URL.
    location = Str("localhost")

    # Update 

    # Should the plugin automatically check for updates?
    check_automatically = Bool(True)

    # The frequency with which to check for updates
    # Can be "startup", which means at application startup, or an integer number
    # of seconds
    # TODO: Contribute a preference for this!
    check_frequency = Trait("startup", "startup", Int)

    # Whether or not to display a dialog informing the user of available
    # updates
    display_dialog = Bool(True)

    # The UpdateInfo object that contains the actual update information.
    # Regardless of whether or not a dialog is displayed to the user, this 
    # attribute will be populated with the appropriate information.
    update_info = Instance(UpdateInfo)

    # This event fires every time the UpdateCheckerPlugin is invoked and 
    # determines that an application update is available.
    update_needed = Event()  #Event(ApplicationEvent)

    #========================================================================
    # Plugin interface
    #========================================================================
    
    def start(self):
        """ Make the appropriate contributions
        """
        
        self.application.on_trait_change("started", self._check_for_update)

    def stop(self):
        """ Clean up
        """

        self.application.on_trait_change("started", self._check_for_update, remove=True)

    #========================================================================
    # Public methods
    #========================================================================

    def _check_for_update(self):
        pass