Beispiel #1
0
    def handle(self, *args, **options):
        try:
            act = GsxAccount.fallback()
        except Exception as e:
            print >> sys.stderr, 'Failed to connect to GSX (%s)' % e
            sys.exit(-1)

        if 'articles' in options['verb']: # Update GSX articles
            articles = gsxws.comms.fetch()
            for a in articles:
                try:
                    article = Article.from_gsx(a)
                    try:
                        content = gsxws.comms.content(article.gsx_id)
                        article.content = content.articleContent
                    except Exception as e:
                        pass
                    article.save()
                except ValueError as e:
                    pass

        if 'comptia' in options['verb']: # Update raw CompTIA data (all product groups)
            try:
                codes = gsxws.comptia.fetch()
                caches['comptia'].set('codes', codes)
            except Exception as e:
                print >> sys.stderr, 'Failed to fetch CompTIA codes (%s)' % e
                sys.exit(-1)

        exit(0)
Beispiel #2
0
    def handle(self, *args, **options):
        try:
            act = GsxAccount.fallback()
        except Exception as e:
            print >> sys.stderr, 'Failed to connect to GSX (%s)' % e
            sys.exit(-1)

        if 'articles' in options['verb']:  # Update GSX articles
            articles = gsxws.comms.fetch()
            for a in articles:
                try:
                    article = Article.from_gsx(a)
                    try:
                        content = gsxws.comms.content(article.gsx_id)
                        article.content = content.articleContent
                    except Exception as e:
                        pass
                    article.save()
                except ValueError as e:
                    pass

        if 'comptia' in options[
                'verb']:  # Update raw CompTIA data (all product groups)
            try:
                codes = gsxws.comptia.fetch()
                caches['comptia'].set('codes', codes)
            except Exception as e:
                print >> sys.stderr, 'Failed to fetch CompTIA codes (%s)' % e
                sys.exit(-1)

        exit(0)
Beispiel #3
0
def get_remote_symptom_codes(group):
    """
    Remote lookup for symptom codes
    """
    symptoms = {}
    cache = caches['comptia']
    # First, try to load from global cache (updated every 24h)
    data = cache.get('codes') or {}

    if not data:
        # ... then try to fetch from GSX
        GsxAccount.fallback()
        data = gsxws.comptia.fetch()
        cache.set('codes', data)

    for k, v in data.get(group):
        symptoms[k] = v

    return symptoms