This repository has been archived on 2020-03-24. You can view files and clone it, but cannot push or open issues or pull requests.
quay/util/systemlogs.py
2014-12-23 14:01:00 -05:00

15 lines
No EOL
399 B
Python

import tarfile
import os
import cStringIO
def build_logs_archive(app):
""" Builds a .tar.gz with the contents of the system logs found for the given app and returns
the binary contents.
"""
path = app.config['SYSTEM_LOGS_PATH']
buf = cStringIO.StringIO()
with tarfile.open(mode="w:gz", fileobj=buf) as tar:
tar.add(path, arcname=os.path.basename(path))
return buf.getvalue()