diff --git a/smartcard/Card.py b/smartcard/Card.py index b82fad52..a261c744 100644 --- a/smartcard/Card.py +++ b/smartcard/Card.py @@ -21,7 +21,6 @@ along with pyscard; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA """ -from smartcard.Exceptions import CardConnectionException, NoCardException from smartcard.reader.Reader import Reader from smartcard.System import readers from smartcard.util import toHexString diff --git a/smartcard/CardConnection.py b/smartcard/CardConnection.py index 607185e0..15bb52b2 100644 --- a/smartcard/CardConnection.py +++ b/smartcard/CardConnection.py @@ -24,8 +24,6 @@ """ from smartcard.CardConnectionEvent import CardConnectionEvent -from smartcard.Exceptions import SmartcardException -from smartcard.Observer import Observer from smartcard.Observer import Observable diff --git a/smartcard/CardMonitoring.py b/smartcard/CardMonitoring.py index f3041044..5624456d 100644 --- a/smartcard/CardMonitoring.py +++ b/smartcard/CardMonitoring.py @@ -33,12 +33,9 @@ from time import sleep import traceback -from smartcard.System import readers -from smartcard.Exceptions import CardRequestTimeoutException from smartcard.Observer import Observer from smartcard.Observer import Observable -from smartcard.CardType import AnyCardType from smartcard.CardRequest import CardRequest _START_ON_DEMAND_ = False @@ -219,7 +216,6 @@ def __getattr__(self, name): if __name__ == "__main__": - from smartcard.CardMonitoring import CardMonitor print('insert or remove cards in the next 10 seconds') # a simple card observer that prints added/removed cards diff --git a/smartcard/CardService.py b/smartcard/CardService.py index 36ead64c..feaac9e3 100644 --- a/smartcard/CardService.py +++ b/smartcard/CardService.py @@ -31,7 +31,6 @@ """ from __future__ import print_function -from smartcard.Exceptions import SmartcardException from smartcard.scard import * diff --git a/smartcard/CardType.py b/smartcard/CardType.py index 5b17e2bb..a9d6cdff 100644 --- a/smartcard/CardType.py +++ b/smartcard/CardType.py @@ -22,6 +22,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA """ from __future__ import print_function +from smartcard.Exceptions import InvalidATRMaskLengthException from smartcard.System import readers from smartcard.util import toHexString diff --git a/smartcard/ClassLoader.py b/smartcard/ClassLoader.py index 3b232152..3cc59c56 100644 --- a/smartcard/ClassLoader.py +++ b/smartcard/ClassLoader.py @@ -9,10 +9,6 @@ License: PSF license (http://docs.python.org/license.html). """ -import sys -import types - - def get_mod(modulePath): """Import a module.""" return __import__(modulePath, globals(), locals(), ['']) diff --git a/smartcard/Examples/wx/pcscdiag/pcscdiag.py b/smartcard/Examples/wx/pcscdiag/pcscdiag.py index 697cfd30..7a1dbda0 100755 --- a/smartcard/Examples/wx/pcscdiag/pcscdiag.py +++ b/smartcard/Examples/wx/pcscdiag/pcscdiag.py @@ -35,7 +35,7 @@ # wxPython GUI modules (http://www.wxpython.org) try: import wx -except: +except ImportError: print('You need wxpython (http://www.wxpython.org) ' + \ 'to run this sample from the source code!') print('press a key to continue') diff --git a/smartcard/ExclusiveConnectCardConnection.py b/smartcard/ExclusiveConnectCardConnection.py index 20fcdb1d..7616e895 100644 --- a/smartcard/ExclusiveConnectCardConnection.py +++ b/smartcard/ExclusiveConnectCardConnection.py @@ -22,7 +22,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA """ from __future__ import print_function -from smartcard.CardConnection import CardConnection from smartcard.CardConnectionDecorator import CardConnectionDecorator from smartcard.Exceptions import CardConnectionException from smartcard.scard import SCardConnect, SCardDisconnect diff --git a/smartcard/ExclusiveTransmitCardConnection.py b/smartcard/ExclusiveTransmitCardConnection.py index e022290e..1d5b2292 100644 --- a/smartcard/ExclusiveTransmitCardConnection.py +++ b/smartcard/ExclusiveTransmitCardConnection.py @@ -22,13 +22,11 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA """ from __future__ import print_function -from smartcard.CardConnection import CardConnection from smartcard.CardConnectionDecorator import CardConnectionDecorator from smartcard.Exceptions import CardConnectionException from smartcard.scard import SCardBeginTransaction, SCardEndTransaction from smartcard.scard import SCARD_LEAVE_CARD from smartcard.scard import SCardGetErrorMessage -from smartcard.pcsc import PCSCCardConnection import smartcard.pcsc diff --git a/smartcard/PassThruCardService.py b/smartcard/PassThruCardService.py index 039d63c4..d7b99948 100644 --- a/smartcard/PassThruCardService.py +++ b/smartcard/PassThruCardService.py @@ -54,7 +54,6 @@ def supports(cardname): SELECT = [0xA0, 0xA4, 0x00, 0x00, 0x02] DF_TELECOM = [0x7F, 0x10] from smartcard.System import readers - from smartcard.CardConnection import CardConnection cc = readers()[0].createConnection() cs = PassThruCardService(cc) cs.connection.connect() diff --git a/smartcard/ReaderMonitoring.py b/smartcard/ReaderMonitoring.py index 10ec1a2a..ac3f5ba4 100644 --- a/smartcard/ReaderMonitoring.py +++ b/smartcard/ReaderMonitoring.py @@ -29,12 +29,11 @@ """ from __future__ import print_function -from threading import Thread, Event, enumerate +from threading import Thread, Event from time import sleep import traceback import smartcard.System -from smartcard.Exceptions import ListReadersException from smartcard.Observer import Observer from smartcard.Observer import Observable from smartcard.Synchronization import * @@ -204,7 +203,6 @@ def stop(self): self.join() if __name__ == "__main__": - from smartcard.ReaderMonitoring import ReaderMonitor print('insert or remove readers in the next 20 seconds') # a simple reader observer that prints added/removed readers diff --git a/smartcard/Session.py b/smartcard/Session.py index e67a3e9c..940b10cd 100644 --- a/smartcard/Session.py +++ b/smartcard/Session.py @@ -25,7 +25,6 @@ from __future__ import print_function from smartcard.Exceptions import InvalidReaderException, NoReadersException -from smartcard.CardConnection import CardConnection from smartcard.PassThruCardService import PassThruCardService from smartcard.System import readers diff --git a/smartcard/pcsc/PCSCCardConnection.py b/smartcard/pcsc/PCSCCardConnection.py index cccc4d35..a3bd7a05 100644 --- a/smartcard/pcsc/PCSCCardConnection.py +++ b/smartcard/pcsc/PCSCCardConnection.py @@ -26,7 +26,6 @@ from smartcard.CardConnection import CardConnection from smartcard.Exceptions import (CardConnectionException, NoCardException, SmartcardException) -from smartcard.Observer import Observable from smartcard.scard import * diff --git a/smartcard/pyro/PyroReader.py b/smartcard/pyro/PyroReader.py index bbf1bf64..35e0c11f 100644 --- a/smartcard/pyro/PyroReader.py +++ b/smartcard/pyro/PyroReader.py @@ -26,9 +26,8 @@ import Pyro.core import Pyro.naming -from smartcard.Exceptions import CardConnectionException, NoCardException +from smartcard.Exceptions import NoCardException from smartcard.reader.Reader import Reader -from smartcard.reader.ReaderFactory import ReaderFactory class PyroReader(Reader): diff --git a/smartcard/pyro/server/PyroEventServer.py b/smartcard/pyro/server/PyroEventServer.py index 3c762f9f..7d284e64 100644 --- a/smartcard/pyro/server/PyroEventServer.py +++ b/smartcard/pyro/server/PyroEventServer.py @@ -93,7 +93,6 @@ def __call__(self, signame, sf): if __name__ == '__main__': - import sys from smartcard.pyro.server.PyroNameServer import PyroNameServer pn = PyroNameServer(sys.argv[1:]) pn.start() diff --git a/smartcard/pyro/server/RemoteCardConnection.py b/smartcard/pyro/server/RemoteCardConnection.py index 9df373ee..2b092b7c 100644 --- a/smartcard/pyro/server/RemoteCardConnection.py +++ b/smartcard/pyro/server/RemoteCardConnection.py @@ -26,10 +26,7 @@ import Pyro.core import Pyro.naming -from smartcard.CardConnection import CardConnection from smartcard.CardConnectionDecorator import CardConnectionDecorator -from smartcard.Exceptions import CardConnectionException, NoCardException -from smartcard.Observer import Observable class RemoteCardConnection(CardConnectionDecorator, Pyro.core.ObjBase): diff --git a/smartcard/pyro/server/RemoteReaderServer.py b/smartcard/pyro/server/RemoteReaderServer.py index 4680eb98..5e5157a8 100644 --- a/smartcard/pyro/server/RemoteReaderServer.py +++ b/smartcard/pyro/server/RemoteReaderServer.py @@ -28,16 +28,12 @@ try: import Pyro.core import Pyro.naming -except: +except ImportError: print('You need pyro (python remote objects) ' + \ 'at http://www.xs4all.nl/~irmen/pyro3/') import sys sys.exit() -import signal -import time - -import smartcard.System from smartcard.reader.Reader import Reader from smartcard.ReaderMonitoring import ReaderMonitor, ReaderObserver from smartcard.pyro.server.RemoteCardConnection import RemoteCardConnection diff --git a/smartcard/wx/SimpleSCardAppFrame.py b/smartcard/wx/SimpleSCardAppFrame.py index c5e450ab..f08d120f 100644 --- a/smartcard/wx/SimpleSCardAppFrame.py +++ b/smartcard/wx/SimpleSCardAppFrame.py @@ -26,10 +26,11 @@ import os.path import wx + import smartcard.wx -import APDUTracerPanel -import CardAndReaderTreePanel -import ReaderToolbar +from smartcard.wx import APDUTracerPanel +from smartcard.wx import CardAndReaderTreePanel +from smartcard.wx import ReaderToolbar import smartcard from smartcard.wx.SimpleSCardAppEventObserver import \