class Cache(object):
-
+
def __init__(self, dir, params=None):
self.dir = dir
self.params = params
self.files = self.get_files()
-
+
def get_files(self):
list = []
for root, dirs, files in os.walk(self.dir):
for file in files:
list.append(file)
return list
-
+
def exists(self, file):
self.files = self.get_files()
return file in self.files
-
+
def write_bin(self, data, file):
path = self.dir + os.sep + file
f = open(path, 'w')
data = f.read()
f.close()
return data
-
+
def read_stream_bin(self, file):
path = self.dir + os.sep + file
chunk_size = 0x1000
list = []
path = self.dir + os.sep + file
doc = xml.dom.minidom.parse(path)
- for data in doc.documentElement.getElementsByTagName('data') :
+ for data in doc.documentElement.getElementsByTagName('data'):
name = data.getAttribute('name')
id = data.getAttribute('id')
unit = data.getAttribute('unit')
value = data.getAttribute('value')
list.append({'name': name, 'id': id, 'unit': unit, 'value': value})
return list
-
+
def write_analyzer_xml(self, data_list, file):
path = self.dir + os.sep + file
doc = xml.dom.minidom.Document()
from gst import Buffer
""" gstreamer buffer to numpy array conversion """
buf = Buffer(getbuffer(frames.astype("float32")))
- #Set its timestamp and duration
+ # Set its timestamp and duration
buf.timestamp = gst.util_uint64_scale(num_samples, gst.SECOND, sample_rate)
buf.duration = gst.util_uint64_scale(chunk_size, gst.SECOND, sample_rate)
return buf
class MainloopThread(threading.Thread):
+
def __init__(self, mainloop):
threading.Thread.__init__(self)
self.mainloop = mainloop
import logging
+
class Logger:
+
"""A logging object"""
def __init__(self, file):
self.logger = logging.getLogger('myapp')
self.hdlr = logging.FileHandler(file)
- self.formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')
+ self.formatter = logging.Formatter(
+ '%(asctime)s %(levelname)s %(message)s')
self.hdlr.setFormatter(self.formatter)
self.logger.addHandler(self.hdlr)
self.logger.setLevel(logging.INFO)
def write_error(self, message):
self.logger.error(message)
-