示例#1
0
	def log_msg(self, msg, level="info", speech=False):
		if speech == True:
			rc = helper.speak_msg(msg)
			if rc > 0:
				helper.print_by_error_code(rc)
		if level == "debug":
			self.logger.debug(msg)
		elif level == "info":
			self.logger.info(msg)
		elif level == "warning":
			self.logger.warning(msg)
		elif level == "error":
			self.logger.error(msg)
		else:
			self.logger.critical(msg)
示例#2
0
		json_string = f.read()
		# parse the string
		try:
			user_profile = json.loads(json_string)
		except ValueError:
			log.log_msg("Error: Parsing of the user profile failed.", "error")
			sys.exit(2)

		dev_profile = DeviceProfile()
		compatible_modules = get_compatible_modules(dev_profile.get_device_profile(), imported_modules)
		c_modules = "compatible: ", compatible_modules
		log.log_msg(c_modules, "debug", False)
		solution_list = get_solutions(user_profile, compatible_modules)
		for s,m_set in zip(solution_list.keys(),solution_list.values()):
			module = m_set.__iter__().next()
			if len(m_set) > 1:
				print "More than one module is available for the ", s, "solution. At the moment the program chooses the first one	in the set"
			print "Configuring of the module", module().__str__()
			# get the values for the configurable options
			settings_to_apply = get_settings_to_apply(module().get_solution_list()[s], user_profile)
			print "settings: ", settings_to_apply
			rc = module().setup(s, settings_to_apply)
			rc = 0
			if rc == 0:
				print module().__str__(), "successfully configured"
			else:
				helper.print_by_error_code(rc)
		break