From 4438d797e775ce0d95b6cd22fea69ae899567c9a Mon Sep 17 00:00:00 2001 From: Lynne Date: Thu, 21 Feb 2019 13:37:45 +1000 Subject: [PATCH] use config.sample.json if config.json doesn't exist --- main.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index 2c52f98..5b7e100 100755 --- a/main.py +++ b/main.py @@ -7,12 +7,16 @@ from mastodon import Mastodon from os import path from bs4 import BeautifulSoup -import os, sqlite3, signal, sys, json, re +import os, sqlite3, signal, sys, json, re, shutil import requests import functions scopes = ["read:statuses", "read:accounts", "read:follows", "write:statuses", "read:notifications"] -cfg = json.load(open('config.json', 'r')) +try: + cfg = json.load(open('config.json', 'r')) +except: + shutil.copy2("config.sample.json", "config.json") + cfg = json.load(open('config.json', 'r')) #config.json *MUST* contain the instance URL, the instance blacklist (for dead/broken instances), and the CW text. if they're not provided, we'll fall back to defaults. if 'site' not in cfg: @@ -186,4 +190,4 @@ print("Done!") db.commit() db.execute("VACUUM") #compact db db.commit() -db.close() \ No newline at end of file +db.close()