summaryrefslogtreecommitdiff
path: root/scripts/create_payload.py
diff options
context:
space:
mode:
authordrebs <drebs@riseup.net>2016-05-02 20:25:45 -0300
committerdrebs <drebs@riseup.net>2016-05-02 20:44:20 -0300
commit31b527a9acc8607e5e03927b3b646b7c832e7058 (patch)
tree0198120076f62027bbbaf70eed6358df012d4cde /scripts/create_payload.py
parent9c1dc66c057dee764e80af875cb60a75e8e3aca4 (diff)
refactor and make complete test run with script
Diffstat (limited to 'scripts/create_payload.py')
-rwxr-xr-xscripts/create_payload.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/scripts/create_payload.py b/scripts/create_payload.py
new file mode 100755
index 0000000..d051661
--- /dev/null
+++ b/scripts/create_payload.py
@@ -0,0 +1,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)