diff --git a/devsupApp/src/devsup/hooks.py b/devsupApp/src/devsup/hooks.py index 559c4e4..4e49ac3 100644 --- a/devsupApp/src/devsup/hooks.py +++ b/devsupApp/src/devsup/hooks.py @@ -14,9 +14,9 @@ __all__ = [ "debugHooks", ] -hooknames = _dbapi._hooks.keys() +hooknames = list(_dbapi._hooks.keys()) -_revnames = dict([(v,k) for k,v in _dbapi._hooks.iteritems()]) +_revnames = dict([(v,k) for k,v in _dbapi._hooks.items()]) _hooktable = defaultdict(list) diff --git a/logApp/src/inotify_wrap.c b/logApp/src/inotify_wrap.c index 248afee..468d03e 100644 --- a/logApp/src/inotify_wrap.c +++ b/logApp/src/inotify_wrap.c @@ -211,7 +211,11 @@ static struct PyModuleDef inotifymodule = { # define MODINIT_RET(VAL) return #endif +#if PY_MAJOR_VERSION >= 3 +PyMODINIT_FUNC PyInit__inotifyy(void) +#else PyMODINIT_FUNC init_inotifyy(void) +#endif { PyObject *mod = NULL; diff --git a/logApp/src/inotifyy.py b/logApp/src/inotifyy.py index 94d1fa8..1b6180b 100644 --- a/logApp/src/inotifyy.py +++ b/logApp/src/inotifyy.py @@ -42,7 +42,7 @@ class INotify(_inotifyy.INotify): def close(self): self.__done = True - os.write(self.__wake,'*') + os.write(self.__wake,b'*') def add(self, callback, path, mask=IN_ALL_EVENTS): wd = super(INotify, self).add(path, mask) diff --git a/logApp/src/logwatch/__init__.py b/logApp/src/logwatch/__init__.py index fadaaca..4affb3f 100644 --- a/logApp/src/logwatch/__init__.py +++ b/logApp/src/logwatch/__init__.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- from __future__ import print_function -import os.path, errno, time +import os.path, errno, time, sys import numpy as np @@ -11,6 +11,8 @@ from devsup.hooks import addHook from devsup.util import importmod, StoppableThread from devsup.db import IOScanListThread +py3 = sys.version_info[0]>=3 + mask=inot.IN_CREATE|inot.IN_DELETE|inot.IN_MOVED_FROM|inot.IN_MODIFY class LogWatcher(StoppableThread): @@ -50,6 +52,8 @@ class LogWatcher(StoppableThread): if reason is None: return ts, reason = reason + if py3: + reason = reason.encode('ascii') buf = np.frombuffer(reason, dtype=self.arr.dtype) buf = buf[:rec.NELM-1] self.arr[:buf.size] = buf @@ -96,7 +100,7 @@ class LogWatcher(StoppableThread): try: self.fd = open(self.fname, 'r') self.pos = self.fd.tell() - except IOError, e: + except IOError as e: if e.errno==errno.ENOENT: return raise