Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swallow keyring saving errors #909

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions .github/workflows/quality-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ jobs:
scripts/type_check

patch_version:
needs: skip_check
if: needs.skip_check.outputs.should_skip != 'true'
uses: ./.github/workflows/patch-version.yml

Expand Down Expand Up @@ -120,9 +121,9 @@ jobs:
matrix:
python-version: [3.12]
os:
# - "macos-12" # many are failing in keychain access
# - "macos-13" # many are failing in keychain access
# - "macos-14" # many are failing in keychain access
- "macos-12"
- "macos-13"
- "macos-14"
- "windows-2019"
- "windows-2022"
steps:
Expand Down Expand Up @@ -170,7 +171,7 @@ jobs:
icloudpd_version: ${{steps.get_version.outputs.icloudpd_version}}

extract_changelog:
needs: [get_version]
needs: [get_version, skip_check]
if: needs.skip_check.outputs.should_skip != 'true'
uses: ./.github/workflows/extract-changelog.yml
with:
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Unreleased

- feature: support for using locale from OS with `--use-os-locale` flag [#897](https://github.com/icloud-photos-downloader/icloud_photos_downloader/issues/897)
- fix: swallow keyring errors [#871](https://github.com/icloud-photos-downloader/icloud_photos_downloader/issues/871)

## 1.21.0 (2024-07-05)

Expand Down
20 changes: 19 additions & 1 deletion src/icloudpd/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,16 @@ def dummy_password_writter(_u: str, _p: str) -> None:
pass


def keyring_password_writter(logger: Logger) -> Callable[[str, str], None]:
def _intern(username: str, password: str) -> None:
try:
store_password_in_keyring(username, password)
except Exception:
logger.warning("Password was not saved to keyring")

return _intern


def password_provider_generator(
_ctx: click.Context, _param: click.Parameter, providers: Sequence[str]
) -> Dict[str, Tuple[Callable[[str], Optional[str]], Callable[[str, str], None]]]:
Expand All @@ -210,7 +220,7 @@ def _map(provider: str) -> Tuple[Callable[[str], Optional[str]], Callable[[str,
if provider == "console":
return (ask_password_in_console, dummy_password_writter)
elif provider == "keyring":
return (get_password_from_keyring, store_password_in_keyring)
return (get_password_from_keyring, dummy_password_writter)
elif provider == "parameter":
# TODO get from parameter
# _param: Optional[Parameter] = get_click_param_by_name("password", _ctx.command.params)
Expand Down Expand Up @@ -670,6 +680,14 @@ def main(
update_password_status_in_webui(status_exchange),
)

# hacky way to inject logger
if "keyring" in password_providers:
# replace
password_providers["keyring"] = (
get_password_from_keyring,
keyring_password_writter(logger),
)

# start web server
if mfa_provider == MFAProvider.WEBUI:
server_thread = Thread(target=serve_app, daemon=True, args=[logger, status_exchange])
Expand Down
Loading