Commit #7: Events thread-based + new easier Extractor.py + our own Timer class
[smartthings-infrastructure.git] / Runner.py
index 0514c39842c402457c87facad62671ec51ada089..440899b6993e735bc404a0560c23b787c6a9a9f7 100644 (file)
--- a/Runner.py
+++ b/Runner.py
@@ -2,11 +2,14 @@ import os
 
 #Create directory for files to append in the main file
 
 
 #Create directory for files to append in the main file
 
+#Extract information from preferences and subscribe method to create required objects
+os.system("python Extractor/ExtractorScript.py")
+
 #Files for both Apps
 Out = open("main.groovy", "w+")
 GlobalVariablesBothApps = open("GlobalVariables/"+"GlobalVariablesBothApps.groovy", "r")
 outGlobal = open("Extractor/"+"outGlobal.groovy", "r")
 #Files for both Apps
 Out = open("main.groovy", "w+")
 GlobalVariablesBothApps = open("GlobalVariables/"+"GlobalVariablesBothApps.groovy", "r")
 outGlobal = open("Extractor/"+"outGlobal.groovy", "r")
-
+eventSimulator = open("eventSimulator/"+"eventSimulator.groovy", "r")
 
 #For App1
 GlobalVariablesEachApp = open("GlobalVariables/"+"GlobalVariablesEachApp.groovy", "r")
 
 #For App1
 GlobalVariablesEachApp = open("GlobalVariables/"+"GlobalVariablesEachApp.groovy", "r")
@@ -16,14 +19,16 @@ runIn = open("Methods/"+"runIn.groovy", "r")
 unschedule = open("Methods/"+"unschedule.groovy", "r")
 sendNotificationToContacts = open("Methods/"+"sendNotificationToContacts.groovy", "r")
 sendSms = open("Methods/"+"sendSms.groovy", "r")
 unschedule = open("Methods/"+"unschedule.groovy", "r")
 sendNotificationToContacts = open("Methods/"+"sendNotificationToContacts.groovy", "r")
 sendSms = open("Methods/"+"sendSms.groovy", "r")
+sendPush = open("Methods/"+"sendPush.groovy", "r")
 eventHandler = open("Methods/"+"eventHandler.groovy", "r")
 eventHandler = open("Methods/"+"eventHandler.groovy", "r")
-App1 = open("Extractor/"+"App1.groovy", "r")
-extractedObjectsApp1 = open("Extractor/"+"extractedObjectsApp1.groovy", "r")
-extractedObjectsConstructorApp1 = open("Extractor/"+"extractedObjectsConstructorApp1.groovy", "r")
+schedule = open("Methods/"+"schedule.groovy", "r")
+App1 = open("Extractor/"+"App1/App1.groovy", "r")
+extractedObjectsApp1 = open("Extractor/"+"App1/extractedObjectsApp1.groovy", "r")
+extractedObjectsConstructorApp1 = open("Extractor/"+"App1/extractedObjectsConstructorApp1.groovy", "r")
+extractedFunctionsApp1 = open("Extractor/"+"App1/extractedFunctionsApp1.groovy", "r")
+
 
 
 
 
-#Extract information from preferences and subscribe method to create required objects
-os.system("python Extractor/ExtractorScript.py")
 
 Out.write("//Infrastructure for SmartThings Application\n")
 Out.write("//Importing Libraries\n")
 
 Out.write("//Infrastructure for SmartThings Application\n")
 Out.write("//Importing Libraries\n")
@@ -41,6 +46,7 @@ Out.write("import Location.LocationVar\n")
 Out.write("import Location.Phrase\n")
 Out.write("import appTouch.Touched\n")
 Out.write("import Event.Event\n")
 Out.write("import Location.Phrase\n")
 Out.write("import appTouch.Touched\n")
 Out.write("import Event.Event\n")
+Out.write("import Timer.SimulatedTimer\n")
 Out.write("\n")
 Out.write("//Global eventHandler\n")
 for line in eventHandler:
 Out.write("\n")
 Out.write("//Global eventHandler\n")
 for line in eventHandler:
@@ -64,6 +70,10 @@ Out.write("\t//Extracted objects for App1\n")
 for line in extractedObjectsApp1:
        Out.write("\t"+line)
 Out.write("\n")
 for line in extractedObjectsApp1:
        Out.write("\t"+line)
 Out.write("\n")
