Skip to content

Commit

Permalink
Fix most major pylint errors and warnings
Browse files Browse the repository at this point in the history
5 undefined variables remain unfixed, they appear to be missing
`smartcard.scard.scard` exports
```
************* Module smartcard.pcsc.PCSCReader
E: 67,22: Undefined variable 'SCardIntroduceReader' (undefined-variable)
E: 70,22: Undefined variable 'SCardAddReaderToGroup' (undefined-
variable)
E: 85,22: Undefined variable 'SCardRemoveReaderFromGroup' (undefined-
variable)
************* Module smartcard.pcsc.PCSCReaderGroups
E: 66,22: Undefined variable 'SCardIntroduceReaderGroup' (undefined-
variable)
E: 90,22: Undefined variable 'SCardForgetReaderGroup' (undefined-
variable)
```
  • Loading branch information
moreati committed Jun 22, 2015
1 parent 7b25b21 commit e1bba4b
Show file tree
Hide file tree
Showing 27 changed files with 21 additions and 60 deletions.
1 change: 0 additions & 1 deletion smartcard/Card.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions smartcard/CardConnection.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
"""

from smartcard.CardConnectionEvent import CardConnectionEvent
from smartcard.Exceptions import SmartcardException
from smartcard.Observer import Observer
from smartcard.Observer import Observable


Expand Down
4 changes: 0 additions & 4 deletions smartcard/CardMonitoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,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
Expand Down Expand Up @@ -216,7 +213,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
Expand Down
1 change: 0 additions & 1 deletion smartcard/CardService.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
"""

from smartcard.Exceptions import SmartcardException
from smartcard.scard import *


Expand Down
1 change: 1 addition & 0 deletions smartcard/CardType.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
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 InvalidATRMaskLengthException
from smartcard.System import readers
from smartcard.util import toHexString

Expand Down
4 changes: 0 additions & 4 deletions smartcard/ClassLoader.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(), [''])
Expand Down
1 change: 0 additions & 1 deletion smartcard/ExclusiveConnectCardConnection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.CardConnection import CardConnection
from smartcard.CardConnectionDecorator import CardConnectionDecorator
from smartcard.Exceptions import CardConnectionException
from smartcard.scard import SCardConnect, SCardDisconnect
Expand Down
2 changes: 0 additions & 2 deletions smartcard/ExclusiveTransmitCardConnection.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,11 @@
along with pyscard; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
"""
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


Expand Down
2 changes: 1 addition & 1 deletion smartcard/Observer.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

class Observer(object):

def update(observable, arg):
def update(self, observable, arg):
'''Called when the observed object is
modified. You call an Observable object's
notifyObservers method to notify all the
Expand Down
1 change: 0 additions & 1 deletion smartcard/PassThruCardService.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,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()
Expand Down
4 changes: 1 addition & 3 deletions smartcard/ReaderMonitoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,11 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
"""

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 *
Expand Down Expand Up @@ -196,7 +195,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
Expand Down
6 changes: 0 additions & 6 deletions smartcard/Session.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
"""

from smartcard.Exceptions import InvalidReaderException, NoReadersException
from smartcard.CardConnection import CardConnection
from smartcard.PassThruCardService import PassThruCardService
from smartcard.System import readers

Expand Down Expand Up @@ -110,8 +109,3 @@ def getATR(self):
def __repr__(self):
"""Returns a string representation of the session."""
return "<Session instance: readerName=%s>" % self.readerName


if __name__ == '__main__':
"""Small sample illustrating the use of Session.py."""
pass
1 change: 0 additions & 1 deletion smartcard/guid.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ def GUIDToStr(g):

if __name__ == "__main__":
"""Small sample illustrating the use of guid.py."""
import smartcard.guid
dummycardguid1 = strToGUID('{AD4F1667-EA75-4124-84D4-641B3B197C65}')
print dummycardguid1
print GUIDToStr(dummycardguid1)
5 changes: 2 additions & 3 deletions smartcard/pcsc/PCSCCardConnection.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
from smartcard.CardConnection import CardConnection
from smartcard.Exceptions import (CardConnectionException,
NoCardException, SmartcardException)
from smartcard.Observer import Observable

from smartcard.scard import *

Expand Down Expand Up @@ -240,8 +239,8 @@ def doGetAttrib(self, attribId):
"""Small sample illustrating the use of CardConnection."""
SELECT = [0xA0, 0xA4, 0x00, 0x00, 0x02]
DF_TELECOM = [0x7F, 0x10]
from smartcard.pcsc.PCSCReader import readers
cc = readers()[0].createConnection()
from smartcard.pcsc.PCSCReader import PCSCReader
cc = PCSCReader.readers()[0].createConnection()
cc.connect()
print "%r %x %x" % cc.transmit(SELECT + DF_TELECOM)

Expand Down
4 changes: 2 additions & 2 deletions smartcard/pcsc/PCSCPart10.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,8 @@ def getTlvProperties(cardConnection, featureList=None, controlCode=None):

if __name__ == '__main__':
"""Small sample illustrating the use of PCSCPart10."""
from smartcard.pcsc.PCSCReader import readers
cc = readers()[0].createConnection()
from smartcard.pcsc.PCSCReader import PCSCReader
cc = PCSCReader.readers()[0].createConnection()
cc.connect(mode=SCARD_SHARE_DIRECT)

#print cc.control( CM_IOCTL_GET_FEATURE_REQUEST )
Expand Down
3 changes: 1 addition & 2 deletions smartcard/pyro/PyroReader.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,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):
Expand Down
4 changes: 2 additions & 2 deletions smartcard/pyro/server/PyroDaemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ def __init__(self):
Thread.__init__(self)
self.setDaemon(True)
self.setName('smartcard.pyro.server.PyroDaemonThread')
self.daemon = PyroDaemon()
self._daemon = PyroDaemon()

def run(self):
"""Starts Pyro daemon."""
self.daemon.start()
self._daemon.start()
1 change: 0 additions & 1 deletion smartcard/pyro/server/PyroEventServer.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,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()
Expand Down
3 changes: 0 additions & 3 deletions smartcard/pyro/server/RemoteCardConnection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
4 changes: 0 additions & 4 deletions smartcard/pyro/server/RemoteReaderServer.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@
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
Expand Down
3 changes: 0 additions & 3 deletions smartcard/reader/ReaderGroups.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,6 @@ def __onremoveitem__(self, item):
def __iter__(self):
return ulist.__iter__(self)

def next(self):
return ulist.__next__(self)

#
# abstract methods implemented in subclasses
#
Expand Down
2 changes: 1 addition & 1 deletion smartcard/sw/ErrorChecker.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class ErrorChecker(object):
pattern.
"""

