Skip to content

Commit 485849c

Browse files
0.10.1
Release 0.10.1
2 parents a1b66e9 + 937d7c3 commit 485849c

File tree

4 files changed

+38
-3
lines changed

4 files changed

+38
-3
lines changed

docs/changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
Versions follow [Semantic Versioning](https://semver.org/): `<major>.<minor>.<patch>`.
44

5+
## HardPy 0.10.1
6+
7+
* Fix **StandCloud** authorization process in Windows.
8+
59
## HardPy 0.10.0
610

711
* Add the `[stand_cloud]` section to the **hardpy.toml** configuration file.

hardpy/common/stand_cloud/registration.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
import socket
1313
import subprocess
1414
import sys
15+
from contextlib import suppress
16+
from platform import system
1517
from time import sleep
1618
from typing import TYPE_CHECKING
1719
from urllib.parse import urlencode
@@ -109,6 +111,12 @@ def logout() -> bool:
109111
delete_password(service_name, cred.username)
110112
except KeyringError:
111113
return False
114+
# TODO(xorialexandrov): fix keyring clearing
115+
# Windows does not clear refresh token by itself
116+
if system() == "Windows":
117+
storage_keyring, _ = get_token_store()
118+
with suppress(KeyringError):
119+
storage_keyring.delete_password(service_name, "refresh_token")
112120
return True
113121

114122

@@ -147,6 +155,18 @@ def _create_callback_process(port: str) -> subprocess.Popen:
147155
"--log-level=error",
148156
]
149157

158+
if system() == "Windows":
159+
env = os.environ.copy()
160+
env["PYTHONUNBUFFERED"] = "1"
161+
162+
return subprocess.Popen( # noqa: S603
163+
args,
164+
stdout=subprocess.PIPE,
165+
bufsize=1,
166+
universal_newlines=True,
167+
env=env,
168+
creationflags=subprocess.CREATE_NEW_PROCESS_GROUP, # type: ignore
169+
)
150170
return subprocess.Popen( # noqa: S603
151171
args,
152172
stdout=subprocess.PIPE,
@@ -187,7 +207,14 @@ def _check_incorrect_response(response: dict, state: str) -> None:
187207
print(f"{error}: {error_description}")
188208
sys.exit(1)
189209

190-
def _par_data(code_verifier: str, client_id: str, port: str, state: str, api_url: str) -> dict:
210+
211+
def _par_data(
212+
code_verifier: str,
213+
client_id: str,
214+
port: str,
215+
state: str,
216+
api_url: str,
217+
) -> dict:
191218
"""Create pushed authorization request data.
192219
193220
Returns:

hardpy/common/stand_cloud/token_storage.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# GNU General Public License v3.0 (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
33
from __future__ import annotations
44

5+
from platform import system
56
from typing import TYPE_CHECKING
67

78
from keyring.core import load_keyring
@@ -16,7 +17,10 @@ def get_token_store() -> tuple[KeyringBackend, KeyringBackend]:
1617
Returns:
1718
tuple[KeyringBackend, KeyringBackend]: token store
1819
"""
19-
storage_keyring = load_keyring("keyring.backends.SecretService.Keyring")
20+
if system() == "Linux":
21+
storage_keyring = load_keyring("keyring.backends.SecretService.Keyring")
22+
elif system() == "Windows":
23+
storage_keyring = load_keyring("keyring.backends.Windows.WinVaultKeyring")
2024
# TODO(xorialexandrov): add memory keyring or other store
2125
mem_keyring = storage_keyring
2226

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
[project]
55
name = "hardpy"
6-
version = "0.10.0"
6+
version = "0.10.1"
77
description = "HardPy library for device testing"
88
license = "GPL-3.0-or-later"
99
authors = [{ name = "Everypin", email = "info@everypin.io" }]

0 commit comments

Comments
 (0)