2019-12-13 01:19:16 +05:30
|
|
|
import os
|
2020-06-03 17:02:47 +05:30
|
|
|
from pathlib import Path
|
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-06-30 07:20:33 +05:30
|
|
|
self.screen_width = 1024
|
|
|
|
self.screen_height = 768
|
2020-03-19 16:21:30 +05:30
|
|
|
try:
|
2020-06-30 07:20:33 +05:30
|
|
|
import wx
|
|
|
|
app = wx.App(False)
|
|
|
|
self.screenwidth, self.screenheight = wx.GetDisplaySize()
|
|
|
|
except ImportError:
|
|
|
|
try:
|
|
|
|
import tkinter
|
|
|
|
tk = tkinter.Tk()
|
|
|
|
self.screen_width = tk.winfo_screenwidth()
|
|
|
|
self.screen_height = tk.winfo_screenheight()
|
|
|
|
tk.destroy()
|
|
|
|
except:
|
|
|
|
pass
|
2019-12-13 01:19:16 +05:30
|
|
|
|
2020-06-03 17:02:47 +05:30
|
|
|
@property
|
|
|
|
def options(self):
|
2020-03-13 00:22:33 +05:30
|
|
|
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
|
2020-06-03 17:02:47 +05:30
|
|
|
|
|
|
|
@property
|
|
|
|
def root_dir(self):
|
|
|
|
"""Return DAMASK root path."""
|
|
|
|
return Path(__file__).parents[2]
|
|
|
|
|
|
|
|
|
|
|
|
# for compatibility
|
|
|
|
def rootDir(self):
|
|
|
|
return str(self.root_dir)
|