diff --git a/.gitignore b/.gitignore index 94c2a63..d76be37 100644 --- a/.gitignore +++ b/.gitignore @@ -24,6 +24,7 @@ sdist/ var/ wheels/ +.idea/ share/python-wheels/ *.egg-info/ .installed.cfg diff --git a/.idea/thu-learn-downloader.iml b/.idea/thu-learn-downloader.iml index 988d67c..19dc602 100644 --- a/.idea/thu-learn-downloader.iml +++ b/.idea/thu-learn-downloader.iml @@ -3,6 +3,8 @@ + + diff --git a/thu_learn_downloader/download/downloader.py b/thu_learn_downloader/download/downloader.py index c2c0675..9ca8b83 100644 --- a/thu_learn_downloader/download/downloader.py +++ b/thu_learn_downloader/download/downloader.py @@ -306,7 +306,7 @@ readme_path = Path(re.sub(r'[<>:"\\|?*\x00-\x1F]', '_', str(readme_path))) os.makedirs(readme_path.parent, exist_ok=True) - readme_path.write_text(homework.markdown) + # readme_path.write_text(homework.markdown) for attachment in homework.attachments: self.sync_file( client=homework.client, diff --git a/thu_learn_downloader/main.py b/thu_learn_downloader/main.py index 2e34c4d..147cb6d 100644 --- a/thu_learn_downloader/main.py +++ b/thu_learn_downloader/main.py @@ -1,3 +1,13 @@ +import os +# Determine the path for openssl.conf based on whether it's running from the executable or source code +config_path = os.path.join(os.path.dirname(__file__), 'openssl.conf') + +# Now you can use config_path to load the openssl.conf file +print(f"Config file path: {config_path}") +os.environ['OPENSSL_CONF'] = config_path +# this patch only works when directly run the project as module +# for using pyinstaller-built release exe, refer to hook.py + import urllib3 urllib3.disable_warnings() @@ -25,7 +35,7 @@ prefix: Annotated[Path, Option(file_okay=False, writable=True)] = Path.home() # noqa: B008 / "thu-learn", semesters: Annotated[list[str], Option("-s", "--semester")] = [ # noqa: B006 - "2023-2024-5" + "2024-2025-5" ], courses: Annotated[list[str], Option("-c", "--course")] = [], # noqa: B006 document: Annotated[bool, Option()] = True, @@ -35,9 +45,10 @@ log_level: Annotated[LogLevel, Option(envvar="LOG_LEVEL")] = LogLevel.INFO, ) -> None: logging.getLogger().setLevel(log_level) + username = username or login.username() or typer.prompt(text="Username") password = ( - password or login.password() or typer.prompt(text="Password", hide_input=True) + password or login.password() or typer.prompt(text="Password", hide_input=True) ) learn: Learn = Learn(language=language) learn.login(username=username, password=password)