summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier Dufour2013-06-10 13:10:23 +0200
committerOlivier Dufour2013-06-27 11:06:32 +0200
commit13c08a2bcf3748bf200703a40420ecb16f0fa335 (patch)
treecf2b12aa7cb47bffe15d6b222aec9440cfd5389d
parent002c7835894b3a2f506b043cc6b365460152e24b (diff)
validation/test/av_home: handle missing files in report, refs #4047
-rwxr-xr-xvalidation/test/av_home/av_home.py115
1 files changed, 82 insertions, 33 deletions
diff --git a/validation/test/av_home/av_home.py b/validation/test/av_home/av_home.py
index 12cbe580f9..10e30e3eff 100755
--- a/validation/test/av_home/av_home.py
+++ b/validation/test/av_home/av_home.py
@@ -138,7 +138,10 @@ def iperf_client_run ():
def prepare_points (mode):
# Get min and max value from server logs
- f = open (os.path.join (av_home_attr.output_dir, "server_log"), "r")
+ try:
+ f = open (os.path.join (av_home_attr.output_dir, "server_log"), "r")
+ except IOError:
+ return
lines = f.readlines ()
minimum = 0
maximum = 0
@@ -173,7 +176,10 @@ def prepare_points (mode):
print >> f, s
f.close ()
# Prepare tonemap points
- f = open (os.path.join (av_home_attr.output_dir, "tonemap"), "r")
+ try:
+ f = open (os.path.join (av_home_attr.output_dir, "tonemap"), "r")
+ except IOError:
+ return
lines = f.readlines ()[2:]
s = ""
for l in lines:
@@ -187,7 +193,10 @@ def prepare_points (mode):
def get_general_result (mode):
# Get average up and down throughput
- f = open (os.path.join (av_home_attr.output_dir, "server_log"), "r")
+ try:
+ f = open (os.path.join (av_home_attr.output_dir, "server_log"), "r")
+ except IOError:
+ return
lines = f.readlines ()
result_re = re.compile (r"^.* 0\.0-[0-9]+\.[0-9].* ([0-9]+.*) Mbits/sec")
avg = ""
@@ -201,7 +210,10 @@ def get_general_result (mode):
else:
print "Average download throughput: %s Mbps" % avg
f.close ()
- f = open (os.path.join (av_home_attr.output_dir, "client_log"), "r")
+ try:
+ f = open (os.path.join (av_home_attr.output_dir, "client_log"), "r")
+ except IOError:
+ return
lines = f.readlines ()
server_re = re.compile(r".*Server Report.*")
avg = ""
@@ -226,7 +238,10 @@ def get_general_result (mode):
if c == '0':
available_carrier += 1
f.close ()
- f = open (os.path.join (av_home_attr.output_dir, "tonemap-%s_plot" % mode), "r")
+ try:
+ f = open (os.path.join (av_home_attr.output_dir, "tonemap-%s_plot" % mode), "r")
+ except IOError:
+ return
line = f.readlines ()[0]
f.close ()
mod_list = [0, 0, 0, 0, 0, 0, 0, 0]
@@ -245,7 +260,10 @@ def get_general_result (mode):
7: "1024-QAM" }
print "Using %d carriers on %d (%d%%)" % (nb_carrier, available_carrier, (nb_carrier * 100) / available_carrier)
avg_str = "%f bits per symbol" % (float(bit_value) / float(available_carrier))
- f = open (os.path.join (av_home_attr.output_dir, "tonemap"), "r")
+ try:
+ f = open (os.path.join (av_home_attr.output_dir, "tonemap"), "r")
+ except IOError:
+ return
fec = int (f.readlines ()[0])
if fec == 1:
fec_str = "FEC 16/21"
@@ -285,10 +303,19 @@ def prepare_plot ():
def do_plot (direction, directory):
import pylab
- if direction == "rx":
- f = open (os.path.join (av_home_attr.prefix, directory, "master_plot"), "r")
- else:
- f = open (os.path.join (av_home_attr.prefix, directory, "slave_plot"), "r")
+ try:
+ if direction == "rx":
+ f = open (os.path.join (av_home_attr.prefix,
+ directory,
+ "master_plot"),
+ "r")
+ else:
+ f = open (os.path.join (av_home_attr.prefix,
+ directory,
+ "slave_plot"),
+ "r")
+ except IOError:
+ return
lines = f.readlines ()
maximum = 0
minimum = 0
@@ -314,10 +341,19 @@ def do_plot (direction, directory):
pylab.gcf().savefig (os.path.join (av_home_attr.prefix, directory, "master-%s.png" % direction))
pylab.clf()
f.close ()
- if direction == "rx":
- f = open (os.path.join (av_home_attr.prefix, directory, "tonemap-slave_plot"), "r")
- else:
- f = open (os.path.join (av_home_attr.prefix, directory, "tonemap-master_plot"), "r")
+ try:
+ if direction == "rx":
+ f = open (os.path.join (av_home_attr.prefix,
+ directory,
+ "tonemap-slave_plot"),
+ "r")
+ else:
+ f = open (os.path.join (av_home_attr.prefix,
+ directory,
+ "tonemap-master_plot"),
+ "r")
+ except IOError:
+ return
lines = f.readlines ()[0]
x = [ j for j in xrange (1536)]
y = [ lines[j] for j in xrange (1536)]
@@ -406,36 +442,49 @@ def get_name (name):
return result + "\n" + underline
def get_field (d, file):
- f = open (os.path.join (av_home_attr.prefix, d, "%s-master" % file), "r")
- value = f.read ()
- f.close ()
- f = open (os.path.join (av_home_attr.prefix, d, "%s-slave" % file), "r")
- value += f.read ()
- f.close ()
+ try:
+ f = open (os.path.join (av_home_attr.prefix, d, "%s-master" % file), "r")
+ value = f.read ()
+ f.close ()
+ f = open (os.path.join (av_home_attr.prefix, d, "%s-slave" % file), "r")
+ value += f.read ()
+ f.close ()
+ except IOError:
+ return "Data missing ..."
return value
def get_graph (d):
tpl = """
Upload:
-.. image:: {upload}
-.. image:: {tx}
+{upload}
+
+{tx}
Download:
-.. image:: {download}
-.. image:: {rx}
+{download}
+
+{rx}
"""
- upload = "%s/master-tx.png" % d
- download = "%s/master-rx.png" % d
- tx = "%s/tonemap-tx.png" % d
- rx = "%s/tonemap-rx.png" % d
-
- return tpl.format (upload = upload,
- download = download,
- tx = tx,
- rx = rx)
+ images = [ "master-tx.png",
+ "master-rx.png",
+ "tonemap-tx.png",
+ "tonemap-rx.png" ]
+ paths = {}
+ for img in images:
+ try:
+ f = open ("%s/%s" % (d, img), "r")
+ f.close ()
+ paths[img] = ".. image:: %s/%s" % (d, img)
+ except IOError:
+ paths[img] = "Data missing ..."
+
+ return tpl.format (upload = paths["master-tx.png"],
+ download = paths["master-rx.png"],
+ tx = paths["tonemap-tx.png"],
+ rx = paths["tonemap-rx.png"])
def generate_report ():
f = open (os.path.join (av_home_attr.prefix, "template.rst"), "r")