Skip to content

Commit 893190d

Browse files
committed
Updates to avoid using with VCProjectApi(ManageProject) as api:
1 parent 7ca7285 commit 893190d

File tree

3 files changed

+43
-62
lines changed

3 files changed

+43
-62
lines changed

src/main/resources/scripts/copy_build_dir.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,9 +237,9 @@ def run(ManageProjectName, Level, BaseName, Env, workspace, vCastProjectWorkspac
237237

238238
def getVcastProjectWorkspace(args):
239239

240-
with VCProjectApi(args.ManageProject) as vc_api:
241-
# vc_api = VCProjectApi(args.ManageProject)
242-
vCastProjectWorkspace = vc_api.project.workspace
240+
vc_api = VCProjectApi(args.ManageProject)
241+
vCastProjectWorkspace = vc_api.project.workspace
242+
vc_api.close()
243243

244244
return vCastProjectWorkspace
245245

src/main/resources/scripts/create_index_html.py

Lines changed: 27 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -55,19 +55,23 @@ def create_index_html(mpName):
5555
import pathlib
5656
from vector.apps.DataAPI.vcproject_api import VCProjectApi
5757
from vector.apps.ReportBuilder.custom_report import CustomReport
58-
with VCProjectApi(mpName) as api:
59-
# Set custom report directory to the where this script was
60-
# found. Must contain sections/index_section.py
61-
rep_path = pathlib.Path(__file__).parent.resolve()
62-
output_file="index.html"
63-
CustomReport.report_from_api(
64-
api=api,
65-
title="HTML Reports",
66-
report_type="INDEX_FILE",
67-
formats=["HTML"],
68-
output_file=output_file,
69-
sections=['CUSTOM_HEADER', 'REPORT_TITLE', 'TABLE_OF_CONTENTS','INDEX_SECTION', 'CUSTOM_FOOTER'],
70-
customization_dir=rep_path)
58+
59+
api = VCProjectApi(mpName)
60+
61+
# Set custom report directory to the where this script was
62+
# found. Must contain sections/index_section.py
63+
rep_path = pathlib.Path(__file__).parent.resolve()
64+
output_file="index.html"
65+
CustomReport.report_from_api(
66+
api=api,
67+
title="HTML Reports",
68+
report_type="INDEX_FILE",
69+
formats=["HTML"],
70+
output_file=output_file,
71+
sections=['CUSTOM_HEADER', 'REPORT_TITLE', 'TABLE_OF_CONTENTS','INDEX_SECTION', 'CUSTOM_FOOTER'],
72+
customization_dir=rep_path)
73+
74+
api.close()
7175

7276
def create_index_html_body ():
7377

@@ -105,52 +109,28 @@ def create_index_html_body ():
105109
return topLevelEntries, indEnvFullEntries, miscEntries
106110

107111

108-
def run(html_file_list):
112+
def run(mpName):
109113

110114
print("Creating index.html for VectorCAST Project Reports")
111115

112-
if len(html_file_list) > 0:
113-
create_index_html (html_file_list)
114-
115-
else:
116-
print("No HTML reports found")
117-
return 1
118-
119-
try:
120-
with open("index.html", 'w') as fd:
121-
fd.write(indexHtmlText)
122-
except:
123-
print("Unable to write to index.html")
124-
return 1
125-
116+
create_index_html (mpName)
117+
126118
return 0
127119

128120

129121
def main():
130-
parser = argparse.ArgumentParser()
131-
parser.add_argument("--html_base_dir", help='Set the base directory of the html_reports directory. The default is the workspace directory', default = "html_reports")
122+
parser = argparse.ArgumentParser()
123+
parser.add_argument('ManageProject', help='Manager Project Name')
132124
args = parser.parse_args()
133125

126+
127+
mpName = args.ManageProject
134128
try:
135129
prj_dir = os.environ['CI_PROJECT_DIR'].replace("\\","/") + "/"
136130
except:
137131
prj_dir = os.getcwd().replace("\\","/") + "/"
138-
139-
tempHtmlReportList = glob.glob("*.html")
140-
tempHtmlReportList += glob.glob(os.path.join(args.html_base_dir, "*.html"))
141-
htmlReportList = []
142-
143-
for report in tempHtmlReportList:
144-
if "index.html" not in report:
145-
report = report.replace("\\","/")
146-
report = report.replace(prj_dir,"")
147-
htmlReportList.append(report)
148-
149-
return run(htmlReportList)
132+
133+
return run(mpName)
150134

151135
if __name__ == "__main__" :
152-
if len(sys.argv) > 0:
153-
ret = create_custom_index_html()
154-
else:
155-
ret = main()
156-
sys.exit (ret)
136+
sys.exit (main())

src/main/resources/scripts/generate_pclp_reports.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -341,18 +341,19 @@ def generate_html_report(mpName, input_xml, output_html):
341341
if output_html is None:
342342
output_html = "pclp_findings.html"
343343

344-
with VCProjectApi(mpName) as api:
345-
# Set custom report directory to the where this script was
346-
# found. Must contain sections/index_section.py
347-
rep_path = pathlib.Path(__file__).parent.resolve()
348-
CustomReport.report_from_api(
349-
api=api,
350-
title="PC-Lint Plus Results",
351-
report_type="INDEX_FILE",
352-
formats=["HTML"],
353-
output_file=output_html,
354-
sections=['CUSTOM_HEADER', 'REPORT_TITLE', 'TABLE_OF_CONTENTS','PCLP_SUMMARY_SECTION','PCLP_DETAILS_SECTION','PCLP_SOURCE_SECTION', 'CUSTOM_FOOTER'],
355-
customization_dir=rep_path)
344+
api = VCProjectApi(mpName)
345+
# Set custom report directory to the where this script was
346+
# found. Must contain sections/index_section.py
347+
rep_path = pathlib.Path(__file__).parent.resolve()
348+
CustomReport.report_from_api(
349+
api=api,
350+
title="PC-Lint Plus Results",
351+
report_type="INDEX_FILE",
352+
formats=["HTML"],
353+
output_file=output_html,
354+
sections=['CUSTOM_HEADER', 'REPORT_TITLE', 'TABLE_OF_CONTENTS','PCLP_SUMMARY_SECTION','PCLP_DETAILS_SECTION','PCLP_SOURCE_SECTION', 'CUSTOM_FOOTER'],
355+
customization_dir=rep_path)
356+
api.close()
356357

357358
def has_any_coverage(line):
358359

0 commit comments

Comments
 (0)