def get_response_content(fs): # get the tree tree = NewickIO.parse(fs.tree, FelTree.NewickTree) ordered_names = list(sorted(node.name for node in tree.gen_tips())) n = len(ordered_names) if n < 2: raise HandlingError('the newick tree should have at least two leaves') # get the eigendecomposition D = np.array(tree.get_distance_matrix(ordered_names)) G = (-0.5) * MatrixUtil.double_centered(D) eigenvalues, eigenvector_transposes = np.linalg.eigh(G) eigenvectors = eigenvector_transposes.T sorted_eigensystem = list(reversed(list(sorted((w, v) for w, v in zip(eigenvalues, eigenvectors))))) sorted_eigenvalues, sorted_eigenvectors = zip(*sorted_eigensystem) M = zip(*sorted_eigenvectors) # write the html out = StringIO() print >> out, '<html>' print >> out, '<body>' print >> out, HtmlTable.get_labeled_table_string( sorted_eigenvalues, ordered_names, M) print >> out, '</body>' print >> out, '</html>' # write the response return out.getvalue()
def get_response_content(fs): # get the tree tree = NewickIO.parse(fs.tree, FelTree.NewickTree) # define the ordering of the nodes ordered_names = list(sorted(node.get_name() for node in tree.preorder())) name_to_id = dict((node.get_name(), id(node)) for node in tree.preorder()) ordered_ids = [name_to_id[name] for name in ordered_names] # get the affinity matrix A = np.array(tree.get_affinity_matrix(ordered_ids)) # get the normalized laplacian for row, name in zip(A, ordered_names): assert sum(row), name row_sums = [sum(row) for row in A] n = len(A) L_script = np.zeros((n, n)) for i in range(n): for j in range(n): if i == j: L_script[i][j] = 1 L_script[i][j] -= A[i][j] / math.sqrt(row_sums[i] * row_sums[j]) # get the eigendecomposition eigenvalues, eigenvector_transposes = np.linalg.eigh(L_script) eigenvectors = eigenvector_transposes.T eigensystem = [(abs(w), w, v.tolist()) for w, v in zip(eigenvalues, eigenvectors)] sorted_eigensystem = list(reversed(sorted(eigensystem))) sorted_abs_eigenvalues, sorted_eigenvalues, sorted_eigenvectors = zip( *sorted_eigensystem) M = zip(*sorted_eigenvectors) # turn the numbers into strings format_string = '%%.%df' % fs.precision M_strings = [[format_string % value for value in row] for row in M] sorted_eigenvalue_strings = [format_string % w for w in sorted_eigenvalues] # write the html out = StringIO() print >> out, '<html>' print >> out, '<body>' print >> out, HtmlTable.get_labeled_table_string(sorted_eigenvalue_strings, ordered_names, M_strings) print >> out, '</body>' print >> out, '</html>' # write the response return out.getvalue()
def cpuMem(namespace, caption): titles = ["POD", "Container", "Resources"] formats = ["str", "str", "str"] listCpuMem = [] pods = helper.getPodStatus(namespace) for pod in pods: if (pod.startswith("NAME READY STATUS RESTARTS AGE")): continue values = pod.split(" ") if (len(values) < 5): continue podname = values[0] #for prefix in config.grafana_pods: # if(podname.startswith(prefix)): cpuMemInfo = cpumem.containerCpuMem(namespace, podname) listCpuMem += cpuMemInfo result = htmlTable.table(titles, formats, listCpuMem, caption) return result, pods
def get_response_content(fs): # get the tree tree = NewickIO.parse(fs.tree, FelTree.NewickTree) # define the ordering of the nodes ordered_names = list(sorted(node.get_name() for node in tree.preorder())) name_to_id = dict((node.get_name(), id(node)) for node in tree.preorder()) ordered_ids = [name_to_id[name] for name in ordered_names] # get the affinity matrix A = np.array(tree.get_affinity_matrix(ordered_ids)) # get the normalized laplacian for row, name in zip(A, ordered_names): assert sum(row), name row_sums = [sum(row) for row in A] n = len(A) L_script = np.zeros((n,n)) for i in range(n): for j in range(n): if i == j: L_script[i][j] = 1 L_script[i][j] -= A[i][j] / math.sqrt(row_sums[i]*row_sums[j]) # get the eigendecomposition eigenvalues, eigenvector_transposes = np.linalg.eigh(L_script) eigenvectors = eigenvector_transposes.T eigensystem = [(abs(w), w, v.tolist()) for w, v in zip(eigenvalues, eigenvectors)] sorted_eigensystem = list(reversed(sorted(eigensystem))) sorted_abs_eigenvalues, sorted_eigenvalues, sorted_eigenvectors = zip(*sorted_eigensystem) M = zip(*sorted_eigenvectors) # turn the numbers into strings format_string = '%%.%df' % fs.precision M_strings = [[format_string % value for value in row] for row in M] sorted_eigenvalue_strings = [format_string % w for w in sorted_eigenvalues] # write the html out = StringIO() print >> out, '<html>' print >> out, '<body>' print >> out, HtmlTable.get_labeled_table_string( sorted_eigenvalue_strings, ordered_names, M_strings) print >> out, '</body>' print >> out, '</html>' # write the response return out.getvalue()
def get_response_content(fs): # get the tree tree = NewickIO.parse(fs.tree, FelTree.NewickTree) ordered_names = list(sorted(node.name for node in tree.gen_tips())) n = len(ordered_names) if n < 2: raise HandlingError("the newick tree should have at least two leaves") # get the eigendecomposition D = np.array(tree.get_distance_matrix(ordered_names)) G = (-0.5) * MatrixUtil.double_centered(D) eigenvalues, eigenvector_transposes = np.linalg.eigh(G) eigenvectors = eigenvector_transposes.T sorted_eigensystem = list(reversed(list(sorted((w, v) for w, v in zip(eigenvalues, eigenvectors))))) sorted_eigenvalues, sorted_eigenvectors = zip(*sorted_eigensystem) M = zip(*sorted_eigenvectors) # write the html out = StringIO() print >> out, "<html>" print >> out, "<body>" print >> out, HtmlTable.get_labeled_table_string(sorted_eigenvalues, ordered_names, M) print >> out, "</body>" print >> out, "</html>" # write the response return out.getvalue()
def do_command_line_analysis(options): """ Print some stuff to stdout, and show a progress bar on stderr. @param options: an object from optparse """ # load the tree, using the default tree if no filename was provided tree, tree_remark = get_tree_and_remark(options) # initialize the simulation objects sims = [ Simulation(Clustering.NeighborJoiningDMS(), 'nj', 'neighbor joining'), Simulation(Clustering.StoneSpectralSignDMS(), 'nj', 'spectral sign cut with neighbor joining fallback'), Simulation(Clustering.RandomDMS(), 'nj', 'random partitioning') ] # possibly add the slow simulation if options.use_exact: sims.append( Simulation(Clustering.StoneExactDMS(), 'nj', 'exact criterion with neighbor joining fallback')) # define the simulation parameters reconstruction_count = options.nsamples sequence_length_string = options.sequence_length if sequence_length_string == 'inf': sequence_length = float('inf') else: sequence_length = int(sequence_length_string) inf_replacement = 20.0 if options.reject_inf: inf_replacement = None elif options.replace_inf: try: inf_replacement = float(options.replace_inf) except ValueError: msg = 'invalid replace_inf value: ' raise OptionError(msg + str(options.replace_inf)) zero_replacement = 0 if options.reject_zero: zero_replacement = None elif options.replace_zero: try: zero_replacement = float(options.replace_zero) except ValueError: msg = 'invalid replace_zero value: ' raise OptionError(msg + str(options.replace_zero)) # start the html file print '<html><body>' # show the simulation parameters print 'original tree source:', tree_remark, '<br/>' print 'reconstruction count:', reconstruction_count, '<br/>' print 'sequence length:', sequence_length, '<br/>' # set the simulation parameters for each simulation for sim in sims: sim.set_original_tree(tree) # If there is only one reconstruction per method # then show the progress of the tree builder. if reconstruction_count == 1: sim.set_verbose() # define an arbitrary but consistent ordering of the taxa ordered_names = [node.name for node in tree.gen_tips()] try: # attempt to simulate a bunch of distance matrices if options.verbose: print 'sampling', reconstruction_count, 'distance matrices...' # initialize the distance matrix sampler sampler = DMSampler.DMSampler(tree, ordered_names, sequence_length) sampler.set_inf_replacement(inf_replacement) sampler.set_zero_replacement(zero_replacement) # start the progress bar pbar = Progress.Bar(1.0) # sample some distance matrices distance_matrices = [] for result in sampler.gen_samples_or_none(): # if we got a result then update the distance matrix list if result: sequence_list, D = result distance_matrices.append(D) # Update the progressbar regardless of whether or not # the proposal was accepted. remaining_acceptances = reconstruction_count - len( distance_matrices) numerator = sampler.get_completed_proposals() denominator = numerator + sampler.get_remaining_proposals( remaining_acceptances) dms_fraction = float(numerator) / float(denominator) dms_total = 1.0 / (1 + len(sims)) pbar.update(dms_fraction * dms_total) # if we have enough samples then break the loop if not remaining_acceptances: break # reconstruct trees using various methods for i, sim in enumerate(sims): if options.verbose: print 'running "%s"...' % sim.description sim.run(distance_matrices, ordered_names) pbar.update(float(i + 2) / float(1 + len(sims))) # stop the progress bar pbar.finish() # get the simulation data table = [('method', 'seconds', 'uniform loss', 'weighted loss')] for sim in sims: table.append((sim.description, sim.get_running_time(), sim.get_uniform_loss(), sim.get_deep_loss())) # convert the row major matrix into an html table print HtmlTable.get_table_string(table) # end the html file print '</html></body>' except KeyboardInterrupt: print 'interrupted stage', pbar.progress, 'of', pbar.high
def get_response_content(fs): # start writing the html response out = StringIO() print >> out, '<html>' print >> out, '<body>' # get the tree and the column sent by the user pruned_tree, taxon_to_aa_letter = get_tree_and_column(fs) # get the weights of the taxa taxon_weight_pairs = LeafWeights.get_stone_weights(pruned_tree) # show the raw physicochemical property table if fs.show_raw_pc_table: print >> out, 'raw physicochemical property table:' print >> out, '<br/>' col_labels = MAPP.g_property_names row_labels = Codon.g_aa_letters table = MAPP.g_property_array print >> out, HtmlTable.get_labeled_table_string( col_labels, row_labels, table) print >> out, '<br/><br/>' # calculate the standardized physicochemical property table standardized_property_array = MAPP.get_standardized_property_array( MAPP.g_property_array) # show the standardized physicochemical property table if fs.show_standardized_pc_table: print >> out, 'standardized physicochemical property table:' print >> out, '<br/>' col_labels = MAPP.g_property_names row_labels = Codon.g_aa_letters table = standardized_property_array print >> out, HtmlTable.get_labeled_table_string( col_labels, row_labels, table) print >> out, '<br/><br/>' # calculate the physicochemical property correlation matrix correlation_matrix = MAPP.get_property_correlation_matrix( standardized_property_array) # show the physicochemical property correlation matrix if fs.show_pc_correlation_matrix: print >> out, 'physicochemical property correlation matrix:' print >> out, '<br/>' col_labels = MAPP.g_property_names row_labels = MAPP.g_property_names table = correlation_matrix print >> out, HtmlTable.get_labeled_table_string( col_labels, row_labels, table) print >> out, '<br/><br/>' # show the pruned tree if fs.show_tree: tree_string = NewickIO.get_narrow_newick_string(pruned_tree, 80) lines = StringIO(tree_string).readlines() lines = [line.rstrip() for line in lines] print >> out, 'pruned phylogenetic tree in newick format:' print >> out, '<pre>' for line in lines: print >> out, cgi.escape(line) print >> out, '</pre>' print >> out, '<br/>' # show the weights if fs.show_weights: taxa, weights = zip(*taxon_weight_pairs) table = [weights] row_labels = ['weight'] col_labels = taxa print >> out, 'taxon weights:' print >> out, '<br/>' print >> out, HtmlTable.get_labeled_table_string( col_labels, row_labels, table) print >> out, '<br/><br/>' # estimate the amino acid distribution for the column, # taking into account the tree and a uniform prior. weights = [] aa_indices = [] for taxon, weight in taxon_weight_pairs: weights.append(weight) aa_indices.append(aa_letter_to_aa_index(taxon_to_aa_letter[taxon])) aa_distribution = MAPP.estimate_aa_distribution(weights, aa_indices) # show the estimated amino acid distribution if fs.show_aa_distribution: table = [aa_distribution] row_labels = ['weight'] col_labels = Codon.g_aa_letters print >> out, 'estimated amino acid distribution:' print >> out, '<br/>' print >> out, HtmlTable.get_labeled_table_string( col_labels, row_labels, table) print >> out, '<br/><br/>' # estimate the mean and variance of each physicochemical property est_pc_means = MAPP.estimate_property_means( standardized_property_array, aa_distribution) est_pc_variances = MAPP.estimate_property_variances( standardized_property_array, aa_distribution) # show the estimated mean and variance of each physicochemical property if fs.show_pc_distribution: table = [est_pc_means, est_pc_variances] row_labels = ['mean', 'variance'] col_labels = MAPP.g_property_names print >> out, 'estimated physicochemical property moments:' print >> out, '<br/>' print >> out, HtmlTable.get_labeled_table_string( col_labels, row_labels, table) print >> out, '<br/><br/>' # calculate the deviation from each property mean # for each possible amino acid deviations = MAPP.get_deviations( est_pc_means, est_pc_variances, standardized_property_array) # show the deviation from each property mean for each possible amino acid if fs.show_deviations: print >> out, 'deviations of amino acids from the normal distribution' print >> out, 'estimated for each property:' print >> out, '<br/>' col_labels = MAPP.g_property_names row_labels = Codon.g_aa_letters table = deviations print >> out, HtmlTable.get_labeled_table_string( col_labels, row_labels, table) print >> out, '<br/><br/>' # calculate the impact scores impact_scores = MAPP.get_impact_scores(correlation_matrix, deviations) # show the impact scores if fs.show_impact_scores: table = [impact_scores] row_labels = ['impact'] col_labels = Codon.g_aa_letters print >> out, 'impact scores:' print >> out, '<br/>' print >> out, HtmlTable.get_labeled_table_string( col_labels, row_labels, table) print >> out, '<br/><br/>' # calculate the p-values p_values = [] for score in impact_scores: ntaxa = len(taxon_weight_pairs) p_values.append(MAPP.get_p_value(score, ntaxa)) # show the p-values if fs.show_p_values: table = [p_values] row_labels = ['p-value'] col_labels = Codon.g_aa_letters print >> out, 'p-values:' print >> out, '<br/>' print >> out, HtmlTable.get_labeled_table_string( col_labels, row_labels, table) print >> out, '<br/><br/>' # write the html footer print >> out, '</body>' print >> out, '</html>' # return the response return out.getvalue()
def do_command_line_analysis(options): """ Print some stuff to stdout, and show a progress bar on stderr. @param options: an object from optparse """ # load the tree, using the default tree if no filename was provided tree, tree_remark = get_tree_and_remark(options) # initialize the simulation objects sims = [ Simulation(Clustering.NeighborJoiningDMS(), "nj", "neighbor joining"), Simulation(Clustering.StoneSpectralSignDMS(), "nj", "spectral sign cut with neighbor joining fallback"), Simulation(Clustering.RandomDMS(), "nj", "random partitioning"), ] # possibly add the slow simulation if options.use_exact: sims.append(Simulation(Clustering.StoneExactDMS(), "nj", "exact criterion with neighbor joining fallback")) # define the simulation parameters reconstruction_count = options.nsamples sequence_length_string = options.sequence_length if sequence_length_string == "inf": sequence_length = float("inf") else: sequence_length = int(sequence_length_string) inf_replacement = 20.0 if options.reject_inf: inf_replacement = None elif options.replace_inf: try: inf_replacement = float(options.replace_inf) except ValueError: msg = "invalid replace_inf value: " raise OptionError(msg + str(options.replace_inf)) zero_replacement = 0 if options.reject_zero: zero_replacement = None elif options.replace_zero: try: zero_replacement = float(options.replace_zero) except ValueError: msg = "invalid replace_zero value: " raise OptionError(msg + str(options.replace_zero)) # start the html file print "<html><body>" # show the simulation parameters print "original tree source:", tree_remark, "<br/>" print "reconstruction count:", reconstruction_count, "<br/>" print "sequence length:", sequence_length, "<br/>" # set the simulation parameters for each simulation for sim in sims: sim.set_original_tree(tree) # If there is only one reconstruction per method # then show the progress of the tree builder. if reconstruction_count == 1: sim.set_verbose() # define an arbitrary but consistent ordering of the taxa ordered_names = [node.name for node in tree.gen_tips()] try: # attempt to simulate a bunch of distance matrices if options.verbose: print "sampling", reconstruction_count, "distance matrices..." # initialize the distance matrix sampler sampler = DMSampler.DMSampler(tree, ordered_names, sequence_length) sampler.set_inf_replacement(inf_replacement) sampler.set_zero_replacement(zero_replacement) # start the progress bar pbar = Progress.Bar(1.0) # sample some distance matrices distance_matrices = [] for result in sampler.gen_samples_or_none(): # if we got a result then update the distance matrix list if result: sequence_list, D = result distance_matrices.append(D) # Update the progressbar regardless of whether or not # the proposal was accepted. remaining_acceptances = reconstruction_count - len(distance_matrices) numerator = sampler.get_completed_proposals() denominator = numerator + sampler.get_remaining_proposals(remaining_acceptances) dms_fraction = float(numerator) / float(denominator) dms_total = 1.0 / (1 + len(sims)) pbar.update(dms_fraction * dms_total) # if we have enough samples then break the loop if not remaining_acceptances: break # reconstruct trees using various methods for i, sim in enumerate(sims): if options.verbose: print 'running "%s"...' % sim.description sim.run(distance_matrices, ordered_names) pbar.update(float(i + 2) / float(1 + len(sims))) # stop the progress bar pbar.finish() # get the simulation data table = [("method", "seconds", "uniform loss", "weighted loss")] for sim in sims: table.append((sim.description, sim.get_running_time(), sim.get_uniform_loss(), sim.get_deep_loss())) # convert the row major matrix into an html table print HtmlTable.get_table_string(table) # end the html file print "</html></body>" except KeyboardInterrupt: print "interrupted stage", pbar.progress, "of", pbar.high
def get_response_content(fs): # start writing the html response out = StringIO() print >> out, '<html>' print >> out, '<body>' # get the tree and the column sent by the user pruned_tree, taxon_to_aa_letter = get_tree_and_column(fs) # get the weights of the taxa taxon_weight_pairs = LeafWeights.get_stone_weights(pruned_tree) # show the raw physicochemical property table if fs.show_raw_pc_table: print >> out, 'raw physicochemical property table:' print >> out, '<br/>' col_labels = MAPP.g_property_names row_labels = Codon.g_aa_letters table = MAPP.g_property_array print >> out, HtmlTable.get_labeled_table_string( col_labels, row_labels, table) print >> out, '<br/><br/>' # calculate the standardized physicochemical property table standardized_property_array = MAPP.get_standardized_property_array( MAPP.g_property_array) # show the standardized physicochemical property table if fs.show_standardized_pc_table: print >> out, 'standardized physicochemical property table:' print >> out, '<br/>' col_labels = MAPP.g_property_names row_labels = Codon.g_aa_letters table = standardized_property_array print >> out, HtmlTable.get_labeled_table_string( col_labels, row_labels, table) print >> out, '<br/><br/>' # calculate the physicochemical property correlation matrix correlation_matrix = MAPP.get_property_correlation_matrix( standardized_property_array) # show the physicochemical property correlation matrix if fs.show_pc_correlation_matrix: print >> out, 'physicochemical property correlation matrix:' print >> out, '<br/>' col_labels = MAPP.g_property_names row_labels = MAPP.g_property_names table = correlation_matrix print >> out, HtmlTable.get_labeled_table_string( col_labels, row_labels, table) print >> out, '<br/><br/>' # show the pruned tree if fs.show_tree: tree_string = NewickIO.get_narrow_newick_string(pruned_tree, 80) lines = StringIO(tree_string).readlines() lines = [line.rstrip() for line in lines] print >> out, 'pruned phylogenetic tree in newick format:' print >> out, '<pre>' for line in lines: print >> out, cgi.escape(line) print >> out, '</pre>' print >> out, '<br/>' # show the weights if fs.show_weights: taxa, weights = zip(*taxon_weight_pairs) table = [weights] row_labels = ['weight'] col_labels = taxa print >> out, 'taxon weights:' print >> out, '<br/>' print >> out, HtmlTable.get_labeled_table_string( col_labels, row_labels, table) print >> out, '<br/><br/>' # estimate the amino acid distribution for the column, # taking into account the tree and a uniform prior. weights = [] aa_indices = [] for taxon, weight in taxon_weight_pairs: weights.append(weight) aa_indices.append(aa_letter_to_aa_index(taxon_to_aa_letter[taxon])) aa_distribution = MAPP.estimate_aa_distribution(weights, aa_indices) # show the estimated amino acid distribution if fs.show_aa_distribution: table = [aa_distribution] row_labels = ['weight'] col_labels = Codon.g_aa_letters print >> out, 'estimated amino acid distribution:' print >> out, '<br/>' print >> out, HtmlTable.get_labeled_table_string( col_labels, row_labels, table) print >> out, '<br/><br/>' # estimate the mean and variance of each physicochemical property est_pc_means = MAPP.estimate_property_means(standardized_property_array, aa_distribution) est_pc_variances = MAPP.estimate_property_variances( standardized_property_array, aa_distribution) # show the estimated mean and variance of each physicochemical property if fs.show_pc_distribution: table = [est_pc_means, est_pc_variances] row_labels = ['mean', 'variance'] col_labels = MAPP.g_property_names print >> out, 'estimated physicochemical property moments:' print >> out, '<br/>' print >> out, HtmlTable.get_labeled_table_string( col_labels, row_labels, table) print >> out, '<br/><br/>' # calculate the deviation from each property mean # for each possible amino acid deviations = MAPP.get_deviations(est_pc_means, est_pc_variances, standardized_property_array) # show the deviation from each property mean for each possible amino acid if fs.show_deviations: print >> out, 'deviations of amino acids from the normal distribution' print >> out, 'estimated for each property:' print >> out, '<br/>' col_labels = MAPP.g_property_names row_labels = Codon.g_aa_letters table = deviations print >> out, HtmlTable.get_labeled_table_string( col_labels, row_labels, table) print >> out, '<br/><br/>' # calculate the impact scores impact_scores = MAPP.get_impact_scores(correlation_matrix, deviations) # show the impact scores if fs.show_impact_scores: table = [impact_scores] row_labels = ['impact'] col_labels = Codon.g_aa_letters print >> out, 'impact scores:' print >> out, '<br/>' print >> out, HtmlTable.get_labeled_table_string( col_labels, row_labels, table) print >> out, '<br/><br/>' # calculate the p-values p_values = [] for score in impact_scores: ntaxa = len(taxon_weight_pairs) p_values.append(MAPP.get_p_value(score, ntaxa)) # show the p-values if fs.show_p_values: table = [p_values] row_labels = ['p-value'] col_labels = Codon.g_aa_letters print >> out, 'p-values:' print >> out, '<br/>' print >> out, HtmlTable.get_labeled_table_string( col_labels, row_labels, table) print >> out, '<br/><br/>' # write the html footer print >> out, '</body>' print >> out, '</html>' # return the response return out.getvalue()
def sendReport(resultList, allGood, testtype): if allGood: title = "ALL PASSED:" else: title = "SOMETHING WRONG:" if (testtype == "day"): title += "Everyday smoke test of CID for namespace: " title += config.cid_namespaces_asr[0] + "," + config.cid_namespaces_asr[ 1] + "," + config.cid_namespaces_tps[ 0] + " and " + config.cid_namespaces_tps[1] else: title += "Everyhour smoke test of CID for namespace: " title += config.cid_namespaces_asr[1] + "," + config.cid_namespaces_tps[ 0] + " and " + config.cid_namespaces_tps[1] #title += config.cid_namespaces_asr[0]+","+config.cid_namespaces_asr[1]+","+config.cid_namespaces_tps[0]+" and "+config.cid_namespaces_tps[1] #title += config.cid_namespaces_asr[1]+","+config.cid_namespaces_tps[0]+" and "+config.cid_namespaces_tps[1] dateTimeObj = datetime.now() timestampStr = dateTimeObj.strftime("%Y-%m-%d %H:%M:%S") html = report.formatTextH3("timestamp: " + helper.getLocalTime(timestampStr) + " " + "context:" + config.context) titleList, formats = titlesResults() html2 = htmlTable.table(titleList, formats, resultList, "cid smoke test results") html += "<br/><br/>" html += html2 html += "<br/><br/>" #html+= PodStatus(config.cid_namespaces_asr[0],config.cid_namespaces_asr[1]) if (testtype == "day"): html += PodStatus(config.cid_namespaces_asr[0], config.cid_namespaces_asr[1]) else: html += PodStatus(config.cid_namespaces_asr[1], None) html += "<br/><br/>" if (testtype == "day"): caption = "CPU Memory of namespace: " + config.cid_namespaces_asr[0] html1, pods_asr1 = cpuMem(config.cid_namespaces_asr[0], caption) html += html1 caption = "CPU Memory of namespace: " + config.cid_namespaces_asr[1] html1, pods_asr1 = cpuMem(config.cid_namespaces_asr[1], caption) html += html1 html += "<br/>" html += "<br/><br/>" if (testtype == "day"): html += PodStatus(config.cid_namespaces_tps[0], config.cid_namespaces_tps[1]) else: html += PodStatus(config.cid_namespaces_tps[1], None) html += "<br/>" if (testtype == "day"): caption = "CPU Memory of namespace: " + config.cid_namespaces_tps[0] html1, pods_tps1 = cpuMem(config.cid_namespaces_tps[0], caption) html += html1 html += "<br/>" caption = "CPU Memory of namespace: " + config.cid_namespaces_tps[1] html2, pods_tps2 = cpuMem(config.cid_namespaces_tps[1], caption) html += html2 attached_files = [] if checkContainerStatus(html): allGood = False title = "pod status is wrong;" + title html = replacePodStatus(html) if (testtype == "day"): '''indexImg=0 run_id='0000' podFilenames = granfanaImages(run_id, config.cid_namespaces_asr[1], pods_asr1) html3, indexImg, attached_files = tableGranfana(run_id, podFilenames, indexImg, attached_files) if(len(attached_files)>1): html+="<br/><br/>" html+=report.formatTextH3("Grafana images of namespace: "+config.cid_namespaces_asr[1]); html+=html3 #podFilenames = granfanaImages(run_id,config.cid_namespaces_asr[1],pods_asr2) #html4, indexImg, attached_files = tableGranfana(run_id, podFilenames, indexImg, attached_files) #html+="<br/>" #html+=report.formatTextH3("Grafana images of namespace: "+config.cid_namespaces_asr[1]); #html+=html4 ''' receivers = config.cid_email_receivers print(html) email.sendHtmlEmailReceivers(title, html, attached_files, receivers) else: if (allGood): receivers = config.cid_email_receivers_passed else: receivers = config.cid_email_receivers email.sendHtmlEmailReceivers(title, html, attached_files, receivers) for filename in attached_files: os.remove(filename) print(html) return html