def __init__(self, msg_file, config, msg_plain=False, json_dump_file=None):
if not os.path.exists(msg_file):
raise RuntimeError("File does not exist: %s" % msg_file)
logger.debug('Reading message from: %s', msg_file)
with open(msg_file, 'r') as fh:
raw = fh.read()
logger.debug('Read %d byte message', len(raw))
if msg_plain:
raw = raw.strip()
else:
logger.debug('base64-decoding and zlib decompressing message')
raw = zlib.decompress(base64.b64decode(raw))
if json_dump_file is not None:
with open(json_dump_file, 'w') as fh:
fh.write(raw)
self.data = json.loads(raw)
logger.debug('Loaded message JSON')
self.config = config
self.session = boto3.Session()
评论列表
文章目录