Exemplo n.º 1
0
    def run(self, *args, **kwargs):
        self.reset(kwargs.get('artifacts'))

        # Trigger handlers and return if there was an error
        exceptions, results = self.trigger(None, *args, **kwargs)

        if not all(results):
            self.update_status(False)
            return False

        # Create "http" cache for this task
        cache_key = 'http.%s.%s' % (self.get_sid(), self.key)
        cache = CacheManager.open(cache_key)

        with Plex.configuration.cache(http=cache):
            # Trigger children and return if there was an error
            exceptions, results = self.trigger_children(*args, **kwargs)

        # Discard HTTP cache
        CacheManager.delete(cache_key)

        if not all(results):
            self.update_status(False, exceptions=exceptions)
            return False

        self.update_status(True)
        return True