py3 compat

This commit is contained in:
Michael Davidsaver
2013-12-10 22:31:36 -05:00
parent 17436ceffb
commit 8a575f183e
4 changed files with 13 additions and 5 deletions
+6 -2
View File
@@ -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