+Out.write("\t//Extracted objects for functions for App1\n")
+for line in extractedFunctionsApp1:
+       Out.write("\t"+line)
+Out.write("\n")
 Out.write("\tApp1(Object obj) {\n")
 Out.write("\t\treference = obj\n")
 Out.write("\t\tlocation = obj.locationObject\n")
 Out.write("\tApp1(Object obj) {\n")
 Out.write("\t\treference = obj\n")
 Out.write("\t\tlocation = obj.locationObject\n")
@@ -88,6 +98,10 @@ for line in sendNotificationToContacts:
        Out.write("\t"+line)
 for line in sendSms:
        Out.write("\t"+line)
        Out.write("\t"+line)
 for line in sendSms:
        Out.write("\t"+line)
+for line in sendPush:
+       Out.write("\t"+line)
+for line in schedule:
+       Out.write("\t"+line)
 Out.write("\n")
 Start = 0
 for line in App1:
 Out.write("\n")
 Start = 0
 for line in App1:
@@ -109,9 +123,11 @@ unschedule = open("Methods/"+"unschedule.groovy", "r")
 sendNotificationToContacts = open("Methods/"+"sendNotificationToContacts.groovy", "r")
 sendSms = open("Methods/"+"sendSms.groovy", "r")
 eventHandler = open("Methods/"+"eventHandler.groovy", "r")
 sendNotificationToContacts = open("Methods/"+"sendNotificationToContacts.groovy", "r")
 sendSms = open("Methods/"+"sendSms.groovy", "r")
 eventHandler = open("Methods/"+"eventHandler.groovy", "r")
-App2 = open("Extractor/"+"App2.groovy", "r")
-extractedObjectsApp2 = open("Extractor/"+"extractedObjectsApp2.groovy", "r")
-extractedObjectsConstructorApp2 = open("Extractor/"+"extractedObjectsConstructorApp2.groovy", "r")
+schedule = open("Methods/"+"schedule.groovy", "r")
+App2 = open("Extractor/"+"App2/App2.groovy", "r")
+extractedObjectsApp2 = open("Extractor/"+"App2/extractedObjectsApp2.groovy", "r")
+extractedObjectsConstructorApp2 = open("Extractor/"+"App2/extractedObjectsConstructorApp2.groovy", "r")
+extractedFunctionsApp2 = open("Extractor/"+"App2/extractedFunctionsApp2.groovy", "r")
 
 Out.write("//Application #2\n")
 Out.write("class App2 {\n")
 
 Out.write("//Application #2\n")
 Out.write("class App2 {\n")
@@ -123,6 +139,10 @@ Out.write("\t//Extracted objects for App2\n")
 for line in extractedObjectsApp2:
        Out.write("\t"+line)
 Out.write("\n")
 for line in extractedObjectsApp2:
        Out.write("\t"+line)
 Out.write("\n")
+Out.write("\t//Extracted objects for functions for App2\n")
+for line in extractedFunctionsApp2:
+       Out.write("\t"+line)
+Out.write("\n")
 Out.write("\tApp2(Object obj) {\n")
 Out.write("\t\treference = obj\n")
 Out.write("\t\tlocation = obj.locationObject\n")
 Out.write("\tApp2(Object obj) {\n")
 Out.write("\t\treference = obj\n")
 Out.write("\t\tlocation = obj.locationObject\n")
@@ -147,6 +167,10 @@ for line in sendNotificationToContacts:
        Out.write("\t"+line)
 for line in sendSms:
        Out.write("\t"+line)
        Out.write("\t"+line)
 for line in sendSms:
        Out.write("\t"+line)
+for line in sendPush:
+       Out.write("\t"+line)
+for line in schedule:
+       Out.write("\t"+line)
 Out.write("\n")
 Start = 0
 for line in App2:
 Out.write("\n")
 Start = 0
 for line in App2:
@@ -160,6 +184,9 @@ Out.write("@Field def app1 = new App1(this)\n")
 Out.write("@Field def app2 = new App2(this)\n")
 Out.write("app1.installed()\n")
 Out.write("app2.installed()\n")
 Out.write("@Field def app2 = new App2(this)\n")
 Out.write("app1.installed()\n")
 Out.write("app2.installed()\n")
+Out.write("\n")
+for line in eventSimulator:
+       Out.write("\t"+line)
 Out.close()
 
 
 Out.close()