diff --git a/project/__init__.py b/project/__init__.py index 79acc89..ff34703 100644 --- a/project/__init__.py +++ b/project/__init__.py @@ -16,10 +16,6 @@ from apispec import APISpec from apispec.ext.marshmallow import MarshmallowPlugin from flask_apispec.extension import FlaskApiSpec import pathlib -import logging - -logging.basicConfig() -logging.getLogger("sqlalchemy.engine").setLevel(logging.INFO) # Create app app = Flask(__name__) diff --git a/project/cli/dump.py b/project/cli/dump.py index bf93fb9..7404dcd 100644 --- a/project/cli/dump.py +++ b/project/cli/dump.py @@ -21,7 +21,7 @@ from project.api.organizer.schemas import OrganizerDumpSchema from project.api.image.schemas import ImageDumpSchema from project.api.organization.schemas import OrganizationDumpSchema from project.api.event_reference.schemas import EventReferenceDumpSchema -import os.path +import os import shutil import pathlib @@ -42,7 +42,12 @@ def dump_items(items, schema, file_base_name, dump_path): def dump_all(): # Setup temp dir tmp_path = os.path.join(dump_path, "tmp") - pathlib.Path(tmp_path).mkdir(parents=True, exist_ok=True) + + try: + original_umask = os.umask(0) + pathlib.Path(tmp_path).mkdir(parents=True, exist_ok=True) + finally: + os.umask(original_umask) # Events events = Event.query.options(joinedload(Event.categories)).all() diff --git a/project/views/root.py b/project/views/root.py index 3c55f66..1738ca2 100644 --- a/project/views/root.py +++ b/project/views/root.py @@ -65,5 +65,7 @@ def developer(): "size": os.path.getsize(all_path), "ctime": os.path.getctime(all_path), } + else: + print("No file at %s" % all_path) return render_template("developer/read.html", dump_file=dump_file) diff --git a/tests/cli/test_dump.py b/tests/cli/test_dump.py index 6031365..e4a71e1 100644 --- a/tests/cli/test_dump.py +++ b/tests/cli/test_dump.py @@ -6,4 +6,5 @@ def test_all(client, seeder, app, utils): result = runner.invoke(args=["dump", "all"]) assert "Zipped all up" in result.output + utils.get_endpoint_ok("developer") utils.get_endpoint_ok("dump_files", path="all.zip") diff --git a/tests/views/test_root.py b/tests/views/test_root.py index 2de9711..be4ac73 100644 --- a/tests/views/test_root.py +++ b/tests/views/test_root.py @@ -1,3 +1,7 @@ +import os +from project import dump_path + + def test_home(client, seeder, utils): url = utils.get_url("home") utils.get_ok(url) @@ -65,5 +69,11 @@ def test_privacy(app, db, utils): def test_developer(client, seeder, utils): + file_name = "all.zip" + all_path = os.path.join(dump_path, file_name) + + if os.path.exists(all_path): + os.remove(all_path) + url = utils.get_url("developer") utils.get_ok(url)