1 | #! /usr/bin/env python |
---|
2 | |
---|
3 | from twisted.python.filepath import FilePath |
---|
4 | import argparse, sys |
---|
5 | |
---|
6 | def MakeAFileWithNBytes(N, Directory): |
---|
7 | FP = Directory.child('FileWith' + str(8*int(N)) + 'Bytes') |
---|
8 | fh = FP.open(mode='w') |
---|
9 | for i in xrange(N): |
---|
10 | fh.write("%7.d"%(i*8) + '\n') |
---|
11 | fh.close() |
---|
12 | |
---|
13 | def main(): |
---|
14 | listofnumbers = [ 3 |
---|
15 | , 2**(17-3) |
---|
16 | , 2**(18-3) |
---|
17 | , 2**(19-3) |
---|
18 | , 2**(20-3) |
---|
19 | , 2**(21-3) |
---|
20 | , 2**(22-3) |
---|
21 | , 2**(23-3)] |
---|
22 | parser = argparse.ArgumentParser(description='Create a set of base 2 exponentially expanding files.') |
---|
23 | parser.add_argument('target_directory', type=str, help='directory where files will be created') |
---|
24 | args = parser.parse_args() |
---|
25 | TD = FilePath(args.target_directory) |
---|
26 | if TD.isdir(): |
---|
27 | print "Argument %s is expected to not exist, prior to script invocation." % TD.path |
---|
28 | sys.exit(-1) |
---|
29 | TD.makedirs() |
---|
30 | for Size in listofnumbers: |
---|
31 | MakeAFileWithNBytes(Size, TD) |
---|
32 | |
---|
33 | if __name__ == '__main__': |
---|
34 | main() |
---|