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

Other cleanup #4

Closed
wants to merge 47 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
565db70
Remove support for Python releases older than 2.6
moreati Jun 19, 2015
ac3eb31
Consolidate build platform logic
moreati Jun 19, 2015
3bca937
Standardise Trove classifiers, declare OS & Python support
moreati Jun 19, 2015
119b0f2
Correct package declarations, include smartcard.pyro
moreati Jun 19, 2015
a72aa55
Switch from distutils to setuptools
moreati Jun 19, 2015
20c77ff
Add gitignore for build artefacts
moreati Jun 19, 2015
7d36645
Initial attempt at CI builds on Windows, using appveyor.com
moreati Jun 19, 2015
7b0005e
Missing comment
moreati Jun 19, 2015
88c556c
Download and install Swig in CI build
moreati Jun 19, 2015
1375471
Merge branch 'master' of github.com:moreati/pyscard
moreati Jun 20, 2015
af2c0e0
First attempt at Travis CI
moreati Jun 20, 2015
31241d9
Correct travis dependcy installation
moreati Jun 20, 2015
17feb6c
sudo helps when running apt-get
moreati Jun 20, 2015
cae9467
gitignore the config generated by the test suite
moreati Jun 22, 2015
370427c
Remove all but two uses of 'except:' & 'except Exception:'
moreati Jun 22, 2015
bedaf68
Commit convert docstring examples to doctest syntax
moreati Jun 22, 2015
7479bf1
Add default pylint config
moreati Jun 22, 2015
7b25b21
Customize pylintrc
moreati Jun 22, 2015
e1bba4b
Fix most major pylint errors and warnings
moreati Jun 22, 2015
173d961
Merge branch 'master' of github.com:LudovicRousseau/pyscard
moreati Jun 22, 2015
568d577
Consolidate Changelog, LICENSE, README etc into root dir. Delete PKG-…
moreati Jun 23, 2015
5c50b3f
Remove code supporting OS X Tiger
moreati Jun 23, 2015
fdadf6e
Reformat functions/attributes supported by `smartcard.scard` as tables
moreati Jun 23, 2015
2fb346a
Consolidate the project version in setup.py, bump to 1.7.0
moreati Jun 23, 2015
c6c442f
Merge branch 'master' of github.com:LudovicRousseau/pyscard
moreati Jun 26, 2015
2d0018b
Build Windows .exe and .msi installers
moreati Jun 28, 2015
4b639d3
README.md: Add a Continuous Integration status
LudovicRousseau Jun 26, 2015
86589a9
README.md: Add AppVeyor icon
LudovicRousseau Jun 26, 2015
907ffa2
README.md: Update travis-ci link
LudovicRousseau Jun 26, 2015
0897480
README.md: Correct Travis CI capitalisation
LudovicRousseau Jun 26, 2015
d0b7415
README.md: fix typo in Travis name
LudovicRousseau Jun 26, 2015
d552dba
configcheck.py: close file after use
LudovicRousseau Jun 27, 2015
734c8e6
Release 1.7.0
LudovicRousseau Jun 27, 2015
e30f9f8
ChangeLog: fix typos and reformat
LudovicRousseau Jun 27, 2015
cd82b30
setup.py: fix classifiers to conform to pypi
Jun 28, 2015
06a3a92
Remove support for Python releases older than 2.6
moreati Jun 19, 2015
7eee767
Consolidate build platform logic
moreati Jun 19, 2015
578da23
Standardise Trove classifiers, declare OS & Python support
moreati Jun 19, 2015
bb11fd6
Add gitignore for build artefacts
moreati Jun 19, 2015
4baa14d
Remove all but two uses of 'except:' & 'except Exception:'
moreati Jun 22, 2015
b64ec04
Fix most major pylint errors and warnings
moreati Jun 22, 2015
c9fa486
Merge branch 'master' of github.com:moreati/pyscard
moreati Jun 29, 2015
3e2f200
Revert differences to upstream@81bfc15
moreati Jun 29, 2015
b01c51d
Fix undefined variable errors found by pylint
moreati Jun 29, 2015
68f5f42
Fix missing usage of raw string
moreati Jun 29, 2015
b0f49f6
Remove no-effect loop
moreati Jun 29, 2015
9ec8fae
Fix name clash between PyroDaemonThread and threading.Thread
moreati Jun 29, 2015
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
Prev Previous commit
Next Next commit
Remove all but two uses of 'except:' & 'except Exception:'
The remaining instance will now print a full traceback. This should
improve on with https://sourceforge.net/p/pyscard/bugs/8/, or at least
make it easier to solve
  • Loading branch information
