To receive notifications about scheduled maintenance, please subscribe to the mailing-list gitlab-operations@sympa.ethz.ch. You can subscribe to the mailing-list at https://sympa.ethz.ch

Commit ab6a6bd9 authored by scmalte's avatar scmalte
Browse files

revise.py, cluster.py: raise helpful exceptions in certain situations, log further output

parent a0885d1f
......@@ -123,7 +123,7 @@ def get_results_graph(results, percentage_threshold, lines_threshold):
return graph
def create_cluster_dot_and_svg_files(subgraph, index, cluster_dot_file, cluster_svg_file=None):
logging.debug(
logging.debug(
"Writing cluster {} with {}/{} nodes/edge to file {}".format(
index,
subgraph.number_of_nodes(),
......@@ -133,8 +133,12 @@ def create_cluster_dot_and_svg_files(subgraph, index, cluster_dot_file, cluster_
nx.drawing.nx_pydot.write_dot(subgraph, cluster_dot_file)
if cluster_svg_file:
dot_command = ["dot", "-Tsvg", "-o{}".format(cluster_svg_file), cluster_dot_file]
logging.debug("Calling dot to create SVG {} file from {}".format(cluster_svg_file, cluster_dot_file))
subprocess.run(["dot", "-Tsvg", "-o{}".format(cluster_svg_file), cluster_dot_file])
logging.debug("Command: {}".format(" ".join(dot_command)))
subprocess.run(dot_command)
def create_clusters(graph, cluster_file_pattern, create_svg_files):
logging.info("Computing connected component (CC) clusters")
......
......@@ -81,7 +81,8 @@ def localize_match_links(doc, input_report_subdir):
url_pattern = r"http://moss\.stanford\.edu/results/\d+/\d+/(match.*\.html)"
# E.g. ./12-345-678/main.cpp (77%)
text_pattern = r"\./([\d-]+)/.* (\(\d+%\))"
# ./some/dir/12-345-678/main.cpp (77%)
text_pattern = r".*?/([\d-]+)/.* (\(\d+%\))"
logging.info("Localising links to match files")
......@@ -92,14 +93,22 @@ def localize_match_links(doc, input_report_subdir):
for a in row.find_all("a"):
# Change remote URLs to local ones
url_match = re.search(url_pattern, a["href"])
if not url_match:
raise RuntimeError("Failure while localising match links in the Moss report. Failed to match link '{}' against regex '{}'".format(a["href"], url_pattern))
a["href"] = "./{}/{}".format(input_report_subdir, url_match.group(1))
# Open links in a new tab/window
a["target"] = "_blank"
# Strip away unnecessary link text
# print(a.get_text().strip())
text_match = re.search(text_pattern, a.get_text().strip())#.group(1)
link_text = a.get_text().strip()
text_match = re.search(text_pattern, link_text)
if not text_match:
raise RuntimeError("Failure while localising match links in the Moss report. Failed to match link text '{}' against regex '{}'".format(link_text, text_pattern))
a.string = "{} {}".format(text_match.group(1), text_match.group(2))
def get_match_percentage(match_text):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment