Skip to content

Commit

Permalink
1.3.11
Browse files Browse the repository at this point in the history
  • Loading branch information
thehappydinoa committed Aug 12, 2018
1 parent 521f392 commit 5fc0597
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 7 deletions.
5 changes: 4 additions & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,10 @@ disable=print-statement,
no-member,
dangerous-default-value,
no-self-use,
superfluous-parens
superfluous-parens,
invalid-name,
too-many-branches,
too-many-statements

enable=c-extension-no-member

Expand Down
2 changes: 1 addition & 1 deletion dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
twine
pytest
setuptools
pylint
18 changes: 14 additions & 4 deletions itachip2ir/device.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""device.py"""
import socket
from contextlib import closing
from traceback import format_exc

from itachip2ir.exception import iTachException

Expand Down Expand Up @@ -56,14 +57,20 @@ def __repr__(self):
"""repr method"""
return "VirtualDevice(name=%s, commands=%s)" % (self.name, self.commands)

def function_generator(self, command_name):
"""returns functions"""
def func():
"""generated fuction"""
print(command_name)
return self.send_command(command_name)
func.__name__ = command_name
return func

def generate_functions(self):
"""dynamically generate functions"""
for command_name in self.commands.keys():
def func():
"""generated fuction"""
return self.send_command(command_name)
func = self.function_generator(command_name)
setattr(self, command_name, func)
func.__name__ = command_name

def format_message(self, msg):
"""format message"""
Expand Down Expand Up @@ -96,6 +103,9 @@ def send_command(self, command_name, byte_size=4096, timeout=3, verbose=False):
print("Received: " + response)
return response
except socket.error as error:
if verbose:
print(repr(error))
print(format_exc())
raise iTachException(str(error))
finally:
sock.close()
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

setup(
name='itachip2ir',
version='1.3.10',
version='1.3.11',
description='A small Python module for interacting with the Global Cache iTach WF2IR or IP2IR',
long_description=long_description,
url='https://github.com/thehappydinoa/itachip2ir',
Expand Down

0 comments on commit 5fc0597

Please sign in to comment.