[Bf-extensions-cvs] [fb121dd] master: use os, urandom to avoid getting the same tip each launch j reported by one user.

Campbell Barton noreply at git.blender.org
Thu Mar 26 14:00:45 CET 2015


Commit: fb121ddcd2c437fcecd745aa037a9cb84a3733d9
Author: Campbell Barton
Date:   Thu Mar 26 23:59:49 2015 +1100
Branches: master
https://developer.blender.org/rBACfb121ddcd2c437fcecd745aa037a9cb84a3733d9

use os,urandom to avoid getting the same tip each launch
j
reported by one user.

===================================================================

M	ui_splash_tips/__init__.py

===================================================================

diff --git a/ui_splash_tips/__init__.py b/ui_splash_tips/__init__.py
index be5b7ff..807b4f4 100644
--- a/ui_splash_tips/__init__.py
+++ b/ui_splash_tips/__init__.py
@@ -28,15 +28,24 @@ bl_info = {
 }
 
 
+def u_randint(s, e):
+    import os
+    import struct
+    data_type = 'Q'
+    size = struct.calcsize(data_type)
+    data = struct.unpack(data_type, os.urandom(size))[0]
+    return s + (data % (e - s))
+
+
 def read_random_line(f):
     import os
 
     chunk_size = 16
     with open(f, 'rb') as f_handle:
-        import random
         f_handle.seek(0, os.SEEK_END)
         size = f_handle.tell()
-        i = random.randint(0, size)
+        # i = random.randint(0, size)
+        i = u_randint(0, size)
         while True:
             i -= chunk_size
             if i < 0:



More information about the Bf-extensions-cvs mailing list