Files
CTFd/export.py
Kevin Chung a64e7d51ef Squashed 'CTFd/themes/core-beta/' changes from 9126d77d..5ce3003b
5ce3003b Merge pull request #47 from aCursedComrade/patch-1
c9887cb1 Fix team template

git-subtree-dir: CTFd/themes/core-beta
git-subtree-split: 5ce3003b4d68352e629ee2d390bc999e7d6b071e
2023-06-11 15:56:28 -04:00

29 lines
770 B
Python

from CTFd import create_app
from CTFd.utils import config
from CTFd.utils.exports import export_ctf
import datetime
import sys
import shutil
app = create_app()
with app.app_context():
print(
"This file will be deleted in CTFd v4.0. Switch to using `python manage.py export_ctf`"
)
backup = export_ctf()
if len(sys.argv) > 1:
with open(sys.argv[1], "wb") as target:
shutil.copyfileobj(backup, target)
else:
ctf_name = config.ctf_name()
day = datetime.datetime.now().strftime("%Y-%m-%d_%T")
full_name = "{}.{}.zip".format(ctf_name, day)
with open(full_name, "wb") as target:
shutil.copyfileobj(backup, target)
print("Exported {filename}".format(filename=full_name))