Skip to content

Commit

Permalink
qml: auth.py formatting, imports
Browse files Browse the repository at this point in the history
  • Loading branch information
accumulator committed May 12, 2023
1 parent 777d32e commit b2a985d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions electrum/gui/qml/auth.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from functools import wraps, partial

from PyQt5.QtCore import pyqtSignal, pyqtSlot, pyqtProperty
from PyQt5.QtCore import pyqtSignal, pyqtSlot

from electrum.logging import get_logger


def auth_protect(func=None, reject=None, method='pin', message=''):
if func is None:
return partial(auth_protect, reject=reject, method=method, message=message)
Expand All @@ -20,6 +21,7 @@ def wrapper(self, *args, **kwargs):

return wrapper


class AuthMixin:
_auth_logger = get_logger(__name__)
authRequired = pyqtSignal([str, str], arguments=['method', 'authMessage'])
Expand All @@ -30,7 +32,7 @@ def authProceed(self, password=None):
self._auth_logger.debug('Proceeding with authed fn()')
try:
self._auth_logger.debug(str(getattr(self, '__auth_fcall')))
(func,args,kwargs,reject) = getattr(self, '__auth_fcall')
(func, args, kwargs, reject) = getattr(self, '__auth_fcall')
if password and 'password' in func.__code__.co_varnames:
r = func(self, *args, **dict(kwargs, password=password))
else:
Expand All @@ -40,7 +42,7 @@ def authProceed(self, password=None):
self._auth_logger.error(f'Error executing wrapped fn(): {repr(e)}')
raise e
finally:
delattr(self,'__auth_fcall')
delattr(self, '__auth_fcall')

@pyqtSlot()
def authCancel(self):
Expand All @@ -49,7 +51,7 @@ def authCancel(self):
return

try:
(func,args,kwargs,reject) = getattr(self, '__auth_fcall')
(func, args, kwargs, reject) = getattr(self, '__auth_fcall')
if reject is not None:
if hasattr(self, reject):
getattr(self, reject)()
Expand Down

0 comments on commit b2a985d

Please sign in to comment.