예제 #1
0
    def _fetch_updates(cls):
        logger.info("Fetching updates...")

        try:
            updates = [e for e in Extension.all() if e.should_update]
        except requests.ConnectionError:
            raise Update.ConnectionError

        cls._set_cached(updates)
        Storage.set('last_checked_at', time.time())

        return updates
예제 #2
0
    def _get_cached(cls):
        logger.info("Fetching cached updates...")

        cache = Storage.get('update_cache')
        extensions = [Extension(name=name) for name, _ in cache.items()]

        for extension in extensions:
            if extension.is_installed and extension.is_configured:
                extension.remote.version = Version(cache[extension.name])

        return extensions
예제 #3
0
    def check_for_updates(self):
        """Open updates window unless ran in last hour"""

        if self.should_check_for_updates():
            try:
                skip_patches = bool(Storage.get('ignore_patch_updates'))
                updates = Update.all(force=True, skip_patches=skip_patches)
            except Update.ConnectionError:
                logger.info("Couldn't connect to the internet")
                return

            if updates:
                logger.info("%d new updates found", len(updates))

                Bus().emit("newUpdatesFound", updates)
            else:
                logger.info("No new updates found")
        else:
            logger.info("Skipping a check for new updates")
예제 #4
0
 def get_updates(self, force):
     skip_patches = bool(Storage.get("ignore_patch_updates"))
     return Update.all(force, skip_patches=skip_patches)
예제 #5
0
 def _set_cached(cls, extensions):
     cache = {e.filename : str(e.remote.version) for e in extensions}
     Storage.set('update_cache', cache)
예제 #6
0
 def last_checked(cls):
     return Storage.get('last_checked_at') or 0
예제 #7
0
from mechanic import logger
from mechanic.bus import Bus
from mechanic.event_caller import EventCaller
from mechanic.storage import Storage
from mechanic.observers.update import UpdateObserver
from mechanic.ui.windows.notification import UpdateNotificationWindow

Storage.set_defaults(ignore={},
                     update_cache={},
                     check_on_startup=True,
                     ignore_patch_updates=False)

UpdateObserver('applicationDidFinishLaunching', 'applicationDidBecomeActive')

EventCaller('newUpdatesFound', UpdateNotificationWindow)
예제 #8
0
 def should_check_for_updates(self):
     return bool(Storage.get('check_on_startup')) and \
         not Update.checked_recently()
예제 #9
0
 def save(self, sender):
     rows = self.get()
     ignore = {r["name"]: True for r in rows if not r["check_for_updates"]}
     Storage.set('ignore', ignore)
예제 #10
0
 def is_ignored(self):
     return self.bundle.name in Storage.get('ignore')
예제 #11
0
 def should_check_for_updates(self):
     return bool(Storage.get('check_on_startup')) and \
         not Update.checked_recently()
예제 #12
0
 def value(self, val):
     return Storage.set(self.key, bool(val))
예제 #13
0
 def value(self):
     return bool(Storage.get(self.key))
예제 #14
0
 def value(self, val):
     return Storage.set(self.key, bool(val))
예제 #15
0
 def value(self):
     return bool(Storage.get(self.key))
예제 #16
0
from mechanic import logger
from mechanic.bus import Bus
from mechanic.event_caller import EventCaller
from mechanic.storage import Storage
from mechanic.observers.update import UpdateObserver
from mechanic.ui.windows.notification import UpdateNotificationWindow


Storage.set_defaults(ignore={},
                     update_cache={},
                     check_on_startup=True,
                     ignore_patch_updates=False)


UpdateObserver('applicationDidFinishLaunching',
               'applicationDidBecomeActive')


EventCaller('newUpdatesFound', UpdateNotificationWindow)