Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def read_disk_config():
"""
Volumes - this is tricky to bend .ini files to handle lists of tuples
The encoded json approach was just too fragile.
So a new section is being added
"""
try:
confd = config.read_ini(CONFIGLOCATION)
if confd["devstation_config_root"].startswith("~/"):
confd["devstation_config_root"] = confd["devstation_config_root"].replace(
"~", os.path.expanduser("~")
)
volumesd = config.read_ini(CONFIGLOCATION)["volumes"]
#: we want to convert an ini section to a dict.
confd["volumes"] = {}
for k, i in volumesd.items():
if "~/" in k:
# convert ~/data to /home/user/data
newkey = os.path.join(os.path.expanduser("~"), k.replace("~/", ""))
# we should have volumes = {'/home/user/data': '/var/data'}
confd["volumes"][newkey] = i
hasconfigdir = True
except Exception as e:
log.error("Failed to read config - error is %s", e)
def read_disk_config():
"""
Volumes - this is tricky to bend .ini files to handle lists of tuples
The encoded json approach was just too fragile.
So a new section is being added
"""
try:
confd = config.read_ini(CONFIGLOCATION)
if confd["devstation_config_root"].startswith("~/"):
confd["devstation_config_root"] = confd["devstation_config_root"].replace(
"~", os.path.expanduser("~")
)
volumesd = config.read_ini(CONFIGLOCATION)["volumes"]
#: we want to convert an ini section to a dict.
confd["volumes"] = {}
for k, i in volumesd.items():
if "~/" in k:
# convert ~/data to /home/user/data
newkey = os.path.join(os.path.expanduser("~"), k.replace("~/", ""))
# we should have volumes = {'/home/user/data': '/var/data'}
confd["volumes"][newkey] = i
hasconfigdir = True
except Exception as e:
log.error("Failed to read config - error is %s", e)
if PDB:
import pdb
pdb.set_trace()
confd = {}