def _generate_serials(self, software, count):
        print "Generating {0} serials".format(count)

        # add serial numbers them to the database
        for _ in xrange(count):
            serial = str(uuid4())
            license = UserLicense(software=software, serial=serial)
            license.save()

        print "{0} new serial numbers generated.".format(count)
示例#2
0
    def _import_serials(self, software, filename):
        print "Importing serial numbers for {0}.".format(software)

        serials = set(unicode(l.strip()) for l in open(filename))

        # remove serial numbers we already have
        licenses = UserLicense.objects.filter(software=software)
        known_serials = set(l.serial for l in licenses)
        if known_serials:
            serials = serials.difference(known_serials)

        # add serial numbers them to the database
        for serial in serials:
            license = UserLicense(software=software, serial=serial)
            license.save()

        print "{0} new serial numbers imported.".format(len(serials))