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 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'bin/import_cals.py') 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() -- cgit v1.2.3