From f4dfb43402e1cd013cbd56e9995319b341ca3a24 Mon Sep 17 00:00:00 2001 From: Izalia Mae Date: Fri, 29 Nov 2019 15:24:07 -0500 Subject: [PATCH] add MASTOPATH var --- README.md | 2 +- block.py | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 57f8b4d..715471e 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Minimum Python version: 3.6.0 `pip install -r requirements.txt` -`cp block.py path/to/mastodon/root` +Copy 'block.py' or set MASTOPATH to your Mastodon root directory ## Usage If the path to a csv file is not specified, 'blocks.csv' in the current directory will be used. diff --git a/block.py b/block.py index d8f6bf3..cbe094c 100755 --- a/block.py +++ b/block.py @@ -13,18 +13,21 @@ import csv import datetime from os import environ as env -from os.path import dirname, exists +from os.path import dirname, exists, abspath from pg import DB from envbash import load_envbash +masto_path = env.get('MASTOPATH', abspath(dirname(__file__))) + + def dbconn(): try: - load_envbash('.env.production') + load_envbash(f'{masto_path}/.env.production') except FileNotFoundError: - print('Could not find ".env.production" in current directory.') + print(f'Could not find ".env.production" in {masto_path}') sys.exit(1) dbhost = env.get('DB_HOST', '/var/run/postgresql') @@ -215,6 +218,11 @@ def get(data): return msg +def noodle(heck): + return '''Skidaddle skidoodle! +Your dick is now a noodle!''' + + def main(): arg = sys.argv @@ -233,7 +241,8 @@ get 'import': load, 'ban': ban, 'unban': unban, - 'get': get + 'get': get, + 'noodle': noodle } if len(arg) < 2 or arg[1] not in tasks: