コード例 #1
0
    def handle_noargs(self, **options):
        if MySQLdb is None:
            raise CommandError("MySQLdb Python module not found (you may "
                    "install it with 'pip install MySQL-python')")
        # pylint: disable=attribute-defined-outside-init
        self.options = options
        # pylint: disable=attribute-defined-outside-init
        self.failing_regions = set()
        while True:
            configs = IpAuthSyncConfig.objects.get_active(timezone.now()) \
                    .select_related('contest') \
                    .prefetch_related('contest__regions')
            mappings = []
            for c in configs:
                mappings.extend(self.handle_config(c))

            with transaction.atomic():
                IpToUser.objects.filter(ipauthsynceduser__isnull=False) \
                        .delete()
                IpAuthSyncedUser.objects.all().delete()
                for user, ip in mappings:
                    entry = IpToUser(user=user, ip_addr=ip)
                    entry.save()
                    IpAuthSyncedUser(entry=entry).save()

            time.sleep(options['interval'])
コード例 #2
0
    def handle_noargs(self, **options):
        if MySQLdb is None:
            raise CommandError("MySQLdb Python module not found (you may "
                               "install it with 'pip install MySQL-python')")
        # pylint: disable=attribute-defined-outside-init
        self.options = options
        # pylint: disable=attribute-defined-outside-init
        self.failing_regions = set()
        while True:
            configs = IpAuthSyncConfig.objects.get_active(timezone.now()) \
                    .select_related('contest') \
                    .prefetch_related('contest__regions')
            mappings = []
            for c in configs:
                mappings.extend(self.handle_config(c))

            with transaction.atomic():
                IpToUser.objects.filter(ipauthsynceduser__isnull=False) \
                        .delete()
                IpAuthSyncedUser.objects.all().delete()
                for user, ip in mappings:
                    entry = IpToUser(user=user, ip_addr=ip)
                    entry.save()
                    IpAuthSyncedUser(entry=entry).save()

            time.sleep(options['interval'])
コード例 #3
0
 def load_data(self, module, modelMgr, data):
     self.stderr.write("Loading...\n")
     for row in data:
         try:
             if module == 'ip':
                 binding = IpToUser(user=User.objects.get(username=row[0]),
                                    ip_addr=row[1])
             elif module == 'dns':
                 binding = DnsToUser(user=User.objects.get(username=row[0]),
                                     dns_name=row[1])
             binding.full_clean()
             binding.save()
         except Exception as e:
             self.stderr.write("Error for %s: %s\n" % (row, e))
コード例 #4
0
ファイル: ipdnsauth.py プロジェクト: mahrud/oioioi
 def load_data(self, module, modelMgr, data):
     self.stderr.write("Loading...\n")
     for row in data:
         try:
             if module == "ip":
                 binding = IpToUser(user=User.objects.get(username=row[0]), ip_addr=row[1])
             elif module == "dns":
                 binding = DnsToUser(user=User.objects.get(username=row[0]), dns_name=row[1])
             binding.full_clean()
             binding.save()
         except Exception as e:
             self.stderr.write("Error for %s: %s\n" % (row, e))