Subversion Repositories HomeAutomation

Rev

Rev 1994 | Rev 2006 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

Rev 1994 Rev 2003
Line 37... Line 37...
37
		
37
		
38
		if line.find(moduleName + "_ID") != -1:
38
		if line.find(moduleName + "_ID") != -1:
39
			parts = line.split("=")
39
			parts = line.split("=")
40
			if parts[1].strip(" ") != -1 and parts[1].strip(" ") != "<ID>":
40
			if parts[1].strip(" ") != -1 and parts[1].strip(" ") != "<ID>":
41
				takenIds.append(int(parts[1].strip(" "), 16))
41
				takenIds.append(int(parts[1].strip(" "), 16))
42
				print "hittade: "+parts[1].strip(" &quot;)+" in file: "+fileName
42
				print "Found id: "+parts[1].strip(" &quot;)+" in file: "+fileName+" for module: "+moduleName
43
	return takenIds
43
	return takenIds
44
 
44
 
45
 
45
 
46
def getModuleIdsFromFile(moduleName):
46
def getModuleIdsFromFile(moduleName):
47
	takenIds = []
47
	takenIds = []
Line 49... Line 49...
49
		if applicationName[0] != '.' and os.path.exists("../" + applicationName + "/config.inc"):
49
		if applicationName[0] != '.' and os.path.exists("../" + applicationName + "/config.inc"):
50
			takenIds = parseModuleIdFromFile(moduleName, "../" + applicationName + "/config.inc")
50
			takenIds = parseModuleIdFromFile(moduleName, "../" + applicationName + "/config.inc")
51
 
51
 
52
	return takenIds
52
	return takenIds
53
	
53
	
-
 
54
def parseAllModuleIdFromFile(fileName):
-
 
55
	modules = getModules()
-
 
56
	config_inc = open(fileName, 'r') 
-
 
57
	config_inc_lines = config_inc.readlines()
-
 
58
	config_inc.close()
-
 
59
	for line in config_inc_lines:
-
 
60
		line = line.strip("\n").strip(" ")
-
 
61
		
-
 
62
		if line.find("_ID") != -1:
-
 
63
			parts = line.split("=")
-
 
64
			if (parts[0][:-3] in modules):
-
 
65
				if parts[1].strip(" ") != -1 and parts[1].strip(" ") != "<ID>":
-
 
66
					print "\tModule: "+parts[0][:-3]+"\t"+parts[1].strip(" ")
-
 
67
	
-
 
68
def getAllModuleIdsFromFile():
-
 
69
	for applicationName in os.listdir("../"):	
-
 
70
		if applicationName[0] != '.' and os.path.exists("../" + applicationName + "/config.inc"):
-
 
71
			print "Found node: "+applicationName
-
 
72
			parseAllModuleIdFromFile("../" + applicationName + "/config.inc")
54
 
73
 
55
def getFreeModuleId(takenIds):
74
def getFreeModuleId(takenIds):
56
	if len(takenIds) == 0:
75
	if len(takenIds) == 0:
57
		return 1
76
		return 1
58
	takenIds.sort()
77
	takenIds.sort()
Line 138... Line 157...
138
	moduleSections = {}
157
	moduleSections = {}
139
	applicationSection = []
158
	applicationSection = []
140
	moduleName="none"
159
	moduleName="none"
141
	if not os.path.exists("config.inc"):
160
	if not os.path.exists("config.inc"):
142
		applicationSection = readConfigSection("src/config.inc.template", "application")
161
		applicationSection = readConfigSection("src/config.inc.template", "application")
143
		
162
		
144
		for moduleName in modules:
163
		for moduleName in modules:
145
			moduleSections[moduleName] = readConfigSection(localmoddir + "/" + moduleName + "/config.inc.template", moduleName)
164
			moduleSections[moduleName] = readConfigSection(localmoddir + "/" + moduleName + "/config.inc.template", moduleName)
146
	else:
165
	else:
147
		applicationSection = readConfigSection("config.inc", "application")
166
		applicationSection = readConfigSection("config.inc", "application")
148
		
167
		
Line 227... Line 246...
227
		for libraries_list_template_line in libraries_list_template_lines:
246
		for libraries_list_template_line in libraries_list_template_lines:
228
			line =libraries_list_template_line.strip("\n").strip(" ")
247
			line =libraries_list_template_line.strip("\n").strip(" ")
229
			if len(line) > 0:
248
			if len(line) > 0:
230
				if line[0] != '#':
249
				if line[0] != '#':
231
					uniqueSet2.append(line)
250
					uniqueSet2.append(line)
232
	
251
	
233
	for sources_list_template_line in sources_list_template_lines:
252
	for sources_list_template_line in sources_list_template_lines:
234
		line = sources_list_template_line.strip("\n").strip(" ")
253
		line = sources_list_template_line.strip("\n").strip(" ")
235
		if len(line) > 0:
254
		if len(line) > 0:
236
			if line[0] != '#':
255
			if line[0] != '#':
237
				uniqueSet.append(line)
256
				uniqueSet.append(line)
Line 286... Line 305...
286
	updateConfigFile()
305
	updateConfigFile()
287
	print ""
306
	print ""
288
	print "Regenerating modules complete"
307
	print "Regenerating modules complete"
289
	print ""
308
	print ""
290
 
309
 
-
 
310
def listUsedModules():
-
 
311
	print "Listing modules..."
-
 
312
	print ""
-
 
313
	getAllModuleIdsFromFile()
-
 
314
	print ""
-
 
315
	print "Listing modules complete"
-
 
316
	print ""
291
 
317
 
292
def addModule(moduleName):
318
def addModule(moduleName):
293
	print "Trying to add module " + moduleName
319
	print "Trying to add module " + moduleName
294
	
320
	
295
	try:
321
	try:
Line 360... Line 386...
360
	print "  --regenerate         Regenarate modules and files"
386
	print "  --regenerate         Regenarate modules and files"
361
	print "  --list               List avalible and installed modules"
387
	print "  --list               List avalible and installed modules"
362
	print "  --add=<module name>  Adds a module to the application"
388
	print "  --add=<module name>  Adds a module to the application"
363
	print "  --del=<module name>  Removes a module from the application"
389
	print "  --del=<module name>  Removes a module from the application"
364
	print "  --new=<module name>  Creates a new module from the module template"
390
	print "  --new=<module name>  Creates a new module from the module template"
-
 
391
	print "  --modules            Lists all used modules in your personal folder"
365
	print ""
392
	print ""
366
 
393
 
367
 
394
 
368
def main():
395
def main():
369
	try:
396
	try:
370
		opts, args = getopt.getopt(sys.argv[1:], "hlrc", ["help", "list", "regenerate", "add=", "del=", "new="])
397
		opts, args = getopt.getopt(sys.argv[1:], "hlrcm", ["help", "list", "modules", "regenerate", "add=", "del=", "new="])
371
	except getopt.GetoptError, err:
398
	except getopt.GetoptError, err:
372
		# print help information and exit:
399
		# print help information and exit:
373
		print str(err) # will print something like "option -a not recognized"
400
		print str(err) # will print something like "option -a not recognized"
374
		usage()
401
		usage()
375
		sys.exit(2)
402
		sys.exit(2)
376
	
403
	
377
	if len(sys.argv) == 1:
404
	if len(sys.argv) == 1:
378
		usage()
405
		usage()
379
		sys.exit()
406
		sys.exit()
380
	
407
	
381
	for o, a in opts:
408
	for o, a in opts:
382
		if o in ("-c"):
409
		if o in ("-c"):
383
			modules = getModules()
410
			modules = getModules()
384
			
411
			
385
			for module in modules:
412
			for module in modules:
386
				print module
413
				print module
387
 
414
 
388
		elif o in ("-l", "--list"):
415
		elif o in ("-l", "--list"):
389
			modules = getModules()
416
			modules = getModules()
390
			print "Available modules"
417
			print "Available modules"
391
			print "================="
418
			print "================="
392
			for module in modules:
419
			for module in modules:
393
				print module
420
				print module
394
			
421
			
395
 
422
 
396
			if os.path.exists(localmoddir):
423
			if os.path.exists(localmoddir):
397
				print ""
424
				print ""
398
			
425
			
399
				modules = getLocalModules()
426
				modules = getLocalModules()
400
			
427
			
401
				print "Modules used in this application"
428
				print "Modules used in this application"
402
				print "================================"
429
				print "================================"
403
				for module in modules:
430
				for module in modules:
404
					print module
431
					print module
405
			
432
			
Line 407... Line 434...
407
			usage()
434
			usage()
408
			sys.exit()
435
			sys.exit()
409
			
436
			
410
		elif o in ("-r", "--regenerate"):
437
		elif o in ("-r", "--regenerate"):
411
			regenerateModules()
438
			regenerateModules()
-
 
439
			
-
 
440
		elif o in ("-m", "--modules"):
-
 
441
			listUsedModules()
412
			
442
			
413
		elif o in ("--add"):
443
		elif o in ("--add"):
414
			if len(a) == 0:
444
			if len(a) == 0:
415
				print "No modulename specified"
445
				print "No modulename specified"
416
				usage()
446
				usage()