diff options
author | jakobst1n <jakob.stendahl@outlook.com> | 2018-09-07 00:32:51 +0200 |
---|---|---|
committer | jakobst1n <jakob.stendahl@outlook.com> | 2018-09-07 00:32:51 +0200 |
commit | 78d7c8d75a5f55ab56dd018edc85ebce9aa033bb (patch) | |
tree | 2ad9da977667b79236cfdd827d0446a5bf9fea18 /src/compileAndRun/pythonSupportFiles/entry.py | |
download | Luxcena-Neo-78d7c8d75a5f55ab56dd018edc85ebce9aa033bb.tar.gz Luxcena-Neo-78d7c8d75a5f55ab56dd018edc85ebce9aa033bb.zip |
: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.
Diffstat (limited to 'src/compileAndRun/pythonSupportFiles/entry.py')
-rw-r--r-- | src/compileAndRun/pythonSupportFiles/entry.py | 78 |
1 files changed, 78 insertions, 0 deletions
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() |