From a211f99319df66ff11a75746c5f7ab40ac19122a Mon Sep 17 00:00:00 2001 From: Chris Lovering Date: Mon, 6 Sep 2021 21:03:14 +0100 Subject: Use context manager for file open Also remove a useless print statement to reduce noise --- manage.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'manage.py') diff --git a/manage.py b/manage.py index ad9bae5f..63602d63 100755 --- a/manage.py +++ b/manage.py @@ -161,7 +161,6 @@ class SiteManager: exists = cursor.fetchone() if exists: # Assume metricity is already populated if it exists - print("Metricity already exists, not creating.") return print("Creating metricity relations and populating with some data.") cursor.execute("CREATE DATABASE metricity") @@ -171,8 +170,8 @@ class SiteManager: database="metricity", **db_connection_kwargs ) - with conn.cursor() as cursor: - cursor.execute(open("postgres/init.sql").read()) + with conn.cursor() as cursor, open("postgres/init.sql", encoding="utf-8") as f: + cursor.execute(f.read()) def prepare_server(self) -> None: """Perform preparation tasks before running the server.""" -- cgit v1.2.3