Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 22 additions & 18 deletions API/Classes/Base/Config.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,28 @@
ALLOWED_EXTENSIONS = set(['zip', 'application/zip'])
ALLOWED_EXTENSIONS_XLS = set(['xls', 'xlsx'])

UPLOAD_FOLDER = Path('WebAPP')
WebAPP_PATH = Path('WebAPP')
DATA_STORAGE = Path("WebAPP", 'DataStorage')
CLASS_FOLDER = Path("WebAPP", 'Classes')
EXTRACT_FOLDER = Path("")
SOLVERs_FOLDER = Path('WebAPP', 'SOLVERs')


#absolute paths
# OSEMOSYS_ROOT = os.path.abspath(os.getcwd())
# UPLOAD_FOLDER = Path(OSEMOSYS_ROOT, 'WebAPP')
# WebAPP_PATH = Path(OSEMOSYS_ROOT, 'WebAPP')
# DATA_STORAGE = Path(OSEMOSYS_ROOT, "WebAPP", 'DataStorage')
# CLASS_FOLDER = Path(OSEMOSYS_ROOT, "WebAPP", 'Classes')
# EXTRACT_FOLDER = Path(OSEMOSYS_ROOT, "")
# SOLVERs_FOLDER = Path(OSEMOSYS_ROOT, 'WebAPP', 'SOLVERs')

os.chmod(DATA_STORAGE, 0o777)
# ── Absolute paths derived from this file's location ──
# Config.py lives at API/Classes/Base/Config.py
# Repository root is 3 levels up: Base/ → Classes/ → API/ → root
_THIS_DIR = Path(__file__).resolve().parent # .../API/Classes/Base
MUIO_ROOT = _THIS_DIR.parent.parent.parent # .../MUIO (repo root)

UPLOAD_FOLDER = MUIO_ROOT / 'WebAPP'
WebAPP_PATH = MUIO_ROOT / 'WebAPP'
DATA_STORAGE = MUIO_ROOT / 'WebAPP' / 'DataStorage'
CLASS_FOLDER = MUIO_ROOT / 'WebAPP' / 'Classes'
EXTRACT_FOLDER = MUIO_ROOT
SOLVERs_FOLDER = MUIO_ROOT / 'WebAPP' / 'SOLVERs'

# ── Ensure DataStorage directory exists ──
os.makedirs(DATA_STORAGE, exist_ok=True)

# ── Safe chmod (skip on Windows where octal modes are not supported) ──
if SYSTEM != 'Windows':
try:
os.chmod(DATA_STORAGE, 0o777)
except OSError:
pass # Non-fatal: permissions may already be sufficient

HEROKU_DEPLOY = 0
AWS_SYNC = 0
Expand Down
5 changes: 4 additions & 1 deletion API/Classes/Case/CaseClass.py
Original file line number Diff line number Diff line change
Expand Up @@ -613,8 +613,11 @@ def createCase(self):
try:
for group, array in self.PARAMETERS.items():
if array:
if group not in Config.DEFAULT_F:
print(f"[WARN] createCase: skipping unknown parameter group '{group}' (not in DEFAULT_F)")
continue
func_name = Config.DEFAULT_F[group]
func = getattr(self,func_name)
func = getattr(self, func_name)
func()

except(IOError):
Expand Down
12 changes: 6 additions & 6 deletions API/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
from Routes.Case.ViewDataRoute import viewdata_api
from Routes.DataFile.DataFileRoute import datafile_api

#RADI
template_dir = os.path.abspath('WebAPP')
static_dir = os.path.abspath('WebAPP')
# ── Use absolute paths from Config (derived from __file__, CWD-independent) ──
template_dir = str(Config.WebAPP_PATH)
static_dir = str(Config.WebAPP_PATH)

# template_dir = Config.WebAPP_PATH.resolve()
# static_dir = Config.WebAPP_PATH.resolve()
# template_dir = os.path.abspath('WebAPP')
# static_dir = os.path.abspath('WebAPP')

# template_dir = os.path.join(sys._MEIPASS, 'WebAPP')
# static_dir = os.path.join(sys._MEIPASS, 'WebAPP')
Expand All @@ -39,7 +39,7 @@

print(__name__)

app = Flask(__name__, static_url_path='', static_folder=static_dir, template_folder=template_dir)
app = Flask(__name__, static_url_path='', static_folder=static_dir, template_folder=template_dir)

app.permanent_session_lifetime = timedelta(days=5)
app.config['SECRET_KEY'] = '12345'
Expand Down