From 78d7c8d75a5f55ab56dd018edc85ebce9aa033bb Mon Sep 17 00:00:00 2001 From: jakobst1n Date: Fri, 7 Sep 2018 00:32:51 +0200 Subject: :construction: Add pre-v1 project Because of some stupid mistakes with the repo, I decided to delete the git history. Create a new, fresh repo, and move all the code there. Since all this is pre-v1, everything is in a testing-phase anyways. So i do not think we are going to feel the need for any history. The old repo is renamed to Luxcena-Neo-Old, and will be there until i convince myself i won't need the history. --- src/compileAndRun/pythonSupportFiles/entry.py | 78 +++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 src/compileAndRun/pythonSupportFiles/entry.py (limited to 'src/compileAndRun/pythonSupportFiles/entry.py') diff --git a/src/compileAndRun/pythonSupportFiles/entry.py b/src/compileAndRun/pythonSupportFiles/entry.py new file mode 100644 index 0000000..4ba1031 --- /dev/null +++ b/src/compileAndRun/pythonSupportFiles/entry.py @@ -0,0 +1,78 @@ +# This is the entry-point for all Luxcena-Neo python-scripts +# The script should be in the same folder as this, and be named "script.py" +# In the future you could possibly have more files and stuff alongside the "script.py"-file as well +import sys +import json +import importlib +import datetime + +def runSync(moduleSc, sc): + timeNow = datetime.datetime.now() + lastDay = timeNow.day + lastHour = timeNow.hour + lastMinute = timeNow.minute + lastSecond = timeNow.second + + while True: + timeNow = datetime.datetime.now() + + if ("LuxcenaNeo" in dir(moduleSc)): + if moduleSc.LuxcenaNeo.forceStop: break + elif ("neo" in dir(moduleSc)): + if moduleSc.neo.forceStop == True: break + + if (timeNow.second != lastSecond): + lastSecond = timeNow.second + sc.eachSecond() + + if (timeNow.minute != lastMinute): + lastMinute = timeNow.minute + sc.eachMinute() + + if (timeNow.hour != lastHour): + lastHour = timeNow.hour + sc.eachHour() + + if (timeNow.day != lastDay): + lastDay = timeNow.lastDay + sc.eachDay() + +def runAsync(moduleSc, sc): + return + +def main(): + print ("Starting script named \"{0}\"".format("test")) + + root_dir = sys.argv[1] + config_dir = root_dir + "/config/" + + print ("> Loading pixel-configuration...") + with open(config_dir + "strip.json", "r") as rawStripConf: + stripConf = json.load(rawStripConf) + segments = stripConf["segments"] + segmentConfiguration = stripConf["segmentConfiguration"] + + print ("> Initializing script...") + moduleSc = importlib.import_module("script") + + if ("LuxcenaNeo" in dir(moduleSc)): + moduleSc.LuxcenaNeo.strip = moduleSc.LuxcenaNeo.Strip(segments, segmentConfiguration) + elif ("neo" in dir(moduleSc)): + moduleSc.neo.strip = moduleSc.neo.Strip(segments, segmentConfiguration) + else: + raise Exception("Neither LuxcenaNeo nor neo found in script, check docs!") + + sc = moduleSc.Main() + + print ("> Running the script...") + sc.onStart() + + if (("async" in dir(moduleSc)) and (moduleSc.async == True)): + runAsync(moduleSc, sc) + else: + runSync(moduleSc, sc) + + print ("> Script exited...") + +if __name__ == "__main__": + main() -- cgit v1.2.3