From ffee6483d2dee8bcf09f490d8f5eb92155b27976 Mon Sep 17 00:00:00 2001 From: Allen Golbig Date: Wed, 13 Jul 2022 18:03:37 -0400 Subject: [PATCH] added ruby gem changes --- .gitignore | 5 ++++- scripts/generate_guidance.py | 23 ++++++++++++++++++++--- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index daab1a74..254d3ed7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ .DS_Store .vscode -*.lock \ No newline at end of file +*.lock +.bundle +bin +mscp_gems diff --git a/scripts/generate_guidance.py b/scripts/generate_guidance.py index a8a83c50..c1c6271f 100755 --- a/scripts/generate_guidance.py +++ b/scripts/generate_guidance.py @@ -1415,6 +1415,7 @@ def create_args(): help="sign the configuration profiles with subject key ID (hash value without spaces)") return parser.parse_args() + def is_asciidoctor_installed(): """Checks to see if the ruby gem for asciidoctor is installed """ @@ -1928,10 +1929,21 @@ def main(): cmd = f"{asciidoctor_path} \'{adoc_output_file.name}\'" process = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True) process.communicate() + elif os.path.exists('../bin/asciidoctor'): + print('Generating HTML file from AsciiDoc...') + cmd = f"'../bin/asciidoctor' \'{adoc_output_file.name}\'" + process = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True) + process.communicate() + elif not os.path.exists('../bin/asciidoctor'): + print('Installing gem requirements - asciidoctor, asciidoctor-pdf, and rouge...') + cmd = ['/usr/bin/bundle', 'install', '--gemfile', '../Gemfile', '--binstubs', '--path', 'mscp_gems'] + subprocess.run(cmd) + print('Generating HTML file from AsciiDoc...') + cmd = f"'../bin/asciidoctor' \'{adoc_output_file.name}\'" + process = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True) + process.communicate() else: - print("If you would like to generate the HTML file from the AsciiDoc file, install the ruby gem for asciidoctor") - - asciidoctorPDF_path = is_asciidoctor_pdf_installed() + print("If you would like to generate the PDF file from the AsciiDoc file, install the ruby gem for asciidoctor") # Don't create PDF if we are generating SCAP if not args.gary: @@ -1941,6 +1953,11 @@ def main(): cmd = f"{asciidoctorPDF_path} \'{adoc_output_file.name}\'" process = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True) process.communicate() + elif os.path.exists('../bin/asciidoctor-pdf'): + print('Generating PDF file from AsciiDoc...') + cmd = f"'../bin/asciidoctor-pdf' \'{adoc_output_file.name}\'" + process = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True) + process.communicate() else: print("If you would like to generate the PDF file from the AsciiDoc file, install the ruby gem for asciidoctor-pdf")