Changeset - f643ffc5d90b
[Not reviewed]
default
0 1 0
Dennis Fink - 10 years ago 2015-07-08 22:22:14

raise runtime error if default_json_file does not exists or is not a file
1 file changed with 6 insertions and 0 deletions:
0 comments (0 inline, 0 general)
spaceapi/active.py
Show inline comments
 
import copy
 
import json
 
import os.path
 

	
 

	
 
default_json_file = os.path.abspath('default.json')
 
last_state_file = os.path.abspath('laststate.json')
 

	
 
if not os.path.exists(default_json_file):
 
    raise RuntimeError('default.json does not exists!')
 
elif not os.path.isfile(default_json_file):
 
    raise RuntimeError('defaul.json is not a file!')
 

	
 

	
 
default_json = {}
 
active_json = {}
 

	
 

	
 
def reload_json():
 
    global default_json
 
    global active_json
 

	
 
    default_json = json.load(open(default_json_file, encoding='utf-8'))
 

	
 
    if os.path.exists(last_state_file):
 
        with open(last_state_file, encoding='utf-8') as f:
0 comments (0 inline, 0 general)