44import os
55import pickle
66import time
7+ import platform
78from datetime import datetime
89from matplotlib import pyplot as plt
910
@@ -62,6 +63,20 @@ def formatTimestamp(ts):
6263 return datetime .fromtimestamp (float (ts )).strftime ("%Y-%m-%d %H:%M:%S" )
6364 except Exception :
6465 return str (ts )
66+
67+ def detect_platform ():
68+ system = platform .system ().lower ()
69+
70+ if system == 'windows' :
71+ return "windows"
72+ elif system == 'linux' :
73+ if os .path .exists ("/data/data/com.termux" ):
74+ return "android"
75+ return "linux"
76+ elif system == 'darwin' :
77+ return "macos"
78+ else :
79+ return "unknown"
6580
6681class Menu_Manager :
6782 def __init__ (self ):
@@ -145,7 +160,7 @@ def renderMenu(self, task):
145160 collums , lines = os .get_terminal_size ()
146161 headerHeight = 1
147162 bodyHeight = lines - headerHeight
148- os .system ('cls' )
163+ os .system ('clear' if platform != 'windows' else ' cls' )
149164 self .printHeader (headerHeight , collums )
150165 return self .printBody (bodyHeight , collums , task )
151166
@@ -369,6 +384,7 @@ def main():
369384 global base_dir
370385 global log
371386 global menu
387+ global platform
372388
373389 global working_dir
374390 global resultsPath
@@ -391,6 +407,8 @@ def main():
391407 log .append ("Initializing..." )
392408 base_dir = os .path .dirname (os .path .abspath (__file__ ))
393409 menu = Menu_Manager ()
410+ platform = utils .detect_platform ()
411+ log .append (f"Detected platform: { platform } " )
394412 while True :
395413 if working_dir is None :
396414 task = {"type" : "options" , "name" : "Main Menu" , "options" : {1 : "Create New Simulation" , 2 : "Load Existing Simulation" , 3 : "Exit" }}
0 commit comments