diff options
| author | 2021-09-06 21:03:14 +0100 | |
|---|---|---|
| committer | 2021-09-06 21:07:53 +0100 | |
| commit | a211f99319df66ff11a75746c5f7ab40ac19122a (patch) | |
| tree | 3f5da790cc43b166de4c82165ef691df3f7f0dcb | |
| parent | Initialise metricity at runtime (diff) | |
Use context manager for file open
Also remove a useless print statement to reduce noise
| -rwxr-xr-x | manage.py | 5 | 
1 files changed, 2 insertions, 3 deletions
@@ -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."""  |