aboutsummaryrefslogtreecommitdiffstats
path: root/servo
diff options
context:
space:
mode:
authorFilipp Lepalaan <filipp@mac.com>2016-03-18 13:01:31 +0200
committerFilipp Lepalaan <filipp@mac.com>2016-03-18 13:01:31 +0200
commit039d439b67d37c7cc98f18fb0636de5d05b86aed (patch)
treee8bc5a9fac7a633e1485dfa0e215fe4b0bc5319a /servo
parent5c1943521f35e22f3fce7033d69659bcd6eb6869 (diff)
downloadServo-039d439b67d37c7cc98f18fb0636de5d05b86aed.tar.gz
Servo-039d439b67d37c7cc98f18fb0636de5d05b86aed.tar.bz2
Servo-039d439b67d37c7cc98f18fb0636de5d05b86aed.zip
Added periodic CompTIA update command
Diffstat (limited to 'servo')
-rw-r--r--servo/management/commands/periodic.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/servo/management/commands/periodic.py b/servo/management/commands/periodic.py
new file mode 100644
index 0000000..5895e3c
--- /dev/null
+++ b/servo/management/commands/periodic.py
@@ -0,0 +1,38 @@
+# -*- coding: utf-8 -*-
+
+import os
+import sys
+import gsxws
+import subprocess
+from time import strftime
+from django.conf import settings
+from django.core.cache import caches
+from django.core.management.base import BaseCommand
+
+from servo.models import GsxAccount
+
+
+class Command(BaseCommand):
+ help = 'Peforms periodic commands'
+ VERBS = ('comptia',)
+
+ def add_arguments(self, parser):
+ parser.add_argument('verb', type=str, choices=self.VERBS, help='Periodic command to perform')
+
+ def handle(self, *args, **options):
+ if 'comptia' in options['verb']:
+ # Update raw CompTIA data (all product groups)
+ try:
+ act = GsxAccount.fallback()
+ except Exception as e:
+ print >> sys.stderr, 'Failed to connect to GSX (%s)' % e
+ sys.exit(-1)
+
+ 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)