-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloader.py
More file actions
executable file
·28 lines (27 loc) · 854 Bytes
/
loader.py
File metadata and controls
executable file
·28 lines (27 loc) · 854 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import json
import sys
import os
def loadjson(exit_on_error):
error = False
argc = len(sys.argv)
if argc < 2 :
error = "No config file is provided."
if error == False:
configfile = sys.argv[1]
if os.path.exists(configfile) == False:
error = configfile + " no such file or directory"
if error == False and os.path.isfile(configfile) == False :
error = configfile + " is a directory"
if error == False:
with open(configfile) as file:
try :
lst = json.load(file)
socket = lst['socket']
except :
error = configfile + " not a valid json file"
if error == False:
return True, lst
if exit_on_error:
print(error)
exit(1)
return False, error