diff --git a/README.md b/README.md index f0c2066..11588a6 100644 --- a/README.md +++ b/README.md @@ -15,8 +15,7 @@ any code you want. ### Instructions -All of the code to make it work is contained in the single file, `fauxmo.py`. It -requires Python 2.7 and standard libraries. The example handler class that +All of the code to make it work is contained in the single file, `fauxmo.py`, which is python 2, and 3 compatible. The example handler class that reacts to on and off commands uses the [python-requests](http://docs.python-requests.org/en/latest/) library, but could be replaced with code that does the same thing in many different ways. diff --git a/fauxmo.py b/fauxmo.py index 1df4e1d..9bf34fc 100755 --- a/fauxmo.py +++ b/fauxmo.py @@ -60,7 +60,7 @@ def dbg(msg): global DEBUG if DEBUG: - print msg + print(msg) sys.stdout.flush() @@ -300,17 +300,17 @@ def init_socket(self): try: self.ssock.bind(('',self.port)) - except Exception, e: + except Exception as e: dbg("WARNING: Failed to bind %s:%d: %s" , (self.ip,self.port,e)) ok = False try: self.ssock.setsockopt(socket.IPPROTO_IP,socket.IP_ADD_MEMBERSHIP,self.mreq) - except Exception, e: + except Exception as e: dbg('WARNING: Failed to join multicast group:',e) ok = False - except Exception, e: + except Exception as e: dbg("Failed to initialize UPnP sockets:",e) return False if ok: @@ -343,7 +343,7 @@ def recvfrom(self,size): return self.ssock.recvfrom(size) else: return False, False - except Exception, e: + except Exception as e: dbg(e) return False, False @@ -417,7 +417,7 @@ def off(self): # Allow time for a ctrl-c to stop the process p.poll(100) time.sleep(0.1) - except Exception, e: + except Exception as e: dbg(e) break