2019-12-13 01:19:16 +05:30
|
|
|
import os
|
2020-03-19 16:21:30 +05:30
|
|
|
import tkinter
|
2019-12-13 01:19:16 +05:30
|
|
|
|
2020-03-19 13:01:24 +05:30
|
|
|
class Environment:
|
2019-12-13 01:19:16 +05:30
|
|
|
|
|
|
|
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-19 16:21:30 +05:30
|
|
|
try:
|
2020-03-14 04:37:49 +05:30
|
|
|
tk = tkinter.Tk()
|
|
|
|
self.screen_width = tk.winfo_screenwidth()
|
|
|
|
self.screen_height = tk.winfo_screenheight()
|
2020-03-19 13:01:24 +05:30
|
|
|
tk.destroy()
|
2020-03-19 16:21:30 +05:30
|
|
|
except tkinter.TclError:
|
2020-03-14 04:37:49 +05:30
|
|
|
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 = {}
|
2020-01-14 03:56:40 +05:30
|
|
|
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
|