projects
/
cmccabe-bin
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
history
|
raw
|
HEAD
pickrand.py: fix off-by-one
[cmccabe-bin]
/
pickrand.py
1
#!/usr/bin/python
2
3
import os
4
import random
5
import sys
6
7
allfiles = []
8
9
for root, dirs, files in os.walk(".", followlinks=True):
10
for f in files:
11
allfiles.append(os.path.join(root, f))
12
if (len(allfiles) == 0):
13
sys.exit(1)
14
random.seed(None)
15
r = random.randint(0,len(allfiles) - 1)
16
print(allfiles[r])
17
sys.exit(0)