forked from jermnelson/bibframe-catalog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
make-config.py
39 lines (35 loc) · 1.24 KB
/
make-config.py
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
29
30
31
32
33
34
35
36
37
38
39
__author__ = "Jeremy Nelson"
import argparse
import hashlib
import os
import uuid
PROJECT_ROOT = os.path.abspath(os.path.dirname(__file__))
CONFIG_PATH = os.path.join(PROJECT_ROOT, "instance", "config.py")
def create_config(args):
if os.path.exists(CONFIG_PATH):
print("Configuration already exists")
return
os.mkdir(os.path.join(PROJECT_ROOT, "instance"))
with open(CONFIG_PATH, "w+") as config:
config.write("""SECRET_KEY="{}"\n""".format(args.secret_key))
config.write("""ELASTIC_SEARCH="{}"\n""".format(args.es_url))
config.write("""KIBANA_URL="{}"\n""".format(args.kibana_url))
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument(
'action',
choices=['create'],
help='Creates Bibcat Instance Configuration')
parser.add_argument(
'--es_url',
default='bf_search:9200',
help='Elasticsearch URL, defaults to localhost:9200')
parser.add_argument(
'--secret_key',
default = hashlib.sha1(os.urandom(30)).hexdigest(),
help='Secret key, defaults to os.urandom()')
parser.add_argument(
'--kibana_url',
default='kibana:5601')
args = parser.parse_args()
create_config(args)