all repos — nasg @ aa1e9b3eec2c11e561e6bc1753fcb1fd861bd470

making config reading path-resistent by finding the abspath for nasg.py instead of relying on ./
Peter Molnar hello@petermolnar.eu
Wed, 21 Mar 2018 18:39:26 +0000
commit

aa1e9b3eec2c11e561e6bc1753fcb1fd861bd470

parent

b9b0561c137cc28b19ae5d8de61b9a6cc5568dd1

1 files changed, 8 insertions(+), 1 deletions(-)

jump to
M shared.pyshared.py

@@ -40,6 +40,8 @@ import sqlite3

import requests from slugify import slugify import jinja2 +from inspect import getsourcefile +import sys class CMDLine(object):

@@ -603,7 +605,12 @@ c = configparser.ConfigParser(

interpolation=configparser.ExtendedInterpolation(), allow_no_value=True ) - c.read('config.ini') + conffile = os.path.join( + os.path.dirname(os.path.abspath(getsourcefile(lambda:0))), + 'config.ini' + ) + c.read(conffile) + for s in c.sections(): for o in c.options(s): curr = c.get(s, o)