Changeset 5112 for main/waeup.sirp/trunk/src/waeup/sirp
- Timestamp:
- 1 Apr 2010, 10:35:49 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/accesscodes/accesscodes.py
r5110 r5112 63 63 """Create the entries for this batch. 64 64 """ 65 self._used = []65 rands = self.getNewRandomNum(num=self.entry_num) 66 66 for num in range(self.entry_num): 67 random_num = self.getNewRandomNum() 68 ac = AccessCode(num, random_num, self.cost) 67 ac = AccessCode(num, rands[num], self.cost) 69 68 self[str(num)] = ac 70 del self._used71 72 def getNewRandomNum(self ):73 """Create a random number of 10 digits.69 return 70 71 def getNewRandomNum(self, num=1): 72 """Create a set of ``num`` random numbers of 10 digits each. 74 73 75 74 The number is returned as string. 76 75 """ 77 result = ''78 while result == '' or result in self._used:79 result= ''76 results = {} 77 while len(results) < num: 78 pin = '' 80 79 for x in range(10): 81 result+= str(random().randint(0, 9))82 self._used.append(result)83 return result 80 pin += str(random().randint(0, 9)) 81 results[pin] = True 82 return results.keys() 84 83 85 84 def createCSVLogFile(self): … … 109 108 [str(value.batch_serial), str(value.representation)] 110 109 ) 110 logger = site.logger 111 logger.info( 112 "Created batch %s-%s" % (self.prefix, self.num)) 113 logger.info( 114 "Written batch CSV to %s" % csv_path) 111 115 return os.path.basename(csv_path) 112 116
Note: See TracChangeset for help on using the changeset viewer.