mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-01-04 00:15:09 +01:00
Use system random source for picking a random book
This commit is contained in:
parent
359116e86a
commit
4c0138e40d
1 changed files with 5 additions and 1 deletions
|
|
@ -21,6 +21,10 @@ class PickRandomAction(InterfaceAction):
|
|||
def genesis(self):
|
||||
self.qaction.triggered.connect(self.pick_random)
|
||||
self.recently_picked = {}
|
||||
try:
|
||||
self.randint = random.SystemRandom().randint
|
||||
except Exception:
|
||||
self.randint = random.randint
|
||||
|
||||
def location_selected(self, loc):
|
||||
enabled = loc == 'library'
|
||||
|
|
@ -38,7 +42,7 @@ def pick_random(self):
|
|||
n = next(iter(rp))
|
||||
del rp[n]
|
||||
while True:
|
||||
pick = random.randint(0, count)
|
||||
pick = self.randint(0, count)
|
||||
if pick in rp:
|
||||
continue
|
||||
rp[pick] = True
|
||||
|
|
|
|||
Loading…
Reference in a new issue