# coding=utf-8

from __future__ import unicode_literals, print_function, absolute_import

import sys
import json
import pprint

from django.test import Client
from django.core.management.base import BaseCommand


class Command(BaseCommand):

    def handle(self, **options):
        c = Client()
        resp = c.get('/system/statuses?self_check_only=1')
        jobj = json.loads(resp.content)
        pprint.pprint(jobj)

        status = 0
        if not jobj['ok']:
            status = 1

        sys.exit(status)
