首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >OpenERP射频识别终端模块错误

OpenERP射频识别终端模块错误
EN

Stack Overflow用户
提问于 2013-11-30 15:15:11
回答 2查看 653关注 0票数 0

在成功地将RFID终端模块安装到OpenERP 7的新数据库以从ZKTeco DS100计算机提取考勤日志之后,我尝试在模块中添加一个用户(将机器上的ID与OpenERP中的雇员ID链接起来)。我知道错误:

代码语言:javascript
复制
    File "C:\Program Files (x86)\OpenERP 7.0-20130610-231029\Server\server\openerp\addons\hr_attendance_terminal\hr_attendance_terminal.py", line 230, in create_terminal_users
    UnboundLocalError: local variable 's' referenced before assignment

代码块:

代码语言:javascript
复制
def create_terminal_users(self, cr, uid, automatic=False, use_new_cursor=False, context=None):
            if context is None:
            context = {}

        terminal_ids = self.pool.get('hr.attendance.terminal').search(cr, uid, [])

        for t_id in terminal_ids:
            terminal = self.pool.get('hr.attendance.terminal').browse(cr, uid, t_id, context=context)
            #print "CREATE USER ON Terminal: %s | %s" % (terminal.tnr, terminal.ip)

            TerminalNr = terminal.tnr # zweistelling in Hex         
            host = terminal.ip # Terminaladresse

            port = 8000 # Terminaldatenport
            STX = '\x02' # Startbit
            ETX = '\x03' # Stopbit

            emp_ids = self.pool.get('hr.employee').search(cr, uid, [('rfid_key', '!=', '')])
            if emp_ids:

                #Verbindung herstellen
                s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
                try:
                    s.connect((host,port))
                except socket.error, msg:
                    print 'Socket Error: %s' % msg
                    break

                for emp_id in emp_ids:
                    employee = self.pool.get('hr.employee').browse(cr, uid, emp_id, context=context)

                    s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
                    rfid_key = employee.rfid_key
                    employee_name = employee.name
                    pin = '0000'
                    pinabfrage = '0' # bei 1 wird pin abgefragt
                    infotext1 = '                ' # 16 Zeichen Infotext
                    infotext2 = employee_name.center(16) # 16 Zeichen Infotext
                    infotext3 = '                ' # 16 Zeichen Infotext
                    infotext4 = '                ' # 16 Zeichen Infotext

                    #Paket / Telegram erstellen
                    #Schema: <STX>SS<Kommando><Daten><BCC><ETX>

                    bccstring = self.create_bcc(TerminalNr + 'SPSTA' + rfid_key + pin + pinabfrage + infotext1 + infotext2 + infotext3 + infotext4)
                    message = STX + TerminalNr + 'SPSTA' + rfid_key + pin + pinabfrage + infotext1 + infotext2 + infotext3 + infotext4 + bccstring + ETX
                    #print "Employee: %s" % employee.name
                    #Paket / Telegram senden
                    try:
                        s.sendall(message)
                    except socket.error, msg:
                        print 'Socket Error: %s' % msg
                        break
                    while 1:
                        reply = s.recv(8192)
                        if str(reply) != '':
                            r_message = re.sub(r'\x02|\x03','',str(reply))
                            r_terminal = r_message[0:2]
                            if r_message[2:7] == 'SPSTA':
                                #print "Stammsatz gespeichert!"
                                break

        s.close()
        return True

备注:

  • 该模块安装正常,尽管它是为OERP 6构建的。
  • 做了一些小的修改来匹配OERP 7的import函数。
  • Python 2.7
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2013-12-02 06:42:30

s.close()应该在for循环中。

票数 0
EN

Stack Overflow用户

发布于 2013-12-18 15:26:29

我想补充我的意见,因为我们是模块的创建者。您安装的模块只适用于这个特定的设备:来自ADC GmbH的Officetimer II,而不是任何其他的RFID考勤设备!

请注意,公开提供的模块只是从2011年中期开始的OpenERP版本6.0的第一个版本,实际上您可以称之为草案,错误修复和增强还没有应用到启动板分支!由于终端通信和时区管理的处理,本模块不应该与OpenERP的版本6.1或7.0一起使用!

当然,我们已经将模块移植到6.1和7.0,但是由于几个原因,我们没有公开这些模块。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20301839

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档