moreati committed Jun 29, 2015
commit 4baa14d7182dde572ffd68ee4db69bb4fb16711f
12 changes: 3 additions & 9 deletions smartcard/CardMonitoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
"""

from sys import exc_info
from threading import Thread, Event
from time import sleep
import traceback

from smartcard.System import readers
from smartcard.Exceptions import CardRequestTimeoutException
Expand Down Expand Up @@ -186,15 +186,9 @@ def run(self):
pass
except AttributeError:
pass

except:
try:
import sys
print sys.exc_info()[1]
print sys.exc_info()[2]
print sys.exc_info()[0]
except:
pass
# FIXME Tighten the exceptions caught by this block
traceback.print_exc()

# stop the thread by signaling stopEvent
def stop(self):
Expand Down
8 changes: 2 additions & 6 deletions smartcard/Examples/framework/sample_MonitorCards.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
"""

from sys import stdin, exc_info
import sys
from time import sleep

from smartcard.CardMonitoring import CardMonitor, CardObserver
Expand All @@ -44,7 +44,7 @@ def update(self, observable, (addedcards, removedcards)):
for card in removedcards:
print "-Removed: ", toHexString(card.atr)

try:
if __name__ == '__main__':
print "Insert or remove a smartcard in the system."
print "This program will exit in 10 seconds"
print ""
Expand All @@ -58,10 +58,6 @@ def update(self, observable, (addedcards, removedcards)):
# monitor will poll forever...
cardmonitor.deleteObserver(cardobserver)

import sys
if 'win32' == sys.platform:
print 'press Enter to continue'
sys.stdin.read(1)

except:
print exc_info()[0], ':', exc_info()[1]
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
"""

from sys import stdin, exc_info
import sys
from time import sleep

from smartcard.CardConnectionObserver import ConsoleCardConnectionObserver
Expand Down Expand Up @@ -63,7 +63,7 @@ def update(self, observable, (addedcards, removedcards)):
for card in removedcards:
print "-Removed: ", toHexString(card.atr)

try:
if __name__ == '__main__':
print "Insert or remove a SIM card in the system."
print "This program will exit in 60 seconds"
print ""
Expand All @@ -77,10 +77,6 @@ def update(self, observable, (addedcards, removedcards)):
# monitor will poll forever...
cardmonitor.deleteObserver(selectobserver)

import sys
if 'win32' == sys.platform:
print 'press Enter to continue'
sys.stdin.read(1)

except:
print exc_info()[0], ':', exc_info()[1]
8 changes: 2 additions & 6 deletions smartcard/Examples/framework/sample_MonitorReaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
"""

from sys import stdin, exc_info
import sys
from time import sleep

from smartcard.ReaderMonitoring import ReaderMonitor, ReaderObserver
Expand All @@ -40,7 +40,7 @@ def update(self, observable, (addedreaders, removedreaders)):
print "Added readers", addedreaders
print "Removed readers", removedreaders

try:
if __name__ == '__main__':
print "Add or remove a smartcard reader to the system."
print "This program will exit in 10 seconds"
print ""
Expand All @@ -54,10 +54,6 @@ def update(self, observable, (addedreaders, removedreaders)):
# monitor will poll forever...
readermonitor.deleteObserver(readerobserver)

import sys
if 'win32' == sys.platform:
print 'press Enter to continue'
sys.stdin.read(1)

