Add package in imports.

This commit is contained in:
Mikaël Ates 2016-02-23 13:01:37 +01:00
parent 93a226ff79
commit fe232de1b7
5 changed files with 25 additions and 23 deletions

View File

@ -27,7 +27,7 @@
'''
from _exceptions import MalformedDataError
from librfid._exceptions import MalformedDataError
def inventory(response):

View File

@ -23,20 +23,22 @@
'''
import utils
from datetime import datetime
import core_standard
from serial import (Serial, EIGHTBITS, PARITY_NONE, STOPBITS_ONE)
from _exceptions import (UnknownReaderTypeException, UnknownReaderException,
import librfid.core_standard
from librfid.utils import get_length_on_2_bytes, get_crc_16_CCITT
from librfid._exceptions import (UnknownReaderTypeException, UnknownReaderException,
BadLengthMessageException, BadCRCException,
CommandResponseCodeMismatchException, UnknownReaderException,
StandardResponseError, UnknownResponseErrorType,
ReaderResponseError)
from commands_standard import COMMANDS as STANDARD_COMMANDS
from errors_standard import ERRORS as STANDARD_ERRORS
from reader_configs import READERS
from librfid.commands_standard import COMMANDS as STANDARD_COMMANDS
from librfid.errors_standard import ERRORS as STANDARD_ERRORS
from librfid.reader_configs import READERS
class RFIDReader():
@ -155,7 +157,7 @@ class Command():
self.data = kwargs.pop('data', '')
if self.data:
self.process_data()
self.lout = utils.get_length_on_2_bytes(self.raw_data)
self.lout = get_length_on_2_bytes(self.raw_data)
self.command = self.rfu + self.type_cmd + self.code_cmd + \
self.reserved + self.lout + self.raw_data
@ -164,17 +166,17 @@ class Command():
def process_data(self):
try:
getattr(core_standard, self.command_name.lower())(self)
getattr(librfid.core_standard, self.command_name.lower())(self)
except:
pass
def build_message(self):
self.sof = '\x02'
self.length = utils.get_length_on_2_bytes(self.command)
self.length = get_length_on_2_bytes(self.command)
self.ctrl_addr = '\x00' # RS232 only
self.ctrl_mode = '\x00' # Unsecure mode
message = self.length + self.ctrl_addr + self.ctrl_mode + self.command
self.crc = utils.get_crc_16_CCITT(message)
self.crc = get_crc_16_CCITT(message)
self.message = self.sof + message + self.crc
def get_message(self):
@ -227,7 +229,7 @@ class ReaderCommand(Command):
self.data = kwargs.pop('data', '')
if self.data:
self.process_data()
self.lout = utils.get_length_on_2_bytes(self.raw_data)
self.lout = get_length_on_2_bytes(self.raw_data)
self.command = self.rfu + self.type_cmd + self.code_cmd + \
self.reserved + self.lout + self.raw_data
@ -259,7 +261,7 @@ class Response():
self.response = message[5:-2]
self.crc = message[-2:]
str_to_check = self.message[1:-2] # [Len ... Commande]
crc = utils.get_crc_16_CCITT(str_to_check)
crc = get_crc_16_CCITT(str_to_check)
if self.crc != crc:
raise BadCRCException('CRC checking failed')
self.code = self.response[0:2]
@ -313,7 +315,7 @@ class Response():
if isinstance(self.command, ReaderCommand):
module = self.command.reader.core
else:
module = core_standard
module = librfid.core_standard
getattr(module, core_method_name)(self)
except Exception, e:
pass

View File

@ -22,10 +22,10 @@
'''
from stid_readers.commands_basic import COMMANDS as BASIC_STID_COMMANDS
from stid_readers.params_basic import PARAMS as BASIC_STID_PARAMS
from stid_readers.errors_basic import ERRORS as BASIC_STID_ERRORS
from stid_readers import core as BASIC_STID_CORE
from librfid.stid_readers.commands_basic import COMMANDS as BASIC_STID_COMMANDS
from librfid.stid_readers.params_basic import PARAMS as BASIC_STID_PARAMS
from librfid.stid_readers.errors_basic import ERRORS as BASIC_STID_ERRORS
from librfid.stid_readers import core as BASIC_STID_CORE
READERS = {

View File

@ -27,8 +27,8 @@
'''
from _exceptions import MalformedDataError, BadParameterException
from utils import get_integer_on_two_bytes, hex_to_int
from librfid._exceptions import MalformedDataError, BadParameterException
from librfid.utils import get_integer_on_two_bytes, hex_to_int
def get_rfsettings(response):

View File

@ -25,7 +25,7 @@
import crc16
from binascii import unhexlify
from _exceptions import OverheadException
from librfid._exceptions import OverheadException
def get_length_on_2_bytes(string):