-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLocal-client-python3
73 lines (58 loc) · 1.7 KB
/
Local-client-python3
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
61
62
63
64
65
66
67
68
69
70
71
72
73
import socket
import sys
import os
import csv
import json
import pandas as pd
import uuid
s = socket.socket()
host = socket.gethostname()
port = 49157
#s.bind((host, port))
try:
s.connect((host, 49159))
print("Connected Successfully!")
except Exception as e:
print("something's wrong with %s:%d. Exception is %s" % (host, 49159, e))
RFWID =uuid.uuid1()
RFWID = "Clien-"+str(RFWID)
print (RFWID)
s.send(bytes(RFWID,encoding="utf-8"))
benchmark_type = input("Benchmark Type (DVD store test or DVD store train or NDBench test or NDBench train) : ")
s.send(benchmark_type.encode())
Metric = input("Workload Metric (CPUUtilization_Average or NetworkIn_Average or NetworkOut_Average or MemoryUtilization_Average or Final_Target) : ")
s.send(Metric.encode())
unit = input("Batch Unit : ")
s.send(unit.encode())
batch_id = input("Batch ID : ")
s.send(batch_id.encode())
batch_size = input("Batch Size : ")
s.send(batch_size.encode())
last_batch_id = s.recv(1024)
FileName = "sample.json"
Data = ""
while True:
Data = s.recv(1024)
DownloadFile = open(FileName,"wb")
i = 1
while Data:
print('Recieving...%d' %(i))
DownloadFile.write(Data)
Data = s.recv(1024)
i = i + 1
print("Done Recieving")
DownloadFile.close()
break
def read_json(filename):
return json.loads(open(filename).read())
def write_csv(data,filename):
with open(filename, 'w+') as outf:
writer = csv.DictWriter(outf, data[0].keys())
writer.writeheader()
for row in data:
writer.writerow(row)
write_csv(read_json('sample.json'), 'output.csv')
s.close()
print("Client RFW ID =" +RFWID)
print("last Batch ID number = ")
print(int(last_batch_id))