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

15 lines
399 B
Python
Raw Normal View History

2014-12-23 19:01:00 +00:00
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()