py3 compat
This commit is contained in:
@ -14,9 +14,9 @@ __all__ = [
|
|||||||
"debugHooks",
|
"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)
|
_hooktable = defaultdict(list)
|
||||||
|
|
||||||
|
@ -211,7 +211,11 @@ static struct PyModuleDef inotifymodule = {
|
|||||||
# define MODINIT_RET(VAL) return
|
# define MODINIT_RET(VAL) return
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if PY_MAJOR_VERSION >= 3
|
||||||
|
PyMODINIT_FUNC PyInit__inotifyy(void)
|
||||||
|
#else
|
||||||
PyMODINIT_FUNC init_inotifyy(void)
|
PyMODINIT_FUNC init_inotifyy(void)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
PyObject *mod = NULL;
|
PyObject *mod = NULL;
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ class INotify(_inotifyy.INotify):
|
|||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
self.__done = True
|
self.__done = True
|
||||||
os.write(self.__wake,'*')
|
os.write(self.__wake,b'*')
|
||||||
|
|
||||||
def add(self, callback, path, mask=IN_ALL_EVENTS):
|
def add(self, callback, path, mask=IN_ALL_EVENTS):
|
||||||
wd = super(INotify, self).add(path, mask)
|
wd = super(INotify, self).add(path, mask)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
import os.path, errno, time
|
import os.path, errno, time, sys
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
@ -11,6 +11,8 @@ from devsup.hooks import addHook
|
|||||||
from devsup.util import importmod, StoppableThread
|
from devsup.util import importmod, StoppableThread
|
||||||
from devsup.db import IOScanListThread
|
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
|
mask=inot.IN_CREATE|inot.IN_DELETE|inot.IN_MOVED_FROM|inot.IN_MODIFY
|
||||||
|
|
||||||
class LogWatcher(StoppableThread):
|
class LogWatcher(StoppableThread):
|
||||||
@ -50,6 +52,8 @@ class LogWatcher(StoppableThread):
|
|||||||
if reason is None:
|
if reason is None:
|
||||||
return
|
return
|
||||||
ts, reason = reason
|
ts, reason = reason
|
||||||
|
if py3:
|
||||||
|
reason = reason.encode('ascii')
|
||||||
buf = np.frombuffer(reason, dtype=self.arr.dtype)
|
buf = np.frombuffer(reason, dtype=self.arr.dtype)
|
||||||
buf = buf[:rec.NELM-1]
|
buf = buf[:rec.NELM-1]
|
||||||
self.arr[:buf.size] = buf
|
self.arr[:buf.size] = buf
|
||||||
@ -96,7 +100,7 @@ class LogWatcher(StoppableThread):
|
|||||||
try:
|
try:
|
||||||
self.fd = open(self.fname, 'r')
|
self.fd = open(self.fname, 'r')
|
||||||
self.pos = self.fd.tell()
|
self.pos = self.fd.tell()
|
||||||
except IOError, e:
|
except IOError as e:
|
||||||
if e.errno==errno.ENOENT:
|
if e.errno==errno.ENOENT:
|
||||||
return
|
return
|
||||||
raise
|
raise
|
||||||
|
Reference in New Issue
Block a user