Skip to content

Commit

Permalink
more cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
bashwork committed Mar 3, 2011
1 parent 525c41d commit ec2241b
Show file tree
Hide file tree
Showing 12 changed files with 25 additions and 30 deletions.
10 changes: 2 additions & 8 deletions doc/quality/current.lint
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,13 @@ pymodbus/factory.py:15: 'from pymodbus.file_message import *' used; unable to de
pymodbus/factory.py:16: 'from pymodbus.other_message import *' used; unable to detect undefined names
pymodbus/factory.py:17: 'from pymodbus.register_read_message import *' used; unable to detect undefined names
pymodbus/factory.py:18: 'from pymodbus.register_write_message import *' used; unable to detect undefined names
pymodbus/transaction.py:58: undefined name 'socket'
pymodbus/other_message.py:11: 'from pymodbus.exceptions import *' used; unable to detect undefined names
pymodbus/other_message.py:389: local variable 'status' is assigned to but never used
pymodbus/server/async.py:229: local variable 'handle' is assigned to but never used
pymodbus/server/async.py:230: local variable 'handle' is assigned to but never used
pymodbus/server/sync.py:16: 'from pymodbus.transaction import *' used; unable to detect undefined names
pymodbus/datastore/remote.py:66: local variable 'result' is assigned to but never used
pymodbus/client/async.py:20: 'reactor' imported but unused
pymodbus/client/common.py:3: 'from pymodbus.bit_read_message import *' used; unable to detect undefined names
pymodbus/client/common.py:4: 'from pymodbus.bit_write_message import *' used; unable to detect undefined names
pymodbus/client/common.py:5: 'from pymodbus.register_read_message import *' used; unable to detect undefined names
pymodbus/client/common.py:6: 'from pymodbus.register_write_message import *' used; unable to detect undefined names
pymodbus/client/common.py:7: 'from pymodbus.diag_message import *' used; unable to detect undefined names
pymodbus/client/common.py:8: 'from pymodbus.file_message import *' used; unable to detect undefined names
pymodbus/client/common.py:9: 'from pymodbus.other_message import *' used; unable to detect undefined names
pymodbus/client/sync.py:6: 'from pymodbus.exceptions import *' used; unable to detect undefined names
pymodbus/client/sync.py:7: 'from pymodbus.transaction import *' used; unable to detect undefined names
pymodbus/client/sync.py:8: 'from pymodbus.transaction import *' used; unable to detect undefined names
17 changes: 8 additions & 9 deletions pymodbus/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""
'''
Pymodbus: Modbus Protocol Implementation
-----------------------------------------
Expand All @@ -9,22 +9,21 @@
Hynek Petrak <hynek@swac.cz>
Released under the the BSD license
"""
'''

from pymodbus.version import _version
__version__ = _version.short()
import pymodbus.version as __version
__version__ = __version.version.short()
__author__ = 'Galen Collins'

#---------------------------------------------------------------------------#
# Block unhandled logging
#---------------------------------------------------------------------------#
import logging
import logging as __logging
try:
from logging import NullHandler
from logging import NullHandler as __null
except ImportError:
class NullHandler(logging.Handler):
class __null(__logging.Handler):
def emit(self, record):
pass

h = NullHandler()
logging.getLogger(__name__).addHandler(h)
__logging.getLogger(__name__).addHandler(__null())
4 changes: 1 addition & 3 deletions pymodbus/client/async.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ def clientTest():
reactor.run()
"""
from collections import deque

from twisted.internet import reactor, defer, protocol

from twisted.internet import defer, protocol
from pymodbus.factory import ClientDecoder
from pymodbus.exceptions import ConnectionException
from pymodbus.transaction import ModbusSocketFramer
Expand Down
3 changes: 2 additions & 1 deletion pymodbus/client/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

from pymodbus.constants import Defaults
from pymodbus.factory import ClientDecoder
from pymodbus.exceptions import *
from pymodbus.exceptions import NotImplementedException, ParameterException
from pymodbus.exceptions import ConnectionException
from pymodbus.transaction import *
from pymodbus.client.common import ModbusClientMixin

Expand Down
2 changes: 1 addition & 1 deletion pymodbus/datastore/modredis.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def __init__(self, **kwargs):
host = kwargs.get('host', 'localhost')
port = kwargs.get('port', 6379)
self.prefix = kwargs.get('prefix', 'pymodbus')
self.client = redis.Redis(host=host, port=port)
self.client = kwargs.get('client', redis.Redis(host=host, port=port))
self.__build_mapping()

def __str__(self):
Expand Down
2 changes: 1 addition & 1 deletion pymodbus/datastore/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def setValues(self, fx, address, values):
'''
# TODO deal with deferreds
_logger.debug("set values[%d] %d:%d" % (fx, address, len(values)))
result = self.__set_callbacks[self.decode(fx)](address, values)
self.__set_callbacks[self.decode(fx)](address, values)

def __str__(self):
''' Returns a string representation of the context
Expand Down
3 changes: 3 additions & 0 deletions pymodbus/internal/ptwisted.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
_logger = logging.getLogger(__name__)


#---------------------------------------------------------------------------#
# Twisted Helper Methods
#---------------------------------------------------------------------------#
def InstallManagementConsole(namespace, users={'admin': 'admin'}, port=503):
''' Helper method to start an ssh management console
for the modbus server.
Expand Down
3 changes: 1 addition & 2 deletions pymodbus/other_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from pymodbus.pdu import ModbusRequest
from pymodbus.pdu import ModbusResponse
from pymodbus.device import ModbusControlBlock
from pymodbus.exceptions import *

_MCB = ModbusControlBlock()

Expand Down Expand Up @@ -390,7 +389,7 @@ def encode(self):
length = len(self.identifier) + 2
packet = struct.pack('>B', length)
packet += self.identifier # we assume it is already encoded
packet += struct.pack('>B', self.status)
packet += struct.pack('>B', status)
return packet

def decode(self, data):
Expand Down
1 change: 1 addition & 0 deletions pymodbus/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def execute(self, request):
''' Starts the producer to send the next request to
consumer.write(Frame(request))
'''
import socket
retries = Defaults.Retries
request.transaction_id = self.__getNextTID()
_logger.debug("Running transaction %d" % request.transaction_id)
Expand Down
6 changes: 3 additions & 3 deletions pymodbus/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ def __str__(self):
'''
return '[%s, version %s]' % (self.package, self.short())

_version = Version('pymodbus', 0, 9, 0)
_version.__name__ = 'pymodbus' # fix epydoc error
version = Version('pymodbus', 0, 9, 0)
version.__name__ = 'pymodbus' # fix epydoc error

#---------------------------------------------------------------------------#
# Exported symbols
#---------------------------------------------------------------------------#
__all__ = ["_version"]
__all__ = ["version"]
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ verbosity=0
detailed-errors=1
with-coverage=1
cover-html=1
cover-html-dir=doc/coverage/
cover-html-dir=build/coverage/
cover-package=pymodbus
#debug=nose.loader
#pdb=1
Expand Down
2 changes: 1 addition & 1 deletion test/test_other_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def testReportSlaveId(self):
self.assertEqual(request.execute().function_code, 0x11)

response = ReportSlaveIdResponse(request.execute().identifier, True)
self.assertEqual(response.encode(), '\x0apymodbus\x01')
self.assertEqual(response.encode(), '\x0apymodbus\xff')
response.decode('\x03\x12\x00')
self.assertEqual(response.status, False)
self.assertEqual(response.identifier, '\x12')
Expand Down

0 comments on commit ec2241b

Please sign in to comment.