-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommand.py
More file actions
136 lines (122 loc) · 2.96 KB
/
Copy pathcommand.py
File metadata and controls
136 lines (122 loc) · 2.96 KB
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
import os
import webbrowser
import json
data1 = '''
<link href="./jquery/jquery-ui.css" rel="stylesheet" />
<script type="text/javascript" src="./jquery/jquery.js"></script>
<script type="text/javascript" src="./jquery/jquery-ui.js"></script>
<script type="text/javascript" src="./jquery/jquery.canvasjs.min.js"></script>
<script type="text/javascript">
window.onload = function () {
//Better to construct options first and then pass it as a parameter
var options1 = {
title: {
text: "Page Replacement algorithm comparision"
},
animationEnabled: true,
data: [
{
type: "bar", //change it to line, area, bar, pie, etc
dataPoints: [
'''
data2 = '''
]
}
]
};
$("#resizable").resizable({
create: function (event, ui) {
//Create chart.
$("#chartContainer1").CanvasJSChart(options1);
},
resize: function (event, ui) {
//Update chart size according to its container's size.
$("#chartContainer1").CanvasJSChart().render();
}
});
}</script>
'''
def func2():
global data1, data2
LI = []
replacementcounts = []
url = os.path.abspath('outputmainprogram.json')
with open(url) as data_file:
data = json.load(data_file)
for AData in data:
LI.append(AData['algoname'])
replacementcounts.append(AData['numberofstageswithswap'])
myfunc(AData)
M = open(os.path.abspath('./menu.html'), 'w')
menudata = '''
<!DOCTYPE html>
<html>
<head>
'''
menudata += data1
for i in range(len(replacementcounts)):
menudata += "{label: \""+data[i]['algoname']+"\", y: "+str(replacementcounts[i])+" },"
menudata += data2
menudata += '''
</head>
<body><ol>
'''
for item in LI:
menudata += "<li><a href=\"./"+item+".html\">"+item+"</a></li>"
menudata += '''
</ol>
<div id="resizable" style="height: 300px;border:1px solid gray;">
<div id="chartContainer1" style="height: 100%; width: 100%;"></div>
</body>
</html>
'''
M.write(menudata)
M.close()
browser(M)
def myfunc(data):
global totalstages
#os.system(commandstring)
listof = []
totalstages = data['numberofstages']
f = open(os.path.abspath(''+data['algoname']+'.html'), 'w')
datatowrite = '''
<!DOCTYPE html>
<html>
<head>
<style>
box {
width: 100px;
height: 100px;
border: 1px solid blue;
border-radius: 3px;
padding: 8px;
background-color: yellow;
margin: 5%;
}
div {
text-align: center;
padding: 20px;
}
</style>
</head>
<body>
<a href="./menu.html">MENU</a>
'''
for i in range(data['numberofstages']):
datatowrite += "<div>stage"+str(i+1)
for j in data['allstages'][i]:
if j > 0:
datatowrite += "<box >"+str(j)+"</box>"
else:
datatowrite += "<box >"+'-'+"</box>"
datatowrite += "</div>"
datatowrite += str(data['numberofstages']) + '''
</body>
</html>
'''
f.write(datatowrite);
def browser(M):
url = os.path.abspath(M.name)
webbrowser.open('file://' + url, new=2)
#print "navigate to menu.html"
func2()