Fix ILIAS init.py and Pferd.py authenticators

This commit is contained in:
I-Al-Istannen 2020-12-05 23:35:20 +01:00
parent 83ea15ee83
commit f47b137b59
3 changed files with 13 additions and 6 deletions

View File

@ -2,8 +2,7 @@
Synchronizing files from ILIAS instances (https://www.ilias.de/). Synchronizing files from ILIAS instances (https://www.ilias.de/).
""" """
from .authenticators import (IliasAuthenticator, KitShibbolethAuthenticator, from .authenticators import IliasAuthenticator, KitShibbolethAuthenticator
KeyringKitShibbolethAuthenticator)
from .crawler import (IliasCrawler, IliasCrawlerEntry, IliasDirectoryFilter, from .crawler import (IliasCrawler, IliasCrawlerEntry, IliasDirectoryFilter,
IliasElementType) IliasElementType)
from .downloader import (IliasDownloader, IliasDownloadInfo, from .downloader import (IliasDownloader, IliasDownloadInfo,

View File

@ -6,6 +6,7 @@ import logging
from pathlib import Path from pathlib import Path
from typing import Callable, List, Optional, Union from typing import Callable, List, Optional, Union
from .authenticators import UserPassAuthenticator
from .cookie_jar import CookieJar from .cookie_jar import CookieJar
from .diva import (DivaDownloader, DivaDownloadStrategy, DivaPlaylistCrawler, from .diva import (DivaDownloader, DivaDownloadStrategy, DivaPlaylistCrawler,
diva_download_new) diva_download_new)
@ -64,6 +65,13 @@ class Pferd(Location):
for transformable in transformables: for transformable in transformables:
LOGGER.info(transformable.path) LOGGER.info(transformable.path)
@staticmethod
def _get_authenticator(
username: Optional[str], password: Optional[str]
) -> KitShibbolethAuthenticator:
inner_auth = UserPassAuthenticator("ILIAS - Pferd.py", username, password)
return KitShibbolethAuthenticator(inner_auth)
def _ilias( def _ilias(
self, self,
target: PathLike, target: PathLike,
@ -150,7 +158,7 @@ class Pferd(Location):
with overwriting or deleting files. The default always asks the user. with overwriting or deleting files. The default always asks the user.
""" """
# This authenticator only works with the KIT ilias instance. # This authenticator only works with the KIT ilias instance.
authenticator = KitShibbolethAuthenticator(username=username, password=password) authenticator = Pferd._get_authenticator(username=username, password=password)
PRETTY.starting_synchronizer(target, "ILIAS", course_id) PRETTY.starting_synchronizer(target, "ILIAS", course_id)
organizer = self._ilias( organizer = self._ilias(
@ -220,7 +228,7 @@ class Pferd(Location):
with overwriting or deleting files. The default always asks the user. with overwriting or deleting files. The default always asks the user.
""" """
# This authenticator only works with the KIT ilias instance. # This authenticator only works with the KIT ilias instance.
authenticator = KitShibbolethAuthenticator(username=username, password=password) authenticator = Pferd._get_authenticator(username, password)
PRETTY.starting_synchronizer(target, "ILIAS", "Personal Desktop") PRETTY.starting_synchronizer(target, "ILIAS", "Personal Desktop")
organizer = self._ilias( organizer = self._ilias(
@ -285,7 +293,7 @@ class Pferd(Location):
with overwriting or deleting files. The default always asks the user. with overwriting or deleting files. The default always asks the user.
""" """
# This authenticator only works with the KIT ilias instance. # This authenticator only works with the KIT ilias instance.
authenticator = KitShibbolethAuthenticator(username=username, password=password) authenticator = Pferd._get_authenticator(username=username, password=password)
PRETTY.starting_synchronizer(target, "ILIAS", "An ILIAS element by url") PRETTY.starting_synchronizer(target, "ILIAS", "An ILIAS element by url")
if not full_url.startswith("https://ilias.studium.kit.edu"): if not full_url.startswith("https://ilias.studium.kit.edu"):

View File

@ -3,5 +3,5 @@ disallow_untyped_defs = True
disallow_incomplete_defs = True disallow_incomplete_defs = True
no_implicit_optional = True no_implicit_optional = True
[mypy-rich.*,bs4] [mypy-rich.*,bs4,keyring]
ignore_missing_imports = True ignore_missing_imports = True