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

added SCARD_E_NO_SERVICE to renewContext #154

Closed
wants to merge 5 commits into from

Conversation

mbokil
Copy link
Contributor

@mbokil mbokil commented Mar 27, 2023

Added SCARD_E_NO_SERVICE to renewContext. Added CardServiceNotFoundException exception. Worked for me on the latest Windows 10 catching both stop and no service to renew the context.

@coveralls
Copy link

Coverage Status

Coverage: 28.576% (-1.0e-05%) from 28.576% when pulling 43e40b9 on mbokil:master into b9bb295 on LudovicRousseau:master.

@@ -114,6 +116,10 @@ def readers(groups=[]):
hcontext = PCSCContext.renewContext()
pcsc_readers = __PCSCreaders__(hcontext, groups)

except CardServiceNotFoundException:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to handle the 2 exceptions at once with:

except (CardServiceStoppedException, CardServiceNotFoundException):

to factorize the code and avoid code duplication.

@@ -89,7 +89,7 @@ def getReaderNames(self):

# get inserted readers
hresult, pcscreaders = SCardListReaders(self.hcontext, [])
if SCARD_E_SERVICE_STOPPED == hresult:
if SCARD_E_SERVICE_STOPPED == hresult or SCARD_E_NO_SERVICE == hresult:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer the syntax I proposed:

        elif hresult in (SCARD_E_SERVICE_STOPPED, SCARD_E_NO_SERVICE):

to avoid the hresult repetition.

Copy link
Owner

@LudovicRousseau LudovicRousseau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice PR.
Can you please update it as suggested?

@mbokil
Copy link
Contributor Author

mbokil commented Mar 29, 2023

Ok I will make these changes and amend the pull request. thanks for reviewing.

change from review
change from review
@LudovicRousseau
Copy link
Owner

Thanks.
I merged your code with some rework of the commit messages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants