diff options
author | CruiseDevice | 2018-10-29 18:59:04 +0530 |
---|---|---|
committer | CruiseDevice | 2018-10-29 18:59:04 +0530 |
commit | dc1b49fc5ef5803160f0b0df5f8076e77e37926d (patch) | |
tree | 5ab83b7086fff95b51aa63ed4c94c8691c78d684 /sbhs/management/commands/update_boards.py | |
parent | 152b4a9c34398cc1a6530ee5c3830f57436b0a27 (diff) | |
download | sbhs_server-dc1b49fc5ef5803160f0b0df5f8076e77e37926d.tar.gz sbhs_server-dc1b49fc5ef5803160f0b0df5f8076e77e37926d.tar.bz2 sbhs_server-dc1b49fc5ef5803160f0b0df5f8076e77e37926d.zip |
Add moderator features
- Add form to update userboard.
- Management command for adding online boards.
- Add conditions for booking slots.
- Add features to test, update and reset boards.
Diffstat (limited to 'sbhs/management/commands/update_boards.py')
-rw-r--r-- | sbhs/management/commands/update_boards.py | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/sbhs/management/commands/update_boards.py b/sbhs/management/commands/update_boards.py new file mode 100644 index 0000000..238646c --- /dev/null +++ b/sbhs/management/commands/update_boards.py @@ -0,0 +1,38 @@ +''' + This command creates a moderator group and adds users to the moderator group + with permissions to add, change and delete + the objects in the exam app. +''' + +# django imports +from django.core.management.base import BaseCommand, CommandError +from django.contrib.auth.models import User, Group, Permission + +# local imports +from sbhs.models import Board +from sbhs.views import map_sbhs_to_rpi + + +class Command(BaseCommand): + help = 'Ping all boards and update status of boards' + + def add_arguments(self, parser): + # Positional arguments + parser.add_argument('host_ip', type=str) + + def handle(self, *args, **options): + app_label = 'sbhs' + try: + board_check, dead_servers = map_sbhs_to_rpi(options["host_ip"]) + board = Board() + all_mac_ids = [] + for machines in board_check: + all_mac_ids.extend(machines["mac_ids"]) + board.switch_off_inactive_boards(all_mac_ids) + self.stdout.write('Updated Board Status') + if dead_servers: + self.stdout.write('Servers {0} are not responding.'\ + .format(", ".join(dead_servers)) + ) + except Exception as e: + self.stdout.write('Failed updating Board because {0}'.format(e))
\ No newline at end of file |