forked from dimagi/commcare-hq
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsettingshelper.py
30 lines (26 loc) · 1.09 KB
/
settingshelper.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
def get_server_url(server_root, username, password):
if username and password:
return "http://%(user)s:%(pass)s@%(server)s" % \
{"user": username,
"pass": password,
"server": server_root }
else:
return "http://%(server)s" % {"server": server_root }
def get_dynamic_db_settings(server_root, username, password, dbname, installed_apps):
"""
Get dynamic database settings. Other apps can use this if they want to change
settings
"""
server = get_server_url(server_root, username, password)
database = "%(server)s/%(database)s" % {"server": server, "database": dbname}
posturl = "http://%s/%s/_design/couchforms/_update/xform/" % (server_root, dbname)
return {"COUCH_SERVER": server,
"COUCH_DATABASE": database,
"XFORMS_POST_URL": posturl }
def get_commit_id():
# This command is never allowed to fail since it's called in settings
try:
import os
return os.popen("git log --format=%H -1").readlines()[0].strip()
except Exception:
return None