blob: d051661d1dfeb518c17f894c1f3c96292da5c6b1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
#!/usr/bin/env python
"""
Create a payload file in disk to use during tests. Reads the name of the file
and the intended size of the payload from the "defaults.conf" file:
PAYLOAD = /path/to/payload/file
PAYLOAD_SIZE = 500 # in Kb
"""
import os
from ConfigParser import ConfigParser
parser = ConfigParser()
parser.read('defaults.conf')
PAYLOAD = parser.get('sync', 'payload')
PAYLOAD_SIZE = int(parser.get('sync', 'payload_size')) * 1024
if os.path.isfile(PAYLOAD):
os.unlink(PAYLOAD)
content = 'a' * 1024
with open(PAYLOAD, 'w') as f:
length = 0
while length < PAYLOAD_SIZE:
f.write(content)
length += len(content)
|