DAMASK_EICMD/python/damask/environment.py

36 lines
1.0 KiB
Python
Raw Normal View History

2019-12-13 01:19:16 +05:30
import os
class Environment():
def __init__(self):
"""Read and provide values of DAMASK configuration."""
2020-03-13 00:22:33 +05:30
self.options = self._get_options()
2020-03-14 04:37:49 +05:30
try:
import tkinter
tk = tkinter.Tk()
self.screen_width = tk.winfo_screenwidth()
self.screen_height = tk.winfo_screenheight()
except Exception:
self.screen_width = 1024
self.screen_height = 768
2019-12-13 01:19:16 +05:30
def relPath(self,relative = '.'):
2020-03-13 00:22:33 +05:30
"""Return absolute path from path relative to DAMASK root."""
2019-12-13 01:19:16 +05:30
return os.path.join(self.rootDir(),relative)
2020-03-13 00:22:33 +05:30
2019-12-13 01:19:16 +05:30
def rootDir(self):
2020-03-13 00:22:33 +05:30
"""Return DAMASK root path."""
2019-12-13 01:19:16 +05:30
return os.path.normpath(os.path.join(os.path.realpath(__file__),'../../../'))
2020-03-13 00:22:33 +05:30
def _get_options(self):
options = {}
for item in ['DAMASK_NUM_THREADS',
'MSC_ROOT',
'MARC_VERSION',
]:
2020-03-13 00:22:33 +05:30
options[item] = os.environ[item] if item in os.environ else None
return options