mirror of
https://github.com/Garmelon/PFERD.git
synced 2026-04-12 15:35:05 +02:00
Add download summary
This commit is contained in:
parent
7024db1f13
commit
f6fbd5e4bb
4 changed files with 39 additions and 1 deletions
|
|
@ -24,6 +24,9 @@ class FileAcceptException(Exception):
|
|||
class Organizer(Location):
|
||||
"""A helper for managing downloaded files."""
|
||||
|
||||
new_files = []
|
||||
modified_files = []
|
||||
|
||||
def __init__(self, path: Path):
|
||||
"""Create a new organizer for a given path."""
|
||||
super().__init__(path)
|
||||
|
|
@ -69,8 +72,10 @@ class Organizer(Location):
|
|||
dst_absolute.touch()
|
||||
return
|
||||
|
||||
self.modified_files.append(dst_absolute)
|
||||
PRETTY.modified_file(dst_absolute)
|
||||
else:
|
||||
self.new_files.append(dst_absolute)
|
||||
PRETTY.new_file(dst_absolute)
|
||||
|
||||
# Create parent dir if needed
|
||||
|
|
|
|||
|
|
@ -34,6 +34,9 @@ class Pferd(Location):
|
|||
useful shortcuts for running synchronizers in a single interface.
|
||||
"""
|
||||
|
||||
new_files = []
|
||||
modified_files = []
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
base_dir: Path,
|
||||
|
|
@ -139,7 +142,8 @@ class Pferd(Location):
|
|||
# This authenticator only works with the KIT ilias instance.
|
||||
authenticator = KitShibbolethAuthenticator(username=username, password=password)
|
||||
PRETTY.starting_synchronizer(target, "ILIAS", course_id)
|
||||
return self._ilias(
|
||||
|
||||
organizer = self._ilias(
|
||||
target=target,
|
||||
base_url="https://ilias.studium.kit.edu/",
|
||||
crawl_function=lambda crawler: crawler.crawl_course(course_id),
|
||||
|
|
@ -151,6 +155,31 @@ class Pferd(Location):
|
|||
clean=clean,
|
||||
)
|
||||
|
||||
self.new_files += organizer.new_files
|
||||
self.modified_files += organizer.modified_files
|
||||
|
||||
return organizer
|
||||
|
||||
def print_summary(self):
|
||||
LOGGER.info("")
|
||||
LOGGER.info("Summary: ")
|
||||
if len(self.new_files) == 0 and len(self.modified_files) == 0:
|
||||
LOGGER.info("Nothing changed")
|
||||
|
||||
if len(self.new_files) > 0:
|
||||
LOGGER.info("New Files:")
|
||||
for file in self.new_files:
|
||||
PRETTY.new_file(file)
|
||||
|
||||
LOGGER.info("")
|
||||
|
||||
if len(self.modified_files) > 0:
|
||||
LOGGER.info("Modified Files:")
|
||||
for file in self.modified_files:
|
||||
PRETTY.modified_file(file)
|
||||
|
||||
LOGGER.info("")
|
||||
|
||||
@swallow_and_print_errors
|
||||
def ilias_kit_personal_desktop(
|
||||
self,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue