add MASTOPATH var

This commit is contained in:
Izalia Mae 2019-11-29 15:24:07 -05:00
parent c1a57fecf2
commit f4dfb43402
2 changed files with 14 additions and 5 deletions

View file

@ -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.

View file

@ -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: