in community-artifacts/Deep-learning/Utilities/madlib_image_loader.py [0:0]
def _write_tmp_file_and_load(self, data):
table_name = self.table_name
if not self.tmp_dir:
print("{0}: Can't find temporary directory... exiting."\
.format(self.pr_name))
time.sleep(1) # allow some time for p.terminate() to be called
return
filename = os.path.join(self.tmp_dir, '{0}{1:04}.tmp'.format(
table_name, self.img_num))
self.img_num += 1
with file(filename, 'w') as f:
self._write_file(f, data)
print("{0}: Wrote {1} images to {2}".format(self.pr_name, len(data),
filename))
with file(filename, 'r') as f:
self._copy_into_db(f, data)