3 import MySQLdb
, math
, os
, random
, sys
, time
7 rdiv
= int(sys
.argv
[1])
9 dbh
= MySQLdb
.connect('10.20.30.16', 'soepkiptng', 'soepkiptng', 'soepkiptng');
12 cur
.execute("SELECT length FROM song WHERE random_pref > 0 AND present AND filename LIKE '/%'")
19 print "%d songs, length %ds (%d days)" % (cur
.rowcount
, totlen
, totlen
/ 86400)
26 lp
= [t
- int(random
.random() * 86400 * 365.25) for x
in range(cur
.rowcount
)]
27 np
= [0 for x
in range(cur
.rowcount
)]
33 for i
, row
in enumerate(rows
):
39 r
*= 1 + int(secs
/ 86400) / rdiv
48 # print "%s %6d %4d" % (time.ctime(t), sel, len)
56 if t
> tstat
+ 86400 * 30:
57 sys
.stderr
.write("\n")
68 print "%s: after %d days: mean %f, stddev %f" % (time
.ctime(t
), (t
- tstart
) / 86400, mean
, math
.sqrt(meansq
- mean
* mean
))
71 for i
, row
in enumerate(rows
):
73 x
= int((t
- lp
[i
]) / 86400)
76 div
= 1 + int(lru
/ 50)
77 stats
= [0 for x
in range(50)]
79 for i
, row
in enumerate(rows
):
81 x
= int((t
- lp
[i
]) / 86400) / div
83 if stats
[x
] > maxstats
:
85 for i
, x
in enumerate(stats
):
86 bar
= int(x
* 100 / maxstats
)
87 print "%4d days: %6d songs: %s" % (i
* div
, x
, "*" * bar
)