Skip to content

Commit e6d0547

Browse files
committed
Fix report handling in rsfc
1 parent 442eec5 commit e6d0547

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/resqui/plugins/rsfc.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import json
22
import tempfile
33
import os
4+
import shutil
45

56
from resqui.plugins.base import IndicatorPlugin
67
from resqui.executors import DockerExecutor
@@ -42,7 +43,7 @@ def execute(self, url, commit_hash):
4243

4344
tempdir = tempfile.mkdtemp()
4445

45-
url = url[:-4] if url.endswith(".git") else url
46+
url = url.removesuffix(".git")
4647

4748
run_args = [
4849
"--rm",
@@ -52,15 +53,18 @@ def execute(self, url, commit_hash):
5253

5354
_ = self.executor.run(["--repo", url], run_args=run_args)
5455

55-
files = os.listdir(tempdir)
56-
if len(files) < 1:
57-
print("Error: RSFC did not generate any output files")
58-
raise
56+
assessment_filename = "rsfc_assessment.json"
57+
assessment_fpath = os.path.join(tempdir, assessment_filename)
58+
if not os.path.isfile(os.path.join(tempdir, assessment_filename)):
59+
raise FileNotFoundError(
60+
f"Error: RSFC did not generate the expected assessment file named '{assessment_filename}'"
61+
)
5962

60-
report_path = os.path.join(tempdir, files[0])
61-
with open(report_path) as f:
63+
with open(assessment_fpath) as f:
6264
report = json.load(f)
6365

66+
shutil.rmtree(tempdir)
67+
6468
self._cache[cache_key] = report
6569

6670
return report
@@ -163,7 +167,6 @@ def has_releases(self, url, branch_hash_or_tag):
163167

164168
def software_has_license(self, url, branch_hash_or_tag):
165169
report = self.execute(url, branch_hash_or_tag)
166-
print(report)
167170
checks = report["checks"]
168171
check_list = []
169172

0 commit comments

Comments
 (0)