except:
print exc_info()[0], ':', exc_info()[1]
6 changes: 1 addition & 5 deletions smartcard/Examples/framework/sample_TransmitCardObserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
along with pyscard; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
"""
from sys import stdin, exc_info
from time import sleep

from smartcard.CardMonitoring import CardMonitor, CardObserver
Expand Down Expand Up @@ -57,7 +56,7 @@ def update(self, observable, (addedcards, removedcards)):
if card in self.cards:
self.cards.remove(card)

try:
if __name__ == '__main__':
print "Insert or remove a smartcard in the system."
print "This program will exit in 100 seconds"
print ""
Expand All @@ -66,6 +65,3 @@ def update(self, observable, (addedcards, removedcards)):
cardmonitor.addObserver(cardobserver)

sleep(100)

except:
print exc_info()[0], ':', exc_info()[1]
14 changes: 6 additions & 8 deletions smartcard/Examples/scard-api/sample_getATR.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
"""

import sys

from smartcard.scard import *
import smartcard.util

try:
if __name__ == '__main__':
hresult, hcontext = SCardEstablishContext(SCARD_SCOPE_USER)
if hresult != SCARD_S_SUCCESS:
raise error(
Expand Down Expand Up @@ -86,10 +88,6 @@
SCardGetErrorMessage(hresult))
print 'Released context.'

except Exception, e:
print e

import sys
if 'win32' == sys.platform:
print 'press Enter to continue'
sys.stdin.read(1)
if 'win32' == sys.platform:
print 'press Enter to continue'
sys.stdin.read(1)
14 changes: 6 additions & 8 deletions smartcard/Examples/scard-api/sample_getAttrib.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
"""

import struct
import sys

from smartcard.scard import *
import smartcard.util

Expand Down Expand Up @@ -90,7 +92,7 @@ def printAttribute(attrib, value):
print apply(struct.pack, ['<' + 'B' * len(value)] + value)


try:
if __name__ == '__main__':
hresult, hcontext = SCardEstablishContext(SCARD_SCOPE_USER)
if hresult != SCARD_S_SUCCESS:
raise error(
Expand Down Expand Up @@ -149,10 +151,6 @@ def printAttribute(attrib, value):
SCardGetErrorMessage(hresult))
print 'Released context.'

except Exception, e:
print e

import sys
if 'win32' == sys.platform:
print 'press Enter to continue'
sys.stdin.read(1)
if 'win32' == sys.platform:
print 'press Enter to continue'
sys.stdin.read(1)
20 changes: 10 additions & 10 deletions smartcard/Examples/scard-api/sample_listInterfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
"""

import sys

import platform
from smartcard.scard import *
import smartcard.guid
Expand All @@ -42,7 +44,7 @@
znewcardSecGuid = \
smartcard.guid.strToGUID('{EB7F69EA-BA20-47d0-8C50-11CFDEB63BBE}')

try:
def main():
hresult, hcontext = SCardEstablishContext(SCARD_SCOPE_USER)
if hresult != SCARD_S_SUCCESS:
raise scard.error(
Expand Down Expand Up @@ -108,15 +110,13 @@
SCardGetErrorMessage(hresult))
print 'Released context.'

except error:
import sys
print sys.exc_info()[0], ':', sys.exc_info()[1]

elif 'pcsclite' == resourceManager:
print 'SCardListInterfaces not supported by pcsc lite'
def main():
print 'SCardListInterfaces not supported by pcsc lite'


import sys
if 'win32' == sys.platform:
print 'press Enter to continue'
sys.stdin.read(1)
if __name__ == '__main__':
main()
if 'win32' == sys.platform:
print 'press Enter to continue'
sys.stdin.read(1)
4 changes: 0 additions & 4 deletions smartcard/Examples/simple/selectDF_TELECOM.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,6 @@
except CardRequestTimeoutException:
print 'time-out: no card inserted during last 10s'

except:
import sys
print sys.exc_info()[1]

import sys
if 'win32' == sys.platform:
print 'press Enter to continue'
Expand Down
5 changes: 1 addition & 4 deletions smartcard/Examples/simple/simpleAPDU.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
0x18, 0xFF]
GET_TIME = [0x80, 0x38, 0x00, 0xA0]

try:
if __name__ == '__main__':
# get all the available readers
r = readers()
print "Available readers: ", r
Expand All @@ -51,6 +51,3 @@

data, sw1, sw2 = connection.transmit(GET_TIME)
print "Get Time: %02X %02X" % (sw1, sw2)

except:
print sys.exc_info()[1]
2 changes: 1 addition & 1 deletion smartcard/Examples/wx/pcscdiag/pcscdiag.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
# wxPython GUI modules (http:https://www.wxpython.org)
try:
import wx
except:
except ImportError:
print 'You need wxpython (http:https://www.wxpython.org) ' + \
'to run this sample from the source code!'
print 'press a key to continue'
Expand Down
4 changes: 3 additions & 1 deletion smartcard/ReaderMonitoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
"""

from sys import exc_info
from threading import Thread, Event, enumerate
from time import sleep
import traceback

import smartcard.System
from smartcard.Exceptions import ListReadersException
Expand Down Expand Up @@ -183,6 +183,8 @@ def run(self):
self.stopEvent.wait(self.period)

except Exception, e:
# FIXME Tighten the exceptions caught by this block
traceback.print_exc()
# Most likely raised during interpreter shutdown due
# to unclean exit which failed to remove all observers.
# To solve this, we set the stop event and pass the
Expand Down
10 changes: 3 additions & 7 deletions smartcard/System.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,6 @@ def listReaders():


if __name__ == '__main__':
try:
print readers()
print readers(['SCard$DefaultReaders'])
print readergroups()
except:
import sys
print sys.exc_info()[1]
print readers()
print readers(['SCard$DefaultReaders'])
print readergroups()
43 changes: 19 additions & 24 deletions smartcard/doc/user-guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1199,30 +1199,26 @@ To monitor reader insertion/removal, simply add the observer to the

.. sourcecode:: python

from sys import stdin, exc_info
from sys import stdin
from time import sleep

from smartcard.ReaderMonitoring import ReaderMonitor, ReaderObserver

try:
print "Add or remove a smartcard reader to the system."
print "This program will exit in 10 seconds"
print ""
readermonitor = ReaderMonitor()
readerobserver = printobserver()
readermonitor.addObserver( readerobserver )

sleep(10)
print "Add or remove a smartcard reader to the system."
print "This program will exit in 10 seconds"
print ""
readermonitor = ReaderMonitor()
readerobserver = printobserver()
readermonitor.addObserver( readerobserver )

# don't forget to remove observer, or the
# monitor will poll forever...
readermonitor.deleteObserver(readerobserver)
sleep(10)

print 'press Enter to continue'
stdin.readline()
# don't forget to remove observer, or the
# monitor will poll forever...
readermonitor.deleteObserver(readerobserver)

except error:
print exc_info()[0], ': ', exc_info()[1]
print 'press Enter to continue'
stdin.readline()

Smart Cards
***********
Expand Down Expand Up @@ -1261,13 +1257,12 @@ card observer to the `CardMonitor
for card in removedcards:
print "-Removed: ", toHexString( card.atr )

try:
print "Insert or remove a smartcard in the system."
print "This program will exit in 10 seconds"
print ""
cardmonitor = CardMonitor()
cardobserver = printobserver()
cardmonitor.addObserver( cardobserver )
print "Insert or remove a smartcard in the system."
print "This program will exit in 10 seconds"
print ""
cardmonitor = CardMonitor()
cardobserver = printobserver()
cardmonitor.addObserver( cardobserver )


Sending APDUs to a Smart Card Obtained from Card Monitoring
Expand Down
2 changes: 1 addition & 1 deletion smartcard/pyro/server/RemoteReaderServer.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
try:
import Pyro.core
import Pyro.naming
except:
except ImportError:
print 'You need pyro (python remote objects) ' + \
'at http:https://www.xs4all.nl/~irmen/pyro3/'
import sys
Expand Down
7 changes: 3 additions & 4 deletions smartcard/scard/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
try:
from scard import *
except:
from smartcard.scard._scard import *
from __future__ import absolute_import

from smartcard.scard.scard import *
Loading