From 6ef013505cd0f28a2ae4a98948fb1913e7f2898c Mon Sep 17 00:00:00 2001 From: dk-15 Date: Fri, 26 May 2017 00:01:35 +0530 Subject: Add new_cron_job.sh for django 1.11 and include log_generator in maintenance management --- maintenance/management/__init__.py | 0 maintenance/management/commands/__init__.py | 1 + maintenance/management/commands/log_generator.py | 20 ++++++++++++++++++++ 3 files changed, 21 insertions(+) create mode 100644 maintenance/management/__init__.py create mode 100644 maintenance/management/commands/__init__.py create mode 100644 maintenance/management/commands/log_generator.py (limited to 'maintenance/management') diff --git a/maintenance/management/__init__.py b/maintenance/management/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/maintenance/management/commands/__init__.py b/maintenance/management/commands/__init__.py new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/maintenance/management/commands/__init__.py @@ -0,0 +1 @@ + diff --git a/maintenance/management/commands/log_generator.py b/maintenance/management/commands/log_generator.py new file mode 100644 index 0000000..95c03d0 --- /dev/null +++ b/maintenance/management/commands/log_generator.py @@ -0,0 +1,20 @@ +#Dev/KoDe :) + +import csv +import datetime +import os +import sys +from django.core.management.base import BaseCommand, CommandError + +class Command(BaseCommand): + args = '' + help = 'Creates Log' + + def handle(self, *args, **options): + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "sbhs_server.settings") # To make a Django Environment. + + from sbhs_server.tables.models import Board + board_details = Board.objects.values_list("online", flat=True) + board = str([x for x in board_details]) + with open('new.csv', "a") as newcsv: + newcsv.write("{0} {1} \n".format(datetime.datetime.now(), board.replace(",", "").replace("[", "").replace("]",""))) -- cgit