Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def get_worker_versions():
""" Search and return the versions of Oasis components
"""
ktool_ver_str = subprocess.getoutput('fmcalc -v')
plat_ver_file = '/home/worker/VERSION'
if os.path.isfile(plat_ver_file):
with open(plat_ver_file, 'r') as f:
plat_ver_str = f.read().strip()
else:
plat_ver_str = ""
return {"worker_verisons": {
"oasislmf": mdk_version,
"ktools": ktool_ver_str,
"platform": plat_ver_str
}}
def get(self, request):
peril_codes = {PERILS[p]['id']: {'desc': PERILS[p]['desc']} for p in PERILS.keys()}
peril_groups = {
PERIL_GROUPS[g]['id']: {
'desc': PERIL_GROUPS[g]['desc'],
'peril_ids': PERIL_GROUPS[g]['peril_ids']
} for g in PERIL_GROUPS.keys()
}
return Response({
'oasislmf_version': oasislmf_package_ver,
'peril_codes': peril_codes,
'peril_groups': peril_groups
})