def read_one(self, fpath, outbuf=None, verbose=False): if outbuf is None: outbuf = BytesIO() outbuf.write(b'\nReading %s.\n' % fpath.encode('utf8')) outbuf.flush() if verbose: logger.info('Reading %s.' % fpath) outpath = None try: outpath = sparser.run_sparser(fpath, 'json', outbuf) except Exception as e: if verbose: logger.error('Failed to run sparser on %s.' % fpath) logger.exception(e) outbuf.write(b'Reading failed.\n') return outpath, outbuf
def read_one(self, fpath, outbuf=None, verbose=False): fpath = path.abspath(fpath) if outbuf is None: outbuf = BytesIO() outbuf.write(b'\nReading %s.\n' % fpath.encode('utf8')) outbuf.flush() if verbose: logger.info('Reading %s.' % fpath) outpath = None try: outpath = sparser.run_sparser(fpath, 'json', outbuf, timeout=60) except Exception as e: if verbose: logger.error('Failed to run sparser on %s.' % fpath) logger.exception(e) outbuf.write(b'Reading failed.----------\n') outbuf.write(str(e).encode('utf-8') + b'\n') outbuf.write(b'-------------------------\n') return outpath, outbuf