Skip to content

Commit 64a913f

Browse files
fix log and progress bar (#664)
1 parent e6482c6 commit 64a913f

11 files changed

+246
-231
lines changed

src/icloudpd/authentication.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"""Handles username/password authentication and two-step authentication"""
22

3-
import logging
43
import sys
54
import click
65
import pyicloud_ipd
@@ -23,7 +22,7 @@ def authenticate_(
2322
client_id=None,
2423
):
2524
"""Authenticate with iCloud username and password"""
26-
logger.tqdm_write("Authenticating...", logging.DEBUG)
25+
logger.debug("Authenticating...")
2726
while True:
2827
try:
2928
# If password not provided on command line variable will be set to None
@@ -42,9 +41,9 @@ def authenticate_(
4241
if icloud.requires_2sa:
4342
if raise_error_on_2sa:
4443
raise TwoStepAuthRequiredError(
45-
"Two-step/two-factor authentication is required!"
44+
"Two-step/two-factor authentication is required"
4645
)
47-
logger.info("Two-step/two-factor authentication is required!")
46+
logger.info("Two-step/two-factor authentication is required")
4847
request_2sa(icloud, logger)
4948
return icloud
5049
return authenticate_

src/icloudpd/autodelete.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,19 @@
22
Delete any files found in "Recently Deleted"
33
"""
44
import os
5-
import logging
65
from tzlocal import get_localzone
76
from icloudpd.paths import local_download_path
87

98

109
def delete_file(logger, path) -> bool:
1110
""" Actual deletion of files """
1211
os.remove(path)
13-
logger.tqdm_write(f"Deleted {path}", logging.INFO)
12+
logger.info("Deleted %s", path)
1413
return True
1514

1615
def delete_file_dry_run(logger, path) -> bool:
1716
""" Dry run deletion of files """
18-
logger.tqdm_write(f"[DRY RUN] Would delete {path}", logging.INFO)
17+
logger.info("[DRY RUN] Would delete %s", path)
1918
return True
2019

2120
def autodelete_photos(logger, dry_run, icloud, folder_structure, directory):
@@ -24,17 +23,17 @@ def autodelete_photos(logger, dry_run, icloud, folder_structure, directory):
2423
from the download directory.
2524
(I.e. If you delete a photo on your phone, it's also deleted on your computer.)
2625
"""
27-
logger.tqdm_write("Deleting any files found in 'Recently Deleted'...", logging.INFO)
26+
logger.info("Deleting any files found in 'Recently Deleted'...")
2827

2928
recently_deleted = icloud.photos.albums["Recently Deleted"]
3029

3130
for media in recently_deleted:
3231
try:
3332
created_date = media.created.astimezone(get_localzone())
3433
except (ValueError, OSError):
35-
logger.tqdm_write(
36-
f"Could not convert media created date to local timezone {media.created}",
37-
logging.ERROR)
34+
logger.error(
35+
"Could not convert media created date to local timezone %s",
36+
media.created)
3837
created_date = media.created
3938

4039
date_path = folder_structure.format(created_date)
@@ -45,6 +44,6 @@ def autodelete_photos(logger, dry_run, icloud, folder_structure, directory):
4544
local_download_path(
4645
media, size, download_dir))
4746
if os.path.exists(path):
48-
logger.tqdm_write(f"Deleting {path}...", logging.DEBUG)
47+
logger.debug("Deleting %s...", path)
4948
delete_local = delete_file_dry_run if dry_run else delete_file
5049
delete_local(logger, path)

0 commit comments

Comments
 (0)