This repository has been archived by the owner on Oct 8, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 69
/
exp.py
executable file
·3396 lines (3134 loc) · 104 KB
/
exp.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
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/python
import sys
import random
import os.path
import psPlot
import commands
import math
import shutil
import threading
import time
import os
import cgi
import cgitb; cgitb.enable()
import socket
from string import Template
# Globals
#
# The program can be used interactively as a web program,
# in which case it needs to be installed in cgi-exec directory,
# or in batch mode where it reads commands through a script
#Mode = 'web'
Mode = 'script'
Path = '.'
relPath = '.'
IterFile = 'exp.html'
menuState = ''
hostName = socket.gethostname()
ran = random.randrange(10000000)
#foutPath = '/Library/WebServer/Documents/Exp/tmp'
foutPath = 'tmp/'
foutName = str(ran)
lastVer=123456789
lastExp= 100.0
lastColorFieldVal = None
uploadDir = 'tmp/'
csvFilename = ''
iterName = 'exp'
iterIndex = 999999999
iterDict = {}
fieldList = []
fieldDict = {}
formatFlag = False
formatList = []
defaultFormatFlag = False
defaultFormat = 2
showColFormattingFlag = False
CommandDict = {}
CommandDict['rowColorChange'] = ''
SelectedRowList = []
SelectedColList = []
SelectedColDict = {}
SelectAllColsFlag = False
SelectAllRowsFlag = False
image = ''
Rows = []
Cols = []
if Mode == 'web':
flog = open('log/log'+foutName+'.out', 'w')
else:
# flog = open('/dev/null', 'w')
flog = open('exp.log', 'w')
fieldDict = {}
formatList = []
saveIgnoreDict = {}
defaultVals = {}
History = []
SelectList = []
AveragedRows = []
AveragedRowsCount = []
ReadRowList = []
ReadCommandDict = {}
ReadCommands = 0
Y1minFlag = False
Y2minFlag = False
Y1min = 'x'
Y2min = 'x'
PlotPercentFlag = 0
PlotRatioFlag = 0
#rowColorChangeVal = 'exp'
rowColorChangeVal = 'ca'
# Global list or Dict initialiation
#
saveIgnoreDict['Rows'] = 'x'
#saveIgnoreDict['Cols'] = 'x'
saveIgnoreDict['File'] = 'x'
saveIgnoreDict['Path'] = 'x'
saveIgnoreDict['SaveComs'] = 'x'
saveIgnoreDict['ReadCommands'] = 'x'
saveIgnoreDict['StartMacro'] = 'x'
saveIgnoreDict['EndMacro'] = 'x'
saveIgnoreDict['SaveMacro'] = 'x'
saveIgnoreDict['DoMacro'] = 'x'
saveIgnoreDict['SavingMacro'] = 'x'
defaultVals['Y1LogScale'] = 'Auto'
defaultVals['PlotRatio'] = 'Off'
defaultVals['BkgLevel'] = '0.8'
defaultVals['PlotPercent'] = 'Off'
#defaultVals['xUniform'] = 'On'
defaultVals['Y2LogScale'] = 'Auto'
#--- rmSpaces
def rmSpaces(s):
oldS = s.strip()
newS = oldS.replace(' ','')
while len(oldS) != len(newS):
oldS = newS
newS = oldS.replace(' ','')
return newS
#--- doError
def doError(msg):
if Mode == 'web':
sys.stdout.write('Content-type: text/html\n\n')
sys.stdout.write('<HTML> <HEAD> <TITLE>'+'exp.py Error'+'</TITLE>\n')
sys.stdout.write('</HEAD><BODY><TABLE BORDER=2 BGCOLOR="#CCFFCC" CELLPADDING=20> <TR> <TD>\n<p><h2>'+msg+'</h2></TD></TR></TABLE></BODY>')
sys.stdout.write('</HTML>')
else:
print 'ERROR in exp.py: %s' % msg
print >>flog, 'ERROR in exp.py: %s' % msg
print >>flog, 'DONE'
flog.close()
sys.stdout.close()
os._exit(0)
#--- isFloat
def isFloat(s):
try: return (float(s),True)[1]
except (ValueError, TypeError), e: return False
#--- floatCmp
def floatCmp(s1, s2):
v1 = float(s1)
v2 = float(s2)
if v1 < v2:
return -1
elif v1 == v2:
return 0
else:
return 1
#--- sortListCmp
def sortListCmp(s1, s2):
if isFloat(s1[0]) and isFloat(s2[0]):
v1 = float(s1[0])
v2 = float(s2[0])
if (v1 < v2):
return -1
elif v1 == v2:
return 0
else:
return 1
else:
if s1[0] < s2[0]:
return -1
elif s1[0] == s2[0]:
return 0
else:
return 1
#--- sortListRevCmp
def sortListRevCmp(s1, s2):
if isFloat(s1[0]) and isFloat(s2[0]):
v1 = float(s1[0])
v2 = float(s2[0])
if (v1 < v2):
return 1
elif v1 == v2:
return 0
else:
return -1
else:
if s1[0] < s2[0]:
return -1
elif s1[0] == s2[0]:
return 0
else:
return 1
#--- getFieldIndex
def getFieldIndex(s):
if s in fieldDict:
return fieldDict[s]
return -1
#--- resetSelectedColDict()
def resetSelectedColDict():
global SelectedColList, SelectedColDict
SelectedColDict = {}
for field in SelectedColList:
SelectedColDict[field] = 1
return
#--- formatFloat
def formatFloat(f):
if f <= 10:
rv = float(int(100.0*f))/100.0
elif f <= 100:
rv = float(int(100.0*f))/100.0
elif f <= 1000:
rv = float(int(10.0*f))/10.0
else:
rv = float(int(f))
return rv
#--- writeSpaces
def writeSpaces(f, spaces, text=''):
i = 0
line = ''
while i < spaces:
i = i + 1
line = line + '  '
f.write(line+text)
return
#--- writeText
def writeText(f, text, spaces):
writeSpaces(f,spaces,text)
return
#--- writeHiddenInput
def writeHiddenInput(f, name, value):
f.write('<input type="hidden" name="'+name+'" value="'+value+'">\n')
return
#--- writeSelectInput
def writeSelectInput(f, label, name, values, selection, spaces, newLine, redoFlag, helpText=''):
writeSpaces(f,spaces,label)
f.write('<SELECT NAME="'+name+'" ')
if redoFlag:
f.write('onchange="redo()" ')
if helpText != '':
f.write('onmouseover="popup(\''+helpText+'\')" onmouseout="popdown()" onclick="popdown()" ')
f.write('>')
valuesList = values.split(',')
for v in valuesList:
vList = v.split('=')
if name in ReadCommandDict and ReadCommandDict[name] == vList[0]:
selStr = 'SELECTED'
elif selection == vList[0]:
selStr = 'SELECTED'
else:
selStr = ''
f.write(' <OPTION VALUE="'+vList[0]+'" '+selStr+'>'+vList[1])
f.write(' </SELECT>')
if newLine != 0:
f.write('\n')
return
#--- writeCheckboxInput
def writeCheckboxInput(f, label, name, value, newLine, callFlag, helpText=''):
if label != '':
f.write('  ' + label)
f.write('<input type=checkbox name="'+name+'" ')
if name in ReadCommandDict and value == '':
value = ReadCommandDict[name]
if value != '' and value != 'F' and value != 'f':
f.write('CHECKED ')
if callFlag:
f.write('onclick="redo()" ')
if helpText != '':
f.write('onmouseover="popup(\''+helpText+'\')" onmouseout="popdown()" ')
if newLine != 0:
f.write('>\n')
else:
f.write('>')
return
#--- writeTextInput
def writeTextInput(f, label, name, value, size, spaces, newLine, helpText=''):
writeSpaces(f,spaces,label)
f.write('<input type=text name="'+name+'" ')
if name in ReadCommandDict:
value = ReadCommandDict[name]
if value != '':
f.write('value="'+value+'" ')
if size != 0:
f.write('size="'+str(size)+'" ')
if helpText != '':
f.write('onmouseover="popup(\''+helpText+'\')" onmouseout="popdown()" onclick="popdown()" ')
if newLine != 0:
f.write('>\n')
else:
f.write('>')
return
#--- writeButton
def writeButton(f, label, name, size, spaces, helpText=''):
writeSpaces(f,spaces)
f.write('<input type="submit" name="'+name+'" value="'+label+'"')
if size > 0:
f.write(' size="'+str(size)+'" ')
if helpText != '':
f.write('" onmouseover="popup(\''+helpText+
'\')" onmouseout="popdown()"')
f.write(' >\n')
return
#--- writeInputFile
def writeInputFile(f, label, name, accept, spaces, helpText=''):
writeSpaces(f,spaces,label)
f.write('<input type="file" name="'+name+'"')
if helpText != '':
f.write('" onmouseover="popup(\''+helpText+
'\')" onmouseout="popdown()" onclick="popdown()" ')
f.write('/>\n')
return
#--- strFloatCmp
def strFloatCmp(s1, s2):
v1 = float(s1)
v2 = float(s2)
return cmp(v1,v2)
#--- strIntCmp
def strIntCmp(s1, s2):
i1 = int(s1)
i2 = int(s2)
return cmp(i1,i2)
#--- getFields
def getFields(line):
global defaultFormatFlag, defaultFormat
k=0
if line.find(':') > 0 or defaultFormatFlag:
formatFlag = True
fieldList = []
ffList = line.split(',')
for field in ffList:
ff = field.split(':')
fieldList.append(ff[0])
if len(ff) > 1:
formatList.append(int(ff[1]))
else:
formatList.append(defaultFormat)
fieldDict[ff[0]] = k
k = k + 1
else:
formatFlag = False
fieldList = line.split(',')
for f in fieldList:
fieldDict[f] = k
k = k + 1
print >> flog, 'Field List'
print >>flog, fieldList
print >>flog, '\nField Dict'
print >>flog, fieldDict
if formatFlag:
print >>flog, 'Format List'
print >>flog, formatList
return fieldList, fieldDict, formatFlag, formatList
#--- myOpen
def myOpen(fname, type):
print >>flog, 'Opening:', fname, ', Type:', type
return open(fname, type)
#--- readCsvFile
def readCsvFile(fname):
global flog, iterName, Rows, iterDict
global fieldDict, fieldList, formatFlag, formatList
global ReadRowList, SelectedRowList, SelectedColList, iterIndex
print >>flog, 'readCsvFile: ' + fname
if not os.path.exists(fname):
doError('csv file "'+fname+'" does not exist')
f = myOpen(fname, 'r')
count=-1
Rows = []
ReadRowList = []
iterDict = {}
for iline in f:
print >>flog, iline
line = iline.strip()
if len(line) == 0:
continue
if line[0] != '#':
if count == -1:
fieldList, fieldDict, formatFlag, formatList = getFields(line)
if iterName in fieldDict:
iterIndex = fieldDict[iterName]
else:
iterIndex = fieldDict['exp']
iterName = 'exp'
print >>flog, "readCsvFile, iterIndex:", iterIndex
else:
rowList = line.split(',')
print >>flog, rowList
iterDict[rowList[iterIndex]] = count
Rows.append(rowList)
count += 1
elif line[0:6] == '#Path:':
Path = line[6:]
f.close()
for r in Rows:
ReadRowList.append(r[iterIndex])
SelectedRowList = ReadRowList*1
SelectedColList = fieldList*1
resetSelectedColDict()
return
#--- appendCsvFile
def appendCsvFile(fname):
global iterName, fieldList, fieldDict, iterDict, Rows
if not os.path.exists(fname):
doError('csv file "'+fname+'" does not exist')
fout = myOpen(fname, 'r')
count = -1
print >>flog, 'appendCsvFile: ', fname
iterIndex = fieldDict[iterName]
for iline in fout:
print >>flog, iline
line = iline.strip()
if len(line) == 0 or line[0] == '#':
continue;
if count == -1:
fieldListNew,fieldDictNew,formatFlagNew,formatListNew = getFields(line)
count = len(Rows) - 1
if not iterName in fieldDictNew:
doError('csv file "'+fname+'" does not have an "'+iterName+'" column.')
maxIter = 0
for i in iterDict.keys():
if int(i) > maxIter:
maxIter = int(i)
maxIter = int((maxIter+100)/100)*100
iterIndexNew = fieldDictNew[iterName]
else:
rowList = line.split(',')
print >>flog, rowList
iterNew = str(int(rowList[iterIndexNew]) + maxIter)
iterDict[iterNew] = count
rowListNew = []
for f in fieldList:
if f in fieldDictNew:
if f == iterName:
rowListNew.append(iterNew)
else:
rowListNew.append(rowList[fieldDictNew[f]])
else:
rowListNew.append(' ')
Rows.append(rowListNew)
count += 1
# elif line[0:6] == '#Path:':
# Path = line[6:]
fout.close()
return
#--- getHex
def getHex(s):
d = ord(s[0])
if d <= ord('9'):
rv = d - ord('0')
elif d <= ord('Z'):
rv = d - ord('A') + 10
else:
rv = d - ord('a') + 10
return rv
#--- replaceHex
def replaceHex(line):
i = line.find('%')
n = 0
while i >= 0 and n < 100000:
c = chr(getHex(line[i+1])*16 + getHex(line[i+2]))
line = line[0:i] + c + line[i+3:]
j = line[i+1:].find('%')
if j >= 0:
i = i + 1 + j
else:
i = -1
n = n + 1
return line
#--- getSelectedRowsNOT
def getSelectedRowsNOT(line):
SelectedRowList = []
commandList = line.split(' ')
for com in commandList:
if com.startswith('Rows='):
r = com.split('=')
SelectedRowList.append(r[1])
return SelectedRowList
#--- putHtmlHeader
def putHtmlHeader(fout, fieldList, formatFlag, formatList, colFormatFlag, foutName, title, image):
global iterName
htmlHeader = [
'<HTML> <HEAD> <TITLE>'+title+' </TITLE> \n',
'<STYLE TYPE="text/css">\n',
'ul {list-style-type:none;margin:0;padding:0;overflow:hidden;}\n',
'li {float:left;}\n',
'<!--\n#pop {POSITION:absolute;VISIBILITY:hidden;border:1px solid mediumblue;Z-INDEX:200;}\n',
# '//-->\n',
# '<!--\n',
'#fileWin {POSITION:absolute;VISIBILITY:hidden;Z-INDEX:198;}\n',
'//-->\n',
'</STYLE>\n',
'</HEAD> \n'
]
htmlHeader2 = [
'<BODY>\n',
'<DIV ID="pop"></DIV>\n',
'<DIV ID="fileWin"></DIV>\n',
'<SCRIPT TYPE="text/javascript">\n<!--\n',
'var skn, sknTimer, fileObj, menuState="",menuTimer;\n',
'var ns6=document.getElementById&&!document.all\n',
'if (ns6)\n',
'skn=document.getElementById("pop").style;\n',
'skn.visibility="visible"\nskn.display="none";\n',
'fileObj=document.getElementById("fileWin").style;\n',
'fileObj.visibility="visible"\nfileObj.display="none";\n',
'document.onmousemove=get_mouse;\n\n',
'menuTimer=setTimeout("initMenu()",50);\n',
# -- function showSkn
'function showSkn() {\n',
'skn.display=\'\'\n',
'}\n',
# -- function popup
'function popup(msg) {\n',
'var content="<TABLE WIDTH=400 BGCOLOR=\'lightblue\'><TD>"+msg+"</TD></TABLE>";\n',
'var allowPopup;\n',
'allowPopup=document.getElementsByName("HelpBubble").item(0).value\n',
'if(ns6 && allowPopup=="on"){\n',
'document.getElementById("pop").innerHTML=content\n',
# 'skn.display=\'\'\n',
'sknTimer=setTimeout("showSkn()",1000);\n',
'}\n',
'}\n\n',
# -- function mouse_over
'function mouse_over(id) {\n',
# 'alert("mouseOver");\n',
'document.getElementById(id).style.color="black"\n',
'}\n',
# -- function mouse_out
'function mouse_out(id) {\n',
# 'alert("mouseOver");\n',
# 'document.write("mouse_out");\n',
'if (menuState!=id) {\n',
'document.getElementById(id).style.color="white"\n',
'}\n}\n',
# -- function initMenu
'function initMenu() {\n',
'var mid=document.getElementsByName("Menu").item(0).value;\n',
'mouse_over(mid);\n',
'on_click(mid);\n',
'}\n',
# -- function on_click
'function on_click(id) {\n',
# 'alert("on_click, id="+id+", menuState="+menuState);\n',
'if(id!=menuState && menuState!="") {\n',
'document.getElementById(menuState).style.background="#98bf21";\n',
'document.getElementById(menuState).style.color="white";\n',
'document.getElementById(menuState+"Table").style.display="none"\n',
'}\n',
'menuState=id;\n',
'document.getElementsByName("Menu").item(0).value=id;\n',
'document.getElementById(id).style.background="#ccffcc"\n',
'var idTable=id+"Table";\n',
# 'var msg=document.getElementById(idTable).innerHTML;\n',
# 'alert("on_click, msg="+msg);\n',
'drawTable(idTable);\n',
# 'alert("mouse click end, menuState="+menuState);\n',
'}\n',
# -- function drawFile
'function drawTable(idTable) {\n',
# 'var content="<TABLE WIDTH=760 BGCOLOR=\'#ccffcc\'><TD>"+msg+"</TD></TABLE>";\n',
# 'document.getElementById("fileWin").innerHTML=content;\n',
# 'fileObj.left=8;\nfileObj.top=33;\n',
# 'alert("drawFile0");\n',
'var tableObj=document.getElementById(idTable).style;',
# 'alert("drawFile1");\n',
# 'tableObj.left=0;tableObj.top=0;\n',
'tableObj.display=\'\';\n',
# 'alert("drawFile2");\n',
# 'fileObj.display=\'\';\n',
'}\n',
# -- function get_mouse
'function get_mouse(e) {\n',
'var x=(ns6)?e.pageX:event.x+document.body.scrollLeft;\n',
'var rs=event.x+400;\n',
'if (rs > document.body.clientWidth) x=x-(rs-document.body.clientWidth+7);\n'
'skn.left=x;\n',
'var y=(ns6)?e.pageY:event.y+document.body.scrollTop;\n',
'skn.top=y+20;\n',
'}\n',
# -- function popdown
'function popdown() {\n',
'if (ns6)\n',
'skn.display="none";\n',
'clearTimeout(sknTimer);\n',
'}\n',
# -- function redo
'function redo() {\n',
' document.table.submit()\n',
'}\n',
# -- function timedRefresh
'function timedRefresh(timeoutPeriod) {\n',
' setTimeout("location.reload(true);", timeoutPeriod);\n',
'}\n',
'//-->\n</SCRIPT>\n',
# '<BODY onload="JavaScript:timedRefresh(60000);">\n',
# '<DIV ID="pop"></DIV>\n',
# '<DIV ID="fileWin"></DIV>\n',
# '<FORM name="table" method="post" action="http://'+hostName+'/cgi-bin/exp.py" enctype="multipart/form-data">\n',
'<FORM name="table" method="post" action="http://localhost/Exp/cgi-exec/exp.py" enctype="multipart/form-data">\n',
# enctype="multipart/form-data"
# enctype="text/plain"
]
for line in htmlHeader:
fout.write(line)
if (not 'SaveStatic' in CommandDict) or (not CommandDict['SaveStatic']):
for line in htmlHeader2:
fout.write(line)
else:
fout.write('<br>\n')
ioHelpDict = {
'file':
'Commands that read or write files',
'select':
'Commands that remove rows or columns',
'calc':
'Commands that modify the spreadsheet',
'plotting':
'Commands to plot data in the spreadsheet',
'settings':
'Commands to set display options',
'KeepRows':
'Select rows by clicking on the checkbox on the left of the row, '
'then press the button to remove the rows that are not selected. '
'To recover deleted rows, press the <b>Back</b> browser button.',
'DeleteRows':
'Select rows by clicking on the checkbox on the left of the row, '
'then press the button to remove the rows that are selected',
'AllRows':
'Selects all rows in the spreadsheet, then you can unselect some '
'before further action',
'KeepCols':
'Select columns by clicking on the checkbox on the top of the column, '
'then press the button to remove the columns thar are not selected.',
'DeleteCols':
'Select columns by clicking on the checkbox on the top of the column, '
'then press the button to remove the columns that are selected',
'AllCols':
'Selects all columns in the spreadsheet, then you can unselect some '
'before further action',
'HelpBubble':
'If checked show help bubble when the curson is on top of the frame '
'elements',
'ShowColFormatting':
'When set, shows on the top of each column the number of decimal '
'digits that will be shown for that column. You can also change it, '
'the choices are 0, 1, 2, 3 or 4 decimal digits.',
'SaveCommands':
'Save current form state under the name entered in the '
'text box',
'ReadCommands':
'Read form state from previously saved state under the name '
'entered in the text box',
'BrowseCommands':
'Show a list of names for previously saved form states',
'SavePage':
'Save current page under the name specified in the text box. '
'Use Browse Saved Pages to load a previously saved page.',
'SaveStatic':
'Page is saved without the commands header. Good for putting on '
'any web server.',
'ReadPage':
'Show directory of experiments with saved pages',
'csvFile':
'Select a csv file to read. The first row should contain the '
'column names. Each column name can optionally be followed by '
'a colon and a digit thar represents the number of decimal '
'places to use for that column in the spreadsheet.',
'loadCsvFile':
'Reload spreadsheet with the selected csv file.',
'AppendCsvFile':
'Append the selected csv file to the spreadsheet.',
'Select':
'Select rows that match the selection criteria.<br />'
'<b>Examples:</b><br />'
'1)    ca==cubic,buffers==1.2;rtt==3,exp<>0:11<br />'
'Matches all rows where (column <i>ca</i> equals <i>cubic</i> and '
'column <i>buffers</i> equals <i>1.2</i>) or (column <i>rtt</i> '
'equals <i>3</i> and (column <i>exp</i> > 0 and < 11) <br />'
'2)    exp[has].0<br />'
'Matches all rows where column <i>exp</i> has the substring <i>.0</i><br />'
'<b>The input should be of the form:</b><br />'
'   [< col_name >< op >< value >[< separator >]]+<br />'
'<b>Where:</b><br />'
'   < col_name > is the name of a column <br />'
'   < op > is one of ==, !=, <, <=, >, >=, <>, [has], [hasnot]<br />'
'   < value > is a number or a string <br />'
'   < separator > is one of:<br />'
'     ,   acts as AND<br />'
'     ;   acts as OR (lower precedence)',
'AverageBy':
'Average rows based on the column names in the text box. <br />'
'The resulting '
'spreadsheet will have one row for each combination of unique values '
'in each of the specified column names. The values of the other '
'columns in the spreadsheet will be the average of all the rows '
'that have the same values in the specified column names (if the '
'column has numerical values)<br />'
'Appending [int] to a column name in the text box results in only '
'comparing the integer component of the column values<br />'
'<b>Note:</b> A new column will be added at the end showing the '
'number of rows that was used in the average<br />'
'<b>For example</b>, if column <i>ca</i> has two values: '
'<i>bic</i> and '
'<i>cubic</i> and column <i>buffers</i> has two values: <i>1.2</i> '
'and <i>0.175</i> then the '
'resulting spreadsheet will have 4 rows (2*2)',
'Sort':
'Sort in increasing order by the specified column names. To sort in '
'decreasing order, add a <b>-</b> before the column name',
'Description':
'Create new <i>Descript</i> entries consisting of the fields entered '
'in the text box (separated by commas) followed by its value for '
'that row. '
'For example, if we have a spreadsheet with ca==cubic and '
'buffers==1.2 in the first row and ca==bic and buffers==0.175 '
'in the second row then '
'if <i>ca, buffers</i> is entered in the text box, '
'the <i>Descript</i> column of the new spreadsheet will have '
'<i>cubic buffers==1.2</i> in the first row and '
'<i>bic buffers==0.175</i> in the second row. Note that the column '
'name is not used for column <i>ca</i> and <i>Notes</i>. '
'This is useful when we want to plot more than one column '
'together.',
'ScaleColumns':
'Scale the columns specified in the text box (separated by commas) '
'by the scale factor specified in the <i>Factor</i> text box.',
'ScaleFactor':
'Scale the columns specified in the <i>Scale Columns</i> text box '
'(separated by commas) '
'by the scale factor specified in the <i>Scale Factor</i> text box.',
'ScaleDo':
'Scale the columns specified in the <i>Scale Columns</i> text box '
'(separated by commas) '
'by the scale factor specified in the <i>Scale Factor</i> text box.',
'FilterNotes':
'If string specified in text box is a substring of the value of '
'the <i>Notes</i> column, then the value of the <i>Notes</i> '
'column gets replaced with the input string; otherwise the '
'value <i>Notes</i> column gets replaced with an empty string. '
'This can be used to select rows based on a substring of the '
'Notes by first doing a <i>Filter Notes</i> followed by a '
'<i>Select</i>.',
'PercentTable':
'Create a display table using selected rows and columns. The first '
'row in the display table is the first row in the current table and '
'is displayed as is. Following rows are shown as relative percent '
'change if the entries are numbers, left as is otherwise. If the '
'entry in the top row is zero, corresponding entries in the following '
'rows are shown as they are.',
'NewColName':
'Add a new column with the name specified in the text box, and whose '
'value will be given by an operation (as specified in the drop '
'down menu) applied to the two columns specified by their names',
'NewColField1':
'Column name of the first operand',
'NewColOp':
'Operation to apply to the two columns to create a new column'
'& = string concatenation',
'NewColField2':
'Column name of the second operand',
'Do':
'Submit current form and apply changes to spreadsheet',
'plotX':
'Column name from where the X (horizontal) axis values will be taken. '
'Note that if there is more than '
'one row with the same value in this column, then bars in the graph '
'will overlap unless separated by specifying a <i>Series</i>.',
'plotY1':
'Column name from where the Y1 (left vertical) axis values will be '
'taken. These values are plotted with bars.',
'plotY2':
'Optional. Column name from where the Y2 (right vertical) axis values '
'will be taken. These values are plotted with red diamonds.',
'plotSeries':
'Optional. Column name from where the series is created. '
'When a series is '
'specified, rather than plotting one bar (or diamond) per X value, '
'<i>n</i> bars are plotted, where <i>n</i> is the number of unique '
'values in the <i>series column</i>. For example, suppose we want '
'to see the effect that buffer size has on losses for 3 TCP '
'variants (Cubic, BIC and Reno). If we set X:ca (TCP variant), '
'Y1:drops, and Series:buffers (buffer size, either 0.175 or 1.2 (MB)), '
'then the X axis will '
'have 3 lables: Cubic, BIC and Reno and for each label there will '
'be two bars plotting the packet drops, one for a buffer size of '
'175KB and the other for 1.2MB',
'plotFilename':
'The plot files will be saved under the specified name in Plot subdirectory',
'plotXLen':
'Lenght of X Axis in inches (default 6.5in)',
'plotXSize':
'Number of pixels in plot image in horizontal direction',
'plotYSize':
'Number of pixels in plot image in vertical direction',
'plotDo':
'Press this button after filling the appropriate plotting fields '
'to insert a plot at the end of the spreadsheet.',
'Y1min':
'Optional. Specifies the minimum value of the Y1 axis. Otherwise '
'the minimum value is chosen based on the data in the Y1 column.',
'Y2min':
'Optional. Specifies the minimum value of the Y2 axis. Otherwise '
'the minimum value is chosen based on the data in the Y2 column.',
'Y1div':
'Optional. Divide Y1 coordinate by specified value.',
'Y2div':
'Optional. Divide Y2 coordinate by specified value.',
'Y1eqY2':
'Optional. Check it to make both Y axis the same.',
'PlotPercent':
'Writes the change (as percent) between the first bar and the other '
'bars in a series. If the bars are wide, it is better to write it '
'horizontally, otherwise vertically.',
'PlotRatio':
'Only used when <i>Write Percent</i> is off. Similar to <i>Write '
'Percent</i>, but writes the ratio instead of the percent.',
'xUniform':
'Write the X axis labels with uniform spacing as opposed to the '
'spacing determined by the X values. Check this if not all the '
'values of the X axis are numbers.',
'Y1LogScale':
'Whether to use a logarithmic scale for the Y1 axis. The choices '
'are: <i>auto</i> to set it automatically based on the range of '
'values, <i>on</i> to use a log scale, or <i>off</i> to not use '
'a log scale.',
'Y2LogScale':
'Whether to use a logarithmic scale for the Y2 axis. The choices '
'are: <i>auto</i> to set it automatically based on the range of '
'values, <i>on</i> to use a log scale, or <i>off</i> to not use '
'a log scale.',
'BkgLevel':
'Optional. Set the grey level of the graph, where 0 is black and 1 '
'is white.',
'plotTitle':
'Optional. Sets the main title of the graph. To have more than one '
'Title line, separate them with a vertical bar.',
'plotXTitle':
'Optional. Sets the name of the X axis',
'plotY1Title':
'Optional. Sets the name of the Y1 (left vertical) axis.',
'plotY2Title':
'Optional. Sets the name of the Y2 (right vertical) axis.',
'plotSeriesTitle':
'Optional. Sets the name for the Series'
}
ioObjects = [
['menuBeg', "#98bf21"],
['menuButton', 'FILE', 'file', 150, 25],
['menuButton', 'SELECTION', 'select', 150, 25],
['menuButton', 'CALCULATION', 'calc', 150, 25],
['menuButton', 'PLOTTING', 'plotting', 150, 25],
['menuButton', 'SETTINGS', 'settings', 150, 25],
['menuEnd'],
# -- fileTable
['text', '<TABLE BORDER=0 BGCOLOR="#ccffcc" id="fileTable" style="display:none;margin-top:-20px" width=760> <TR><TD>\n<p>', 1],
['textInput', 'Save Fields: ', 'SaveCommands', '', 25, 1, 0],
['textInput', 'Read Fields: ', 'ReadCommands', '', 25, 1, 0],
['button', 'Browse Saved Fields', 'BrowseCommands', 0, 1],
['eop', 1],
['textInput', 'Save Page: ', 'SavePage', '', 30, 1, 0],
['checkbox', 'Save Static', 'SaveStatic', False, 0],
['button', 'Browse Saved Pages', 'ReadPage', 0, 1],
['eop', 1],
['fileInput', 'New csv file: ', 'csvFile', 'text/csv', 1],
['button', 'Load File', 'loadCsvFile', 0, 1],
['button', 'Append File', 'AppendCsvFile', 0, 1],
['text', '</TD></TR></TABLE>', 1],
# -- selectTable
['text', '<TABLE BORDER=0 BGCOLOR="#ccffcc" id="selectTable" style="display:none;margin-top:-20px" width=760> <TR> <TD>\n', 1],
['text', 'Rows: ', 1],
['button', 'Keep Selected', 'KeepRows', 0, 0],
['button', 'Delete Selected', 'DeleteRows', 0, 0],
['button', 'Select All', 'AllRows', 0, 0],
['eop', 1],
['text', 'Cols: ', 1],
['button', 'Keep Selected', 'KeepCols', 0, 0],
['button', 'Delete Selected', 'DeleteCols', 0, 0],
['button', 'Select All', 'AllCols', 0, 0],
['eop', 1],
['textInput', 'Select: ', 'Select', '', 60, 1, 0],
['text', '</TD></TR></TABLE>', 1],
# -- calcTable
['text', '<TABLE BORDER=0 BGCOLOR="#ccffcc" id="calcTable" style="display:none;margin-top:-20px" width=760> <TR> <TD>\n', 1],
['textInput', 'Average By: ', 'AverageBy', '', 30, 1, 0],
['textInput', 'Sort: ', 'Sort', '', 20, 1, 0],
['eop', 1],
['textInput', 'Make Descript: ', 'Description', '', 25, 1, 0],
['textInput', 'Filter Notes: ', 'FilterNotes', '', 25, 1, 1],
['eop', 1],
['textInput', 'Scale Columns: ', 'ScaleColumns', '', 30, 1, 0],
['textInput', 'Scale Factor: ', 'ScaleFactor', '', 10, 1, 0],
['button', 'Do Scaling', 'ScaleDo', 0, 1],
['eop', 1],
['textInput', 'New Column: ', 'NewColName', '', 15, 1, 0],
['textInput', '= ', 'NewColField1', '', 15, 1, 0],
['selectInput', '', 'NewColOp', 'NewColDiv= / ,NewColMult= * ,'
'NewColAdd= + ,NewColSub= - ,NewColConcat= & ', '', 1, 0, False],
['textInput', '', 'NewColField2', '', 15, 1, 1],
['button', 'Do', 'Do', 1, 1],
['eop', 1],
['button', 'Create Percent Table', 'PercentTable', 0, 1],
['text', '</TD></TR></TABLE>', 1],
# -- plottingTable
['text', '<TABLE BORDER=0 BGCOLOR="#ccffcc" id="plottingTable" style="display:none;margin-top:-20px" width=760> <TR> <TD>\n', 1],
['textInput', 'Filename:', 'plotFilename', '', 16, 1, 1],
['textInput', 'X Len:', 'plotXLen', '6.5', 8, 1, 1],
['text', 'Plot size in Pixels ', 1],
['textInput', 'X:', 'plotXSize', '2400', 8, 1, 1],
['textInput', 'Y:', 'plotYSize', '1200', 8, 1, 1],
['button', 'Do Plot', 'plotDo', 0, 1],
['eop', 1],
['textInput', 'X:', 'plotX', '', 10, 1, 1],
['textInput', 'Y1:', 'plotY1', '', 10, 1, 1],
['textInput', 'Y2:', 'plotY2', '', 10, 1, 1],
['textInput', 'Series:', 'plotSeries', '', 10, 1, 1],
['eop', 1],
['textInput', 'Y1min:', 'Y1min', '',
4, 1, 1],
['textInput', 'Y2min:', 'Y2min', '', 4, 1, 1],
['textInput', 'Y1div:', 'Y1div', '', 4, 1, 1],
['textInput', 'Y2div:', 'Y2div', '', 4, 1, 1],
['eop', 1],
['checkbox', 'Y1=Y2', 'Y1eqY2', False, 0],
['selectInput', 'Write Percent:', 'PlotPercent', 'Off=Off,'
'Horizontal=Horizontal,Vertical=Vertical,Off=Off', '', 1, 1, False],
['selectInput', 'Write Ratio:', 'PlotRatio', 'Off=Off, Horizontal=Horizontal,'
'Vertical=Vertical', '', 1, 1, False],
['eop', 1],
['checkbox', 'Even X labels:', 'xUniform', False, 1],
['selectInput', 'Y1 log scale:', 'Y1LogScale', 'Auto=Auto,Off=Off,On=On',
'', 1, 0, False],
['selectInput', 'Y2 log scale:', 'Y2LogScale', 'Auto=Auto,Off=Off,On=On',
'', 1, 0, False],
['textInput', 'Background:', 'BkgLevel', '0.8', 3, 1, 0],
['eop', 1],
['textInput', 'Title:', 'plotTitle',
'', 30, 1, 1],
['textInput', 'X Title:', 'plotXTitle', '', 20, 1, 1],
['textInput', 'Y1 Title:', 'plotY1Title', '', 20, 1, 1],
['eop', 1],
['textInput', 'Y2 Title:', 'plotY2Title', '', 20, 1, 1],
['textInput', 'Series Title:', 'plotSeriesTitle', '', 20, 1, 1],
['text', '</TD></TR></TABLE>', 1],
# -- settingsTable
['text', '<TABLE BORDER=0 BGCOLOR="#ccffcc" id="settingsTable" style="display:none;margin-top:-20px" width=760> <TR> <TD>\n', 1],
['checkbox', '<b>Enable Help Bubble (after 1 sec): </b>', 'HelpBubble', False, 0],
['eop', 1],
['checkbox', '<b>Show Column Formatting: </b>', 'ShowColFormatting',
True, 1],
['eop', 0],
['textInput', '<b>Row Color Change:</b>', 'rowColorChange', rowColorChangeVal, 20, 1, 1],
['eop', 0],
['text', '<br /></TD></TR></TABLE>', 1],
# -- Hidden inputs
['hidden', 'File', foutName],
['hidden', 'Path', Path],
['hidden', 'relPath', relPath],
['hidden', 'IterFile', IterFile],
['hidden', 'Menu', menuState],
['hidden', 'Image', image],
]
if (not 'SaveStatic' in CommandDict) or (not CommandDict['SaveStatic']):
for obj in ioObjects:
if len(obj) > 2 and obj[2] in ioHelpDict:
helpStr = ioHelpDict[obj[2]]
else:
helpStr = ''
if obj[0] == 'text':
writeText(fout, obj[1], obj[2])
elif obj[0] == 'button':
writeButton(fout, obj[1], obj[2], obj[3], obj[4], helpStr)
elif obj[0] == 'textInput':
writeTextInput(fout, obj[1], obj[2], obj[3], obj[4], obj[5], obj[6],