-
Notifications
You must be signed in to change notification settings - Fork 5
/
delta_client.py
executable file
·61 lines (36 loc) · 957 Bytes
/
delta_client.py
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/python3
import socket
import sys
import delta
import time
from libdeka import *
import delta
from vankusconf import HOST, PORT
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect((HOST, PORT))
delta.delta_init()
d = bytes()
y = bytearray()
while 1:
sock.sendall(bytes("getdps\r\n", "ascii"))
header = getline(sock)
jobnum = int(header.split()[0])
plen = int(header.split()[1])
if plen == 0:
time.sleep(1)
else:
print(header)
d = getdata(sock, plen)
# convert to mutable bytearray, some swig magic
y = bytearray(d)
x=time.time()
# find blocks we will need and madvise them
delta.ncq_submit(y)
print("submit took: %f s"%(time.time()-x))
x=time.time()
print("process")
# read the madvised blocks
delta.ncq_read(y)
print("process took: %f s"%(time.time()-x))
sendascii(sock, "putstart %i %i\r\n"%(jobnum, plen))
sendblob(sock, y)