paulfp / Three-Factor-Security-Door

What do you get when you mix a Raspberry Pi, a MySQL database, an RFID reader, an LCD touchscreen, a relay switch, an electronic door strike and a Twilio SMS account?
https://www.switchedonnetwork.com/2017/11/10/build-the-ultimate-door-security-system-with-three-factor-authentication/
55 stars 35 forks source link

Stuck with lock.py #1

Open arnoldmitrica opened 4 years ago

arnoldmitrica commented 4 years ago

First, thank you for your tutorial from yt. Really nice done.

After I load the script using python lock.py it says:

Exception in thread Thread-1: Traceback (most recent call last): File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner self.run() File "/usr/lib/python2.7/threading.py", line 754, in run self.target(*self.args, **self.__kwargs) File "lock.py", line 195, in listen_rfid rfid_presented += keys[ event.code ] IndexError: string index out of range

Exception TypeError: TypeError('super() takes at least 1 argument (0 given)',) in <bound method InputDevice.del of InputDevice('/dev/input/event0')> ignored

-------------------------------------For line 801 in threading.py----------------------------------

def __bootstrap_inner(self):

    try:
        self._set_ident()
        self.__started.set()
        with _active_limbo_lock:
            _active[self.__ident] = self
            del _limbo[self]
        if __debug__:
            self._note("%s.__bootstrap(): thread started", self)

        if _trace_hook:
            self._note("%s.__bootstrap(): registering trace hook", self)
            _sys.settrace(_trace_hook)
        if _profile_hook:
            self._note("%s.__bootstrap(): registering profile hook", self)
            _sys.setprofile(_profile_hook)

try: self.run() LINE 801

        except SystemExit:
            if __debug__:
                self._note("%s.__bootstrap(): raised SystemExit", self)
        except:
            if __debug__:
                self._note("%s.__bootstrap(): unhandled exception", self)
            # If sys.stderr is no more (most likely from interpreter
            # shutdown) use self.__stderr.  Otherwise still use sys (as in
            # _sys) in case sys.stderr was redefined since the creation of
            # self.
            if _sys and _sys.stderr is not None:
                print>>_sys.stderr, ("Exception in thread %s:\n%s" %
                                     (self.name, _format_exc()))
            elif self.__stderr is not None:
                # Do the best job possible w/o a huge amt. of code to
                # approximate a traceback (code ideas from
                # Lib/traceback.py)
                exc_type, exc_value, exc_tb = self.__exc_info()
                try:
                    print>>self.__stderr, (
                        "Exception in thread " + self.name +
                        " (most likely raised during interpreter shutdown):")
                    print>>self.__stderr, (
                        "Traceback (most recent call last):")
                    while exc_tb:
                        print>>self.__stderr, (
                            '  File "%s", line %s, in %s' %
                            (exc_tb.tb_frame.f_code.co_filename,
                                exc_tb.tb_lineno,
                                exc_tb.tb_frame.f_code.co_name))
                        exc_tb = exc_tb.tb_next
                    print>>self.__stderr, ("%s: %s" % (exc_type, exc_value))
                # Make sure that exc_tb gets deleted since it is a memory
                # hog; deleting everything else is just for thoroughness
                finally:
                    del exc_type, exc_value, exc_tb
        else:
            if __debug__:
                self._note("%s.__bootstrap(): normal return", self)
        finally:
            # Prevent a race in
            # test_threading.test_no_refcycle_through_target when
            # the exception keeps the target alive past when we
            # assert that it's dead.
            self.__exc_clear()
    finally:
        with _active_limbo_lock:
            self.__stop()
            try:
                # We don't call self.__delete() because it also
                # grabs _active_limbo_lock.
                del _active[_get_ident()]
            except:
                pass

---------------------------------------For line 754 in threading.py ------------------------------

def run(self):

    """Method representing the thread's activity.

    You may override this method in a subclass. The standard run() method
    invokes the callable object passed to the object's constructor as the
    target argument, if any, with sequential and keyword arguments taken
    from the args and kwargs arguments, respectively.

    """
    try:
        if self.__target:

self.target(*self.args, **self.__kwargs) LINE 754

    finally:
        # Avoid a refcycle if the thread is running a function with
        # an argument that has a member that points to the thread.
        del self.__target, self.__args, self.__kwargs
bixicy commented 4 years ago

Yes, the 0-argument syntax is specific to Python 3.

In Python 2 and code that must be cross-version compatible, just stick to passing in the class object and instance explicitly.

And by the way, Python 2 has reached End Of Life. Try to change to Python 3