3 #Create directory for files to append in the main file
6 Out = open("main.groovy", "w+")
7 GlobalVariablesBothApps = open("GlobalVariables/"+"GlobalVariablesBothApps.groovy", "r")
8 outGlobal = open("Extractor/"+"outGlobal.groovy", "r")
12 GlobalVariablesEachApp = open("GlobalVariables/"+"GlobalVariablesEachApp.groovy", "r")
13 setLocationMode = open("Methods/"+"setLocationMode.groovy", "r")
14 subscribe = open("Methods/"+"subscribe.groovy", "r")
15 runIn = open("Methods/"+"runIn.groovy", "r")
16 unschedule = open("Methods/"+"unschedule.groovy", "r")
17 sendNotificationToContacts = open("Methods/"+"sendNotificationToContacts.groovy", "r")
18 sendSms = open("Methods/"+"sendSms.groovy", "r")
19 eventHandler = open("Methods/"+"eventHandler.groovy", "r")
20 App1 = open("Extractor/"+"App1.groovy", "r")
21 extractedObjectsApp1 = open("Extractor/"+"extractedObjectsApp1.groovy", "r")
22 extractedObjectsConstructorApp1 = open("Extractor/"+"extractedObjectsConstructorApp1.groovy", "r")
25 #Extract information from preferences and subscribe method to create required objects
26 os.system("python Extractor/ExtractorScript.py")
28 Out.write("//Infrastructure for SmartThings Application\n")
29 Out.write("//Importing Libraries\n")
30 Out.write("import groovy.transform.Field\n")
32 Out.write("//Importing Classes\n")
33 Out.write("import ContactSensor.Contacting\n")
34 Out.write("import ContactSensor.Contacts\n")
35 Out.write("import Lock.Locking\n")
36 Out.write("import Lock.Locks\n")
37 Out.write("import Switch.Switching\n")
38 Out.write("import Switch.Switches\n")
39 Out.write("import Logger.Logger\n")
40 Out.write("import Location.LocationVar\n")
41 Out.write("import Location.Phrase\n")
42 Out.write("import appTouch.Touched\n")
43 Out.write("import Event.Event\n")
45 Out.write("//GlobalVariables for both Apps\n")
46 for line in GlobalVariablesBothApps:
49 Out.write("//Extracted global objects for both Apps\n")
50 for line in outGlobal:
53 Out.write("//Application #1\n")
54 Out.write("class App1 {\n")
55 Out.write("\tdef reference\n")
56 Out.write("\tdef location\n")
57 Out.write("\tdef app\n")
59 Out.write("\t//Extracted objects for App1\n")
60 for line in extractedObjectsApp1:
63 Out.write("\tApp1(Object obj) {\n")
64 Out.write("\t\treference = obj\n")
65 Out.write("\t\tlocation = obj.locationObject\n")
66 Out.write("\t\tapp = obj.appObject\n")
67 for line in extractedObjectsConstructorApp1:
68 Out.write("\t\t"+line)
70 Out.write("\t//Global variables for each app\n")
71 for line in GlobalVariablesEachApp:
74 Out.write("\t//Methods\n")
75 for line in setLocationMode:
77 for line in subscribe:
81 for line in unschedule:
83 for line in sendNotificationToContacts:
87 for line in eventHandler:
99 GlobalVariablesEachApp = open("GlobalVariables/"+"GlobalVariablesEachApp.groovy", "r")
102 GlobalVariablesEachApp = open("GlobalVariables/"+"GlobalVariablesEachApp.groovy", "r")
103 setLocationMode = open("Methods/"+"setLocationMode.groovy", "r")
104 subscribe = open("Methods/"+"subscribe.groovy", "r")
105 runIn = open("Methods/"+"runIn.groovy", "r")
106 unschedule = open("Methods/"+"unschedule.groovy", "r")
107 sendNotificationToContacts = open("Methods/"+"sendNotificationToContacts.groovy", "r")
108 sendSms = open("Methods/"+"sendSms.groovy", "r")
109 eventHandler = open("Methods/"+"eventHandler.groovy", "r")
110 App2 = open("Extractor/"+"App2.groovy", "r")
111 extractedObjectsApp2 = open("Extractor/"+"extractedObjectsApp2.groovy", "r")
112 extractedObjectsConstructorApp2 = open("Extractor/"+"extractedObjectsConstructorApp2.groovy", "r")
114 Out.write("//Application #2\n")
115 Out.write("class App2 {\n")
116 Out.write("\tdef reference\n")
117 Out.write("\tdef location\n")
118 Out.write("\tdef app\n")
120 Out.write("\t//Extracted objects for App2\n")
121 for line in extractedObjectsApp2:
124 Out.write("\tApp2(Object obj) {\n")
125 Out.write("\t\treference = obj\n")
126 Out.write("\t\tlocation = obj.locationObject\n")
127 Out.write("\t\tapp = obj.appObject\n")
128 for line in extractedObjectsConstructorApp2:
129 Out.write("\t\t"+line)
131 Out.write("\t//Global variables for each app\n")
132 for line in GlobalVariablesEachApp:
135 Out.write("\t//Methods\n")
136 for line in setLocationMode:
138 for line in subscribe:
142 for line in unschedule:
144 for line in sendNotificationToContacts:
148 for line in eventHandler:
159 Out.write("@Field def app1 = new App1(this)\n")
160 Out.write("@Field def app2 = new App2(this)\n")
161 Out.write("app1.installed()\n")
162 Out.write("app2.installed()\n")