def __call__(data, sw1, sw2):
def __call__(self, data, sw1, sw2):
"""Called to test data, sw1 and sw2 for error.
@param data: apdu response data
Expand Down
5 changes: 1 addition & 4 deletions smartcard/util/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def toBytes(bytestring):
"""
import struct
import re
packedstring = ''.join(re.split('\W+', bytestring))
packedstring = ''.join(re.split(r'\W+', bytestring))
try:
return reduce(lambda x, y: x + [int(y, 16)],
struct.unpack('2s' * (len(packedstring) / 2),
Expand Down Expand Up @@ -204,9 +204,6 @@ def toHexString(bytes=[], format=0):

from string import rstrip

for byte in tuple(bytes):
pass

if type(bytes) is not list:
raise TypeError('not a list of bytes')

Expand Down
2 changes: 1 addition & 1 deletion smartcard/wx/APDUHexValidator.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def Clone(self):

def Validate(self, win):
tc = self.GetWindow()
val = tc.GetValue()
value = tc.GetValue()

if not apduregexp.match(value):
return False
Expand Down
4 changes: 2 additions & 2 deletions smartcard/wx/CardAndReaderTreePanel.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,9 +408,9 @@ def __init__(self, parent, appstyle, clientpanel):
def OnDestroy(self, event):
"""Called on panel destruction."""
# deregister observers
if hasattr(self, cardmonitor):
if hasattr(self, 'cardmonitor'):
self.cardmonitor.deleteObserver(self.cardtreecardobserver)
if hasattr(self, readermonitor):
if hasattr(self, 'readermonitor'):
self.readermonitor.deleteObserver(self.readertreereaderobserver)
self.cardmonitor.deleteObserver(self.readertreecardobserver)
event.Skip()
4 changes: 2 additions & 2 deletions smartcard/wx/ReaderToolbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ def __init__(self, parent):
bmpReader = wx.Bitmap(ICO_READER, wx.BITMAP_TYPE_ICO)
else:
bmpReader = wx.ArtProvider_GetBitmap(
wx.ART_HELP_BOOK, wx.ART_OTHER, isz)
wx.ART_HELP_BOOK, wx.ART_OTHER, tsize)
if None != ICO_SMARTCARD:
bmpCard = wx.Bitmap(ICO_SMARTCARD, wx.BITMAP_TYPE_ICO)
else:
bmpCard = wx.ArtProvider_GetBitmap(
wx.ART_HELP_BOOK, wx.ART_OTHER, isz)
wx.ART_HELP_BOOK, wx.ART_OTHER, tsize)
self.readercombobox = ReaderComboBox(self)

# create and add controls
Expand Down
7 changes: 4 additions & 3 deletions smartcard/wx/SimpleSCardAppFrame.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down

0 comments on commit e1bba4b

Please sign in to comment.