from django.core.management.base import BaseCommand, CommandError

from ...cron import parse_auth_log

class Command(BaseCommand):
    def handle(self, *args, **options):
        parse_auth_log()

@@ -1,12 +1,45 @@
+from django.conf import settings%0A
 from django.
@@ -97,133 +97,761 @@
 or%0A%0A
-from ...cron import parse_auth_log%0A%0Aclass Command(BaseCommand):%0A    def handle(self, *args, **options):%0A        parse_auth_log(
+try:%0A    import simplejson as json%0Aexcept ImportError as e:%0A    import json%0A%0Afrom rest_framework.renderers import JSONRenderer%0Afrom unipath import Path%0A%0Afrom ...api.serializers import HackLocationSerializer%0Afrom ...cron import parse_auth_log%0Afrom ...models import SshHackLocation%0A%0Aclass Command(BaseCommand):%0A    def handle(self, *args, **options):%0A        parse_auth_log()%0A        # Write the attempt data to json for fast AJAX loading%0A        serializer = HackLocationSerializer(SshHackLocation.objects.all(), many=True)%0A        data = JSONRenderer().render(serializer.data, 'application/json', %7B%7D)%0A        json_output_file = Path(settings.STATIC_ROOT).child('hack_location.json')%0A        with open(json_output_file, 'wb') as f:%0A            f.write(data
 )%0A

Write hack locations to json after parsing log file