def handle(self, *args, **options):
        all_students = {}
        admins = get_admins_usernames()
        all_students_q = User.objects.filter(is_active = True).exclude(username__in = admins)
        for student in all_students_q:
            all_students[student.get_profile().dionysos_username] = decrypt_password(student.get_profile().dionysos_password)

        self.stdout.write('all_real_accounts = %s\n' % str(all_students))
 def get_or_create_user(self, request = None, username = None, password = None):
     '''
     Retrieves the user from the Django DB. If the user is not
     found in the DB, then it tries to retrieve him from
     dionysos.teilar.gr
     '''
     try:
         student = Cronos(username, password)
         '''
         Try to pull the user from the Django DB
         '''
         user = User.objects.get(username = username)
         '''
         skip dionysos authentication if the user is one of the listed ADMINS
         '''
         if user.username in get_admins_usernames():
             if user.check_password(password):
                 return user
             else:
                 return
         '''
         If the user is found in the DB, try to login with those
         credentials in dionysos.teilar.gr
         '''
         try:
             student.dionysos_auth_login(request)
         except LoginError:
             '''
             Authentication failed
             '''
             return
         except CronosError:
             '''
             Connection issue with dionysos.teilar.gr. Try to authenticate
             with the password stored in the DB instead
             '''
             if password != decrypt_password(user.get_profile().dionysos_password):
                 return
     except User.DoesNotExist:
         '''
         If the user is not in the DB, try to log in with his
         dionysos.teilar.gr account
         '''
         try:
             student.dionysos_auth_login(request, personal_data = True, declaration = True, grades = True)
             '''
             The credentials worked, try to create a user based on those credentials
             '''
             student.get_dionysos_account(request)
             try:
                 '''
                 Relate the webscraped school name with the one stored in the DB
                 '''
                 student.dionysos_school = Departments.objects.get(name = student.dionysos_school)
             except Exception as error:
                 logger_syslog.error(error, extra = log_extra_data(request))
                 logger_mail.exception(error)
                 raise CronosError(u'Αδυναμία ανάκτησης της σχολής')
             user = self.add_student_to_db(request, student)
         except CronosError:
             raise
         except LoginError:
             '''
             Authentication failed
             '''
             return
     return user