From 2173f7d7613b5158f4bb2f71a02df353c058c1ee Mon Sep 17 00:00:00 2001 From: emkael Date: Wed, 24 Feb 2016 23:38:27 +0100 Subject: * moving PHP app files to app/php and Python app files to app/python --- bin/import_cals.py | 11 +++++++---- bin/pyrun.sh | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) (limited to 'bin') diff --git a/bin/import_cals.py b/bin/import_cals.py index 34e607d..41f5542 100644 --- a/bin/import_cals.py +++ b/bin/import_cals.py @@ -20,18 +20,21 @@ CONFIG = json.load(open( def main(): cal_list = None - if not os.path.exists(CONFIG['cache']) or \ - int(time.time()) - int(os.path.getmtime(CONFIG['cache'])) > \ + cache_path = os.path.join( + os.path.dirname(os.path.realpath(__file__)), + CONFIG['cache']) + if not os.path.exists(cache_path) or \ + int(time.time()) - int(os.path.getmtime(cache_path)) > \ CONFIG['cache_time']: opener = urllib2.build_opener() opener.addheaders = [('User-Agent', CONFIG['user_agent'])] cal_list = json.loads(opener.open(CONFIG['reddit_url']).read()) cal_list = cal_list[0]['data']['children'][0]['data']['selftext'] - with open(CONFIG['cache'], 'w') as cache_file: + with open(cache_path, 'w') as cache_file: cache_file.write(cal_list) cache_file.close() else: - cal_list = open(CONFIG['cache'], 'r').read() + cal_list = open(cache_path, 'r').read() session = Session.create() diff --git a/bin/pyrun.sh b/bin/pyrun.sh index 188a0eb..36a3339 100755 --- a/bin/pyrun.sh +++ b/bin/pyrun.sh @@ -2,5 +2,5 @@ DIR=$(dirname $0) SCRIPT=$(echo $1 | sed 's/\.py\$//') shift -export PYTHONPATH=$DIR/.. +export PYTHONPATH=$DIR/../app/python/ python $DIR/$SCRIPT.py $@ -- cgit v1.2.3