From a03d88b742bb4be61b48d88a412060ec838a16f3 Mon Sep 17 00:00:00 2001 From: Matthew Foran <46829130+mjforan@users.noreply.github.com> Date: Tue, 24 May 2022 17:10:06 -0400 Subject: [PATCH] Bug fixes, better linux compatibility (#9) * removed package-lock.json from repo * added package-lock.json to .gitignore * fixed typo, linux compatbility * added quotes to url * check if attempt is None * reverted removing package-lock.json Co-authored-by: Matthew Foran --- export.py | 2 +- singlefile.py | 15 +++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/export.py b/export.py index 068afa4..68d4d16 100644 --- a/export.py +++ b/export.py @@ -473,7 +473,7 @@ def findCourseAssignments(course): hasattr(submission, "submission_comments") else "" # Attempt sub_view.attempt = submission.attempt if \ - hasattr(submission, "attempt") else 0 + hasattr(submission, "attempt") and submission.attempt is not None else 0 # User ID sub_view.user_id = str(submission.user_id) if \ hasattr(submission, "user_id") else "" diff --git a/singlefile.py b/singlefile.py index de1a3cd..dbc5a79 100644 --- a/singlefile.py +++ b/singlefile.py @@ -1,7 +1,7 @@ from subprocess import run -SINGLEFILE_BINARY_PATH = ".\\node_modules\\single-file\\cli\\single-file" -#CHROME_PATH = "C:\\Program Files\\Google\Chrome\\Application\\chrome.exe" #Uncomment this and set your browser exe if it can't find yours. +SINGLEFILE_BINARY_PATH = "./node_modules/single-file/cli/single-file" +CHROME_PATH = "C:/Program Files/Google\ Chrome/Application/chrome.exe" #Uncomment this and set your browser exe if it can't find yours. def addQuotes(str): return "\"" + str.strip("\"") + "\"" @@ -9,20 +9,19 @@ def addQuotes(str): def download_page(url, cookies_path, output_path, output_name_template = ""): args = [ addQuotes(SINGLEFILE_BINARY_PATH), - #"--browser-executeable-path=" + addQuotes(CHROME_PATH.strip("\"")), #Uncomment this and set your browser exe if it can't find yours. + #"--browser-executable-path=" + addQuotes(CHROME_PATH.strip("\"")), #Uncomment this and set your browser exe if it can't find yours. "--browser-cookies-file=" + addQuotes(cookies_path), "--output-directory=" + addQuotes(output_path), - url + addQuotes(url) ] if(output_name_template != ""): args.append("--filename-template=" + addQuotes(output_name_template)) try: - run("node " + " ".join(args)) + run("node " + " ".join(args), shell=True) except Exception as e: - print("Was not able to save the URL " + url + " using singlefile. The reported error was " + - e.strerror) + print("Was not able to save the URL " + url + " using singlefile. The reported error was " + e.strerror) #if __name__ == "__main__": - #download_page("https://www.google.com/", "", ".\\output\\test", "test.html") \ No newline at end of file + #download_page("https://www.google.com/", "", "./output/test", "